36 lines
900 B
TypeScript
36 lines
900 B
TypeScript
![]() |
import { makeRequest } from "@frontend/kitui";
|
|||
|
import { parseAxiosError } from "@root/utils/parse-error";
|
|||
|
|
|||
|
export interface GetHistoryResponse {
|
|||
|
totalPages: number;
|
|||
|
records: {
|
|||
|
id: string;
|
|||
|
userId: string;
|
|||
|
type: string;
|
|||
|
isDeleted: boolean;
|
|||
|
createdAt: string;
|
|||
|
updatedAt: string;
|
|||
|
deletedAt: string;
|
|||
|
comment: string;
|
|||
|
rawDetails: {
|
|||
|
tariffs: string[];
|
|||
|
};
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
export async function getHistory(): Promise<[GetHistoryResponse | null, string?]> {
|
|||
|
try {
|
|||
|
const historyResponse = await makeRequest<never, GetHistoryResponse>({
|
|||
|
url: "https://penahub.gitlab.yandexcloud.net/history?page=1&limit=100",
|
|||
|
method: "get",
|
|||
|
useToken: true,
|
|||
|
});
|
|||
|
|
|||
|
return [historyResponse];
|
|||
|
} catch (nativeError) {
|
|||
|
const [error] = parseAxiosError(nativeError);
|
|||
|
|
|||
|
return [null, `Не удалось получить историю. ${error}`];
|
|||
|
}
|
|||
|
}
|