2023-11-05 23:33:40 +00:00
|
|
|
|
import { Tariff, makeRequest } from "@frontend/kitui"
|
|
|
|
|
import { parseAxiosError } from "@root/utils/parse-error"
|
2023-09-12 21:45:18 +00:00
|
|
|
|
|
|
|
|
|
export interface GetHistoryResponse {
|
|
|
|
|
totalPages: number;
|
2023-09-15 21:00:02 +00:00
|
|
|
|
records: HistoryRecord[];
|
2023-09-12 21:45:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-10 14:51:50 +00:00
|
|
|
|
export type HistoryRecord = {
|
2023-09-15 21:00:02 +00:00
|
|
|
|
comment: string;
|
|
|
|
|
createdAt: string;
|
|
|
|
|
id: string;
|
|
|
|
|
isDeleted: boolean;
|
|
|
|
|
key: string;
|
2023-10-16 21:05:18 +00:00
|
|
|
|
rawDetails: [RawDetails, KeyValue];
|
2023-09-15 21:00:02 +00:00
|
|
|
|
updatedAt: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-16 21:05:18 +00:00
|
|
|
|
type RawDetails = { Key: string; Value: KeyValue[][] }
|
2023-09-16 12:24:19 +00:00
|
|
|
|
type KeyValue = { Key: string; Value: string | number };
|
|
|
|
|
|
2023-09-12 21:45:18 +00:00
|
|
|
|
export async function getHistory(): Promise<[GetHistoryResponse | null, string?]> {
|
2023-11-05 23:33:40 +00:00
|
|
|
|
try {
|
|
|
|
|
const historyResponse = await makeRequest<never, GetHistoryResponse>({
|
|
|
|
|
url: "https://hub.pena.digital/customer/history?page=1&limit=100&type=payCart",
|
|
|
|
|
method: "get",
|
|
|
|
|
useToken: true,
|
|
|
|
|
})
|
2023-09-12 21:45:18 +00:00
|
|
|
|
|
2023-11-05 23:33:40 +00:00
|
|
|
|
return [historyResponse]
|
|
|
|
|
} catch (nativeError) {
|
|
|
|
|
const [error] = parseAxiosError(nativeError)
|
2023-09-12 21:45:18 +00:00
|
|
|
|
|
2023-11-05 23:33:40 +00:00
|
|
|
|
return [null, `Не удалось получить историю. ${error}`]
|
|
|
|
|
}
|
2023-09-12 21:45:18 +00:00
|
|
|
|
}
|