From 0969cde841cd22ea704567f516c8b86ee221969e Mon Sep 17 00:00:00 2001 From: jessikitty Date: Mon, 2 Feb 2026 12:10:45 +1100 Subject: [PATCH] Update chores API: Add multi-user support, birthday filtering, and points - Added AssignedUser interface with birthday and completed_at fields - Updated Chore interface with assigned_users array and points field - Added assigned_user_ids to CreateChoreRequest and UpdateChoreRequest - Added query params to getChores: user_id and exclude_birthdays - Added assignUsers method for POST /chores/{id}/assign endpoint - Updated frequency enum to include 'on_trigger' and 'fortnightly' --- frontend/src/api/chores.ts | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) 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; + }, };