Skip to content

Commit

Permalink
[CARE-6533] Passed params as object
Browse files Browse the repository at this point in the history
  • Loading branch information
fgyimah committed Nov 5, 2024
1 parent 93b1be4 commit d08d648
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions modules/InfiniteStories/InfiniteStories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ type Props = {
total: number;
};

function fetchStories(
localeCode: Locale.Code,
offset: number,
limit: number,
category: Props['category'],
excludedStoryUuids: Story['uuid'][] | undefined,
tag: Props['tag'],
) {
function fetchStories(props: {
localeCode: Locale.Code;
offset: number;
limit: number;
category: Props['category'];
excludedStoryUuids: Story['uuid'][] | undefined;
tag: Props['tag'];
}) {
const { localeCode, offset, limit, category, excludedStoryUuids, tag } = props;
return http.get<{ data: ListStory[]; total: number }>('/api/stories', {
limit,
offset,
Expand Down Expand Up @@ -68,7 +69,15 @@ export function InfiniteStories({
const locale = useLocale();
const { load, loading, data, done } = useInfiniteLoading(
useCallback(
(offset) => fetchStories(locale, offset, pageSize, category, excludedStoryUuids, tag),
(offset) =>
fetchStories({
localeCode: locale,
offset,
limit: pageSize,
category,
excludedStoryUuids,
tag,
}),
[category, excludedStoryUuids, locale, pageSize, tag],
),
{ data: initialStories, total },
Expand Down

0 comments on commit d08d648

Please sign in to comment.