1
|
import { SortOptions } from "../types/general"
|
2
|
import { Note } from "../types/note"
|
3
|
import { axiosInstance } from "./api"
|
4
|
|
5
|
|
6
|
export const getItemNotesRequest = async (itemId : string) => {
|
7
|
return await axiosInstance.get(
|
8
|
`/notes/?item_id[]=${itemId}`
|
9
|
)
|
10
|
}
|
11
|
|
12
|
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
|
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
|
|
42
|
|