Add comprehensive .gitignore
This commit is contained in:
60
maternal-web/lib/api/children.ts
Normal file
60
maternal-web/lib/api/children.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import apiClient from './client';
|
||||
|
||||
export interface Child {
|
||||
id: string;
|
||||
familyId: string;
|
||||
name: string;
|
||||
birthDate: string;
|
||||
gender: 'male' | 'female' | 'other';
|
||||
photoUrl?: string;
|
||||
medicalInfo?: any;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CreateChildData {
|
||||
name: string;
|
||||
birthDate: string;
|
||||
gender: 'male' | 'female' | 'other';
|
||||
photoUrl?: string;
|
||||
medicalInfo?: any;
|
||||
}
|
||||
|
||||
export interface UpdateChildData extends Partial<CreateChildData> {}
|
||||
|
||||
export const childrenApi = {
|
||||
// Get all children for the authenticated user
|
||||
getChildren: async (familyId?: string): Promise<Child[]> => {
|
||||
const params = familyId ? { familyId } : {};
|
||||
const response = await apiClient.get('/api/v1/children', { params });
|
||||
return response.data.data.children;
|
||||
},
|
||||
|
||||
// Get a specific child
|
||||
getChild: async (id: string): Promise<Child> => {
|
||||
const response = await apiClient.get(`/api/v1/children/${id}`);
|
||||
return response.data.data.child;
|
||||
},
|
||||
|
||||
// Create a new child
|
||||
createChild: async (familyId: string, data: CreateChildData): Promise<Child> => {
|
||||
const response = await apiClient.post(`/api/v1/children?familyId=${familyId}`, data);
|
||||
return response.data.data.child;
|
||||
},
|
||||
|
||||
// Update a child
|
||||
updateChild: async (id: string, data: UpdateChildData): Promise<Child> => {
|
||||
const response = await apiClient.patch(`/api/v1/children/${id}`, data);
|
||||
return response.data.data.child;
|
||||
},
|
||||
|
||||
// Delete a child
|
||||
deleteChild: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/api/v1/children/${id}`);
|
||||
},
|
||||
|
||||
// Get child's age
|
||||
getChildAge: async (id: string): Promise<{ ageInMonths: number; ageInYears: number; remainingMonths: number }> => {
|
||||
const response = await apiClient.get(`/api/v1/children/${id}/age`);
|
||||
return response.data.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user