Skip to content

Commit

Permalink
fix using testuser as recipientId for historyPage
Browse files Browse the repository at this point in the history
  • Loading branch information
stCarolas committed Jun 16, 2024
1 parent 077acbf commit cfef5f0
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/pages/History/HistoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from "@opendonationassistant/oda-history-service-client";
import { usePagination } from "ahooks";
import { PaginationResult } from "ahooks/lib/usePagination/types";
import { useLoaderData } from "react-router";
import { WidgetData } from "../../types/WidgetData";

const dateTimeFormat = new Intl.DateTimeFormat("ru-RU", {
year: "numeric",
Expand Down Expand Up @@ -63,22 +65,6 @@ function description(item: HistoryItemData) {
return desc;
}

async function getHistory(params: {
current: number;
pageSize: number;
}): Promise<{ total: number; list: HistoryItemData[] }> {
const history = await HistoryService(
undefined,
process.env.REACT_APP_HISTORY_API_ENDPOINT,
).getHistory(
{
recipientId: "testuser",
},
{ params: { size: params.pageSize, page: params.current - 1 } },
);
return { total: history.data.totalSize, list: history.data?.content };
}

function list(data: HistoryItemData[], pagination: any) {
return (
<List
Expand All @@ -90,7 +76,7 @@ function list(data: HistoryItemData[], pagination: any) {
onChange: pagination.onChange,
onShowSizeChange: pagination.onChange,
showSizeChanger: true,
pageSizeOptions: [5,10,15,20,25],
pageSizeOptions: [5, 10, 15, 20, 25],
align: "center",
position: "bottom",
}}
Expand Down Expand Up @@ -125,7 +111,26 @@ function list(data: HistoryItemData[], pagination: any) {
}

export default function HistoryPage({}) {
const { data, loading, pagination } = usePagination(getHistory, {defaultPageSize: 5});
const { recipientId } = useLoaderData() as WidgetData;
const { data, loading, pagination } = usePagination(getHistory, {
defaultPageSize: 5,
});

async function getHistory(params: {
current: number;
pageSize: number;
}): Promise<{ total: number; list: HistoryItemData[] }> {
const history = await HistoryService(
undefined,
process.env.REACT_APP_HISTORY_API_ENDPOINT,
).getHistory(
{
recipientId: recipientId,
},
{ params: { size: params.pageSize, page: params.current - 1 } },
);
return { total: history.data.totalSize, list: history.data?.content };
}

return (
<>
Expand Down

0 comments on commit cfef5f0

Please sign in to comment.