front-hub/src/api/history.ts

36 lines
900 B
TypeScript
Raw Normal View History

2023-09-12 21:45:18 +00:00
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}`];
}
}