-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
40 lines (32 loc) · 1.19 KB
/
Copy pathindex.ts
File metadata and controls
40 lines (32 loc) · 1.19 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
import { instance } from '..';
import { CreateVoteOptionRequest, CreateVoteRequest } from './request';
import { VoteListResponse } from './response';
const router = '/votes';
const exemplaryRouter = '/candidate-list';
export const getVoteList = async () => {
const { data } = await instance.get<VoteListResponse>(`${router}`);
return data;
};
export const createVote = async (body: CreateVoteRequest) => {
await instance.post(`${router}`, body);
};
export const patchVote = async (body: CreateVoteRequest, votingId: string) => {
await instance.patch(`${router}/${votingId}`, body);
};
export const deleteVote = async (votingId: string) => {
await instance.delete(`${router}/${votingId}`);
};
export const createVoteOption = async (body: CreateVoteOptionRequest) => {
const { data } = await instance.post(`${router}/options`, body);
return data;
};
export const getVoteResult = async (votingTopicId: string) => {
const { data } = await instance.get(`${router}/result/${votingTopicId}`);
return data;
};
export const getExemplaryStudents = async (requestDate: string) => {
const { data } = await instance.get(exemplaryRouter, {
params: { requestDate },
});
return data.students;
};