Spaces:
Sleeping
Sleeping
| import { query } from "@/shared/api/query"; | |
| import { GetLogsRequestParams, GetLogsResponseType } from "./types"; | |
| import { downloadFile } from "@/shared/utils/downloadFile"; | |
| export const getLogs = async (params: GetLogsRequestParams): Promise<GetLogsResponseType> => { | |
| const response = await query<GetLogsResponseType>({ | |
| url: "/logs", | |
| method: "get", | |
| params: params, | |
| }); | |
| if ("error" in response) { | |
| throw new Error(`Ошибка: ${response.error.status}`); | |
| } | |
| return response.data; | |
| }; | |
| export const downloadLogsAsExcel = async (params: GetLogsRequestParams, filename: string): Promise<Blob> => { | |
| const response = await query<Blob>({ | |
| url: `/logs/excel`, | |
| method: "get", | |
| params: params, | |
| responseType: "blob", | |
| }); | |
| if ("error" in response) { | |
| throw new Error(`Ошибка: ${response.error.status}`); | |
| } | |
| downloadFile(response, filename); | |
| return response.data; | |
| }; | |