-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparticipants.ts
More file actions
57 lines (51 loc) · 1.62 KB
/
participants.ts
File metadata and controls
57 lines (51 loc) · 1.62 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
import { axiosClient } from '../../../shared/types/api/http-client';
export const getParticipants = async (
eventId: number,
tags: string = 'all',
page: number = 0,
size: number = 10
) => {
const params = { eventId, tags, page, size };
const response = await axiosClient.get('/host-channels/dashboard/participant-management', { params });
return response.data.result;
};
export const approveParticipants = async ({ orderId }: { orderId: number }) => {
try {
const response = await axiosClient.patch('/host-channels/dashboard/participant-management/approve', { orderId });
return response.data;
} catch (error) {
console.log(error);
}
};
export const downloadExcel = async (eventId:number): Promise<void> => {
const response = await axiosClient.get(
'/host-channels/dashboard/participant-management/excel',
{
responseType: 'blob',
params: { eventId },
}
);
console.log(response.headers)
//파일이름 추출
const disposition = response.headers['content-disposition'];
let filename = '기본값.xlsx';
if (disposition) {
const match = disposition.match(/filename\*=UTF-8''(.+)/);
if (match && match[1]) {
filename = decodeURIComponent(match[1]);
}
}
console.log(disposition)
//저장
const blob = new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
});
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
};