add event CRUD actions and recurring event expansion
- Implement full CRUD in MongoEventRepository (findById, findByUserId, findByDateRange, update, delete) - Extend ChatService to handle create/update/delete actions with dynamic test responses - Add recurrenceExpander utility using rrule library for RRULE parsing - Add eventFormatters utility for German-localized week/month overviews - Add German translations for days and months in shared Constants - Update client ChatService to support all event actions (action, eventId, updates params)
This commit is contained in:
@@ -4,15 +4,22 @@ import { EventModel } from './models';
|
||||
|
||||
export class MongoEventRepository implements EventRepository {
|
||||
async findById(id: string): Promise<CalendarEvent | null> {
|
||||
throw new Error('Not implemented');
|
||||
const event = await EventModel.findById(id);
|
||||
if (!event) return null;
|
||||
return event.toJSON() as unknown as CalendarEvent;
|
||||
}
|
||||
|
||||
async findByUserId(userId: string): Promise<CalendarEvent[]> {
|
||||
throw new Error('Not implemented');
|
||||
const events = await EventModel.find({ userId }).sort({ startTime: 1 });
|
||||
return events.map(e => e.toJSON() as unknown as CalendarEvent);
|
||||
}
|
||||
|
||||
async findByDateRange(userId: string, startDate: Date, endDate: Date): Promise<CalendarEvent[]> {
|
||||
throw new Error('Not implemented');
|
||||
const events = await EventModel.find({
|
||||
userId,
|
||||
startTime: { $gte: startDate, $lte: endDate }
|
||||
}).sort({ startTime: 1 });
|
||||
return events.map(e => e.toJSON() as unknown as CalendarEvent);
|
||||
}
|
||||
|
||||
async create(userId: string, data: CreateEventDTO): Promise<CalendarEvent> {
|
||||
@@ -22,10 +29,13 @@ export class MongoEventRepository implements EventRepository {
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateEventDTO): Promise<CalendarEvent | null> {
|
||||
throw new Error('Not implemented');
|
||||
const event = await EventModel.findByIdAndUpdate(id, data, { new: true });
|
||||
if (!event) return null;
|
||||
return event.toJSON() as unknown as CalendarEvent;
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<boolean> {
|
||||
throw new Error('Not implemented');
|
||||
const result = await EventModel.findByIdAndDelete(id);
|
||||
return result !== null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user