14 lines
664 B
TypeScript
14 lines
664 B
TypeScript
import { apiPost, apiPatch, apiDelete } from './client';
|
|
import type { Entry } from '$lib/types/api';
|
|
|
|
export function createEntry(date: string, mealId: number, productId: number, grams: number): Promise<Entry> {
|
|
return apiPost<Entry>(`/diary/${date}/meal/${mealId}/entry`, { product_id: productId, grams });
|
|
}
|
|
|
|
export function updateEntry(date: string, mealId: number, id: number, patch: { grams?: number }): Promise<Entry> {
|
|
return apiPatch<Entry>(`/diary/${date}/meal/${mealId}/entry/${id}`, patch);
|
|
}
|
|
|
|
export function deleteEntry(date: string, mealId: number, id: number): Promise<void> {
|
|
return apiDelete(`/diary/${date}/meal/${mealId}/entry/${id}`);
|
|
}
|