Skip to content

Commit

Permalink
fix: server update localised pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrusegard committed Feb 7, 2024
1 parent c831228 commit 2c7b192
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"next": "Next",
"goToNextPage": "Go to next page",
"morePages": "More pages",
"page": "Page"
"page": "page"
},
"layout": {
"hackerspaceHome": "Hackerspace homepage",
Expand Down
2 changes: 1 addition & 1 deletion messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"next": "Neste",
"goToNextPage": "Gå til neste side",
"morePages": "Flere sider",
"page": "Side"
"page": "side"
},
"layout": {
"hackerspaceHome": "Hackerspace hjemmeside",
Expand Down
10 changes: 5 additions & 5 deletions src/app/[locale]/(dashboard)/news/(header)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export async function generateMetadata({
};
}

const searchParamsCache = createSearchParamsCache({
page: parseAsInteger.withDefault(1),
});

export default function News({
params: { locale },
searchParams,
Expand All @@ -35,7 +31,11 @@ export default function News({
}) {
unstable_setRequestLocale(locale);
const t = useTranslations('ui');
const { page } = searchParamsCache.parse(searchParams);
const searchParamsCache = createSearchParamsCache({
[t('page')]: parseAsInteger.withDefault(1),
});

const { [t('page')]: page = 1 } = searchParamsCache.parse(searchParams);
// TODO: Button to create new article should only be visible when logged in
return (
<>
Expand Down
5 changes: 4 additions & 1 deletion src/components/layout/PaginationCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ function PaginationCarousel({
totalPages,
t,
}: PaginationCarouselProps) {
const [page, setPage] = useQueryState(t.page, parseAsInteger.withDefault(1));
const [page, setPage] = useQueryState(
t.page,
parseAsInteger.withDefault(1).withOptions({ shallow: false }),
);

function handlePrevious(e: React.MouseEvent<HTMLAnchorElement>) {
e.preventDefault();
Expand Down

0 comments on commit 2c7b192

Please sign in to comment.