source: frontend/src/api/diary.ts

main
Last change on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[700e2f9]1import { apiClient } from "@/api/client";
2
3export interface DiaryEntry {
4 idDiary: number;
5 date: string; // ISO date string
6 dailyRating: number;
7 content: string;
8}
9
10export interface CreateDiaryEntryRequest {
11 dailyRating: number;
12 content: string;
13}
14
15export interface UpdateDiaryEntryRequest {
16 content: string;
17 dailyRating?: number; // only for the current day's entries
18}
19
20export const diaryApi = {
21 getDiaryEntries: async (
22 patientId: number,
23 year: number,
24 month: number,
25 ): Promise<DiaryEntry[]> =>
26 apiClient.get<DiaryEntry[]>(
27 `/diary/${patientId}?year=${year}&month=${month}`,
28 ),
29
30 createDiaryEntry: async (
31 data: CreateDiaryEntryRequest,
32 ): Promise<DiaryEntry> => apiClient.post<DiaryEntry>("/diary", data),
33
34 updateDiaryEntry: async (
35 diaryId: number,
36 data: UpdateDiaryEntryRequest,
37 ): Promise<DiaryEntry> =>
38 apiClient.put<DiaryEntry>(`/diary/${diaryId}`, data),
39
40 deleteDiaryEntry: async (diaryId: number): Promise<void> =>
41 apiClient.delete<void>(`/diary/${diaryId}`),
42};
Note: See TracBrowser for help on using the repository browser.