Skip to content

Commit

Permalink
fix(frontend): use total to control multi-page selection
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 11, 2023
1 parent 7209c6c commit 3acfd87
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/GZCTF/ClientApp/src/pages/admin/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ const Logs: FC = () => {
>
<Icon path={mdiArrowLeftBold} size={1} />
</ActionIcon>
<Text fw="bold" size="sm">
{activePage}
</Text>
<ActionIcon
size="lg"
disabled={logs && logs.length < ITEM_COUNT_PER_PAGE}
Expand Down
7 changes: 5 additions & 2 deletions src/GZCTF/ClientApp/src/pages/admin/Teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const Teams: FC = () => {
})
.then((res) => {
setTeams(res.data)
setCurrent((page - 1) * ITEM_COUNT_PER_PAGE + res.data.length)
setCurrent(res.data.length)
})
.catch(showErrorNotification)
.finally(() => {
Expand Down Expand Up @@ -169,9 +169,12 @@ const Teams: FC = () => {
<ActionIcon size="lg" disabled={page <= 1} onClick={() => setPage(page - 1)}>
<Icon path={mdiArrowLeftBold} size={1} />
</ActionIcon>
<Text fw="bold" size="sm">
{page}
</Text>
<ActionIcon
size="lg"
disabled={teams && teams.length < ITEM_COUNT_PER_PAGE}
disabled={page * ITEM_COUNT_PER_PAGE >= total}
onClick={() => setPage(page + 1)}
>
<Icon path={mdiArrowRightBold} size={1} />
Expand Down
7 changes: 5 additions & 2 deletions src/GZCTF/ClientApp/src/pages/admin/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const Users: FC = () => {
})
.then((res) => {
setUsers(res.data)
setCurrent((page - 1) * ITEM_COUNT_PER_PAGE + res.data.length)
setCurrent(res.data.length)
})
.catch(showErrorNotification)
.finally(() => {
Expand Down Expand Up @@ -211,9 +211,12 @@ const Users: FC = () => {
<ActionIcon size="lg" disabled={page <= 1} onClick={() => setPage(page - 1)}>
<Icon path={mdiArrowLeftBold} size={1} />
</ActionIcon>
<Text fw="bold" size="sm">
{page}
</Text>
<ActionIcon
size="lg"
disabled={users && users.length < ITEM_COUNT_PER_PAGE}
disabled={page * ITEM_COUNT_PER_PAGE >= total}
onClick={() => setPage(page + 1)}
>
<Icon path={mdiArrowRightBold} size={1} />
Expand Down
5 changes: 4 additions & 1 deletion src/GZCTF/ClientApp/src/pages/admin/games/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ const Games: FC = () => {
<ActionIcon size="lg" disabled={page <= 1} onClick={() => setPage(page - 1)}>
<Icon path={mdiArrowLeftBold} size={1} />
</ActionIcon>
<Text fw="bold" size="sm">
{page}
</Text>
<ActionIcon
size="lg"
disabled={games && games.length < ITEM_COUNT_PER_PAGE}
disabled={page * ITEM_COUNT_PER_PAGE >= total}
onClick={() => setPage(page + 1)}
>
<Icon path={mdiArrowRightBold} size={1} />
Expand Down

0 comments on commit 3acfd87

Please sign in to comment.