1 |
bb690a9a
|
Fantič
|
import { SortOptions } from "../types/general"
|
2 |
3a226033
|
Fantič
|
import { Note } from "../types/note"
|
3 |
97deff21
|
Fantič
|
import { axiosInstance } from "./api"
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
export const getItemNotesRequest = async (itemId : string) => {
|
7 |
|
|
return await axiosInstance.get(
|
8 |
bb690a9a
|
Fantič
|
`/notes/?item_id[]=${itemId}`
|
9 |
97deff21
|
Fantič
|
)
|
10 |
|
|
}
|
11 |
b225ffee
|
Fantič
|
|
12 |
3a226033
|
Fantič
|
export const updateNoteRequest = async (note : Note) => {
|
13 |
|
|
return await axiosInstance.put(`/note`, note);
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
export const createNoteRequest = async (note : Note) => {
|
17 |
|
|
return await axiosInstance.post(`/note`, note);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
export const deleteNoteRequest = async (noteId : string) => {
|
21 |
|
|
return await axiosInstance.delete(
|
22 |
|
|
`/note/${noteId}`
|
23 |
|
|
)
|
24 |
|
|
}
|
25 |
|
|
|
26 |
bb690a9a
|
Fantič
|
export const getAllNotesRequest = async (myComments : boolean, generalComments : boolean, sortOptions: { items: SortOptions, date: SortOptions }) => {
|
27 |
|
|
let url = `/notes/?my_notes=${myComments}&general_notes=${generalComments}`;
|
28 |
|
|
|
29 |
|
|
if(sortOptions.date != SortOptions.None){
|
30 |
|
|
url += "&order_by=date&order_dir="+sortOptions.date;
|
31 |
|
|
}
|
32 |
|
|
if(sortOptions.items != SortOptions.None){
|
33 |
|
|
url += "&order_by=items&order_dir="+sortOptions.items;
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
return await axiosInstance.get(
|
37 |
|
|
url
|
38 |
|
|
)
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
|