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