38 lines
995 B
TypeScript
38 lines
995 B
TypeScript
import { Tariff, makeRequest } from "@frontend/kitui"
|
||
import { parseAxiosError } from "@root/utils/parse-error"
|
||
|
||
export interface GetHistoryResponse {
|
||
totalPages: number;
|
||
records: HistoryRecord[];
|
||
}
|
||
|
||
export type HistoryRecord = {
|
||
comment: string;
|
||
createdAt: string;
|
||
id: string;
|
||
isDeleted: boolean;
|
||
key: string;
|
||
rawDetails: [RawDetails, KeyValue];
|
||
updatedAt: string;
|
||
userId: string;
|
||
};
|
||
|
||
type RawDetails = { Key: string; Value: KeyValue[][] }
|
||
type KeyValue = { Key: string; Value: string | number };
|
||
|
||
export async function getHistory(): Promise<[GetHistoryResponse | null, string?]> {
|
||
try {
|
||
const historyResponse = await makeRequest<never, GetHistoryResponse>({
|
||
url: "https://hub.pena.digital/customer/history?page=1&limit=100&type=payCart",
|
||
method: "get",
|
||
useToken: true,
|
||
})
|
||
|
||
return [historyResponse]
|
||
} catch (nativeError) {
|
||
const [error] = parseAxiosError(nativeError)
|
||
|
||
return [null, `Не удалось получить историю. ${error}`]
|
||
}
|
||
}
|