source: frontend/src/api/therapy.ts@ 700e2f9

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

Init

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import { apiClient } from "@/api/client";
2
3export interface Therapy {
4 idTherapy: number;
5 name: string;
6 dose: string;
7 expDate: string;
8 consultationId: number;
9}
10
11export interface CreateTherapyRequest {
12 name: string;
13 dose: string;
14 expDate: string;
15}
16
17export interface UpdateTherapyRequest {
18 name?: string;
19 dose?: string;
20 expDate?: string;
21}
22
23export const therapyApi = {
24 getTherapiesByConsultation: async (
25 consultationId: number,
26 ): Promise<Therapy[]> =>
27 apiClient.get<Therapy[]>(`/therapies/consultation/${consultationId}`),
28
29 createTherapy: async (
30 consultationId: number,
31 data: CreateTherapyRequest,
32 ): Promise<Therapy> =>
33 apiClient.post<Therapy>(`/therapies/consultation/${consultationId}`, data),
34
35 updateTherapy: async (
36 therapyId: number,
37 data: UpdateTherapyRequest,
38 ): Promise<Therapy> =>
39 apiClient.put<Therapy>(`/therapies/${therapyId}`, data),
40
41 deleteTherapy: async (therapyId: number): Promise<void> =>
42 apiClient.delete<void>(`/therapies/${therapyId}`),
43};
Note: See TracBrowser for help on using the repository browser.