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