Skip to content

Commit

Permalink
fix(ui-ux): fix route issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fullstackninja864 committed Nov 22, 2023
1 parent 77a2838 commit 7fd2319
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 16 deletions.
5 changes: 3 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dayjs-plugin-utc": "^0.1.2",
"ethers": "^5.7.2",
"lodash": "^4.17.21",
"next": "13.4.12",
"react-code-blocks": "0.0.9-0",
"react-dropzone": "^14.2.3",
"react-qr-code": "^2.0.11",
Expand All @@ -36,8 +37,8 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.7",
"@netlify/plugin-lighthouse": "^4.1.1",
"@netlify/plugin-nextjs": "^4.38.0",
"@netlify/plugin-lighthouse": "^5.0.0",
"@netlify/plugin-nextjs": "^4.41.2",
"@tailwindcss/line-clamp": "^0.4.4",
"@testing-library/cypress": "^9.0.0",
"@types/node": "18.16.3",
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/components/commons/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ const Link = forwardRef<HTMLAnchorElement, PropsWithChildren<LinkProps>>(
passHref
{...props}
ref={ref}
as={{
pathname,
query: {
...query,
...networkQuery,
}
}}
href={{
pathname,
query: {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/components/commons/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function Pagination<T>({
},
next: nextPageParams,
};
console.log({ currentPageNumber })

if (nextPageParamsFromApi === undefined || nextPageParamsFromApi === null) {
return [pageButton.previous, pageButton.current];
Expand All @@ -81,6 +82,7 @@ export default function Pagination<T>({
}, [source]);

useEffect(() => {
console.log(router.query)
if (
!previousPagesParams.some(
(page) => page?.page_number === (router.query.page_number as string),
Expand All @@ -99,14 +101,15 @@ export default function Pagination<T>({
}, [router.query]);

useEffect(() => {
console.log({ previousPagesParams }, router.query.page_number)
// bug: clicking on the arrow button will cause the page to go back to page 1
// If pageNumber > 1 and previousPagesParams (local state) is cleared, go back to page 1
if (
Number(router.query.page_number) > 1 &&
previousPagesParams.length === 0
) {
setPreviousPagesParams([]);
router.push(pathName);
// router.push(pathName);
}
}, [router.query]);

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/pages/blocks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export async function getServerSideProps(
// Pass data to the page via props
return { props: { data } };
} catch (e) {
console.log({ e })
return { notFound: true };
}
}
Loading

0 comments on commit 7fd2319

Please sign in to comment.