Skip to content

Commit

Permalink
fix(frontend): pass userId to router.push()
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCatLady committed Mar 29, 2021
1 parent 701dd13 commit 2f92dba
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions src/components/RequestList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ const RequestList: React.FC = () => {
name="filter"
onChange={(e) => {
setCurrentFilter(e.target.value as Filter);
router.push(router.pathname);
router.push({
pathname: router.pathname,
query: { userId: router.query.userId },
});
}}
value={currentFilter}
className="rounded-r-only"
Expand Down Expand Up @@ -176,7 +179,10 @@ const RequestList: React.FC = () => {
name="sort"
onChange={(e) => {
setCurrentSort(e.target.value as Sort);
router.push(router.pathname);
router.push({
pathname: router.pathname,
query: { userId: router.query.userId },
});
}}
value={currentSort}
className="rounded-r-only"
Expand Down Expand Up @@ -250,7 +256,10 @@ const RequestList: React.FC = () => {
onChange={(e) => {
setCurrentPageSize(Number(e.target.value));
router
.push(router.pathname)
.push({
pathname: router.pathname,
query: { userId: router.query.userId },
})
.then(() => window.scrollTo(0, 0));
}}
value={currentPageSize}
Expand All @@ -271,9 +280,16 @@ const RequestList: React.FC = () => {
disabled={!hasPrevPage}
onClick={() =>
router
.push(`${router.pathname}?page=${page - 1}`, undefined, {
shallow: true,
})
.push(
{
pathname: `${router.pathname}?page=${page - 1}`,
query: { userId: router.query.userId },
},
undefined,
{
shallow: true,
}
)
.then(() => window.scrollTo(0, 0))
}
>
Expand All @@ -283,9 +299,16 @@ const RequestList: React.FC = () => {
disabled={!hasNextPage}
onClick={() =>
router
.push(`${router.pathname}?page=${page + 1}`, undefined, {
shallow: true,
})
.push(
{
pathname: `${router.pathname}?page=${page + 1}`,
query: { userId: router.query.userId },
},
undefined,
{
shallow: true,
}
)
.then(() => window.scrollTo(0, 0))
}
>
Expand Down

0 comments on commit 2f92dba

Please sign in to comment.