diff --git a/frontend/src/api/chores.ts b/frontend/src/api/chores.ts index f42c85e..411cc85 100644 --- a/frontend/src/api/chores.ts +++ b/frontend/src/api/chores.ts @@ -1,14 +1,24 @@ import api from './axios'; +export interface AssignedUser { + id: number; + username: string; + full_name: string; + birthday?: string; + completed_at?: string; +} + export interface Chore { id: number; title: string; - description: string; + description?: string; room: string; - frequency: 'daily' | 'weekly' | 'monthly' | 'once'; + frequency: 'daily' | 'weekly' | 'fortnightly' | 'monthly' | 'on_trigger'; + points: number; status: 'pending' | 'in_progress' | 'completed' | 'skipped'; - assigned_to?: number; - assigned_user?: { + assigned_users: AssignedUser[]; // Multiple users + assigned_user_id?: number; // Legacy field + assigned_user?: { // Legacy field id: number; username: string; full_name: string; @@ -23,8 +33,9 @@ export interface CreateChoreRequest { title: string; description?: string; room: string; - frequency: 'daily' | 'weekly' | 'monthly' | 'once'; - assigned_to?: number; + frequency: 'daily' | 'weekly' | 'fortnightly' | 'monthly' | 'on_trigger'; + points?: number; + assigned_user_ids?: number[]; // Multiple users due_date?: string; } @@ -32,15 +43,16 @@ export interface UpdateChoreRequest { title?: string; description?: string; room?: string; - frequency?: 'daily' | 'weekly' | 'monthly' | 'once'; + frequency?: 'daily' | 'weekly' | 'fortnightly' | 'monthly' | 'on_trigger'; + points?: number; status?: 'pending' | 'in_progress' | 'completed' | 'skipped'; - assigned_to?: number; + assigned_user_ids?: number[]; // Multiple users due_date?: string; } export const choreService = { - async getChores(): Promise { - const response = await api.get('/api/v1/chores'); + async getChores(params?: { user_id?: number; exclude_birthdays?: boolean }): Promise { + const response = await api.get('/api/v1/chores', { params }); return response.data; }, @@ -69,4 +81,9 @@ export const choreService = { }); return response.data; }, + + async assignUsers(choreId: number, userIds: number[]): Promise { + const response = await api.post(`/api/v1/chores/${choreId}/assign`, userIds); + return response.data; + }, };