forked from amand33p/bug-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbugs.ts
More file actions
70 lines (61 loc) · 1.5 KB
/
Copy pathbugs.ts
File metadata and controls
70 lines (61 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import axios from 'axios';
import backendUrl from '../backendUrl';
import { setConfig } from './auth';
import { BugPayload } from '../redux/types';
const baseUrl = `${backendUrl}/projects`;
const getBugs = async (projectId: string) => {
const response = await axios.get(`${baseUrl}/${projectId}/bugs`, setConfig());
return response.data;
};
const createBug = async (projectId: string, bugData: BugPayload) => {
const response = await axios.post(
`${baseUrl}/${projectId}/bugs`,
bugData,
setConfig()
);
return response.data;
};
const updateBug = async (
projectId: string,
bugId: string,
bugData: BugPayload
) => {
const response = await axios.put(
`${baseUrl}/${projectId}/bugs/${bugId}`,
bugData,
setConfig()
);
return response.data;
};
const deleteBug = async (projectId: string, bugId: string) => {
const response = await axios.delete(
`${baseUrl}/${projectId}/bugs/${bugId}`,
setConfig()
);
return response.data;
};
const closeBug = async (projectId: string, bugId: string) => {
const response = await axios.post(
`${baseUrl}/${projectId}/bugs/${bugId}/close`,
null,
setConfig()
);
return response.data;
};
const reopenBug = async (projectId: string, bugId: string) => {
const response = await axios.post(
`${baseUrl}/${projectId}/bugs/${bugId}/reopen`,
null,
setConfig()
);
return response.data;
};
const bugService = {
getBugs,
createBug,
updateBug,
deleteBug,
closeBug,
reopenBug,
};
export default bugService;