Skip to content

Commit

Permalink
fix: null error on next and prev
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Feb 28, 2024
1 parent 6d78c01 commit b506f84
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"uuid": "9.0.1"
},
"devDependencies": {
"@commitlint/config-conventional": "18.6.2",
"@commitlint/config-conventional": "19.0.3",
"@cypress/code-coverage": "3.12.26",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/katex": "^0.16.7",
Expand Down
16 changes: 12 additions & 4 deletions src/modules/item/NavigationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import { Box } from '@mui/material';

import { DiscriminatedItem, ItemType, Triggers } from '@graasp/sdk';
import { ActionTriggers, DiscriminatedItem, ItemType } from '@graasp/sdk';
import { Button } from '@graasp/ui';

import { hooks, mutations } from '@/config/queryClient';
Expand Down Expand Up @@ -50,7 +50,7 @@ const NavigationButton = ({
}

const handleClickNavigationButton = (itemId: string) => {
triggerAction({ itemId, payload: { type: Triggers.ItemView } });
triggerAction({ itemId, payload: { type: ActionTriggers.ItemView } });
setFocusedItemId(itemId);
};

Expand All @@ -65,7 +65,11 @@ const NavigationButton = ({
<Button
variant="outlined"
startIcon={<ArrowBackIcon />}
onClick={() => handleClickNavigationButton(prev.id)}
onClick={() => {
if (prev && prev.id) {
handleClickNavigationButton(prev.id);
}
}}
>
{prev.name}
</Button>
Expand All @@ -75,7 +79,11 @@ const NavigationButton = ({
{next ? (
<Button
endIcon={<ArrowForwardIcon />}
onClick={() => handleClickNavigationButton(next.id)}
onClick={() => {
if (next && next.id) {
handleClickNavigationButton(next.id);
}
}}
>
{next.name}
</Button>
Expand Down
40 changes: 25 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ __metadata:
languageName: node
linkType: hard

"@commitlint/config-conventional@npm:18.6.2":
version: 18.6.2
resolution: "@commitlint/config-conventional@npm:18.6.2"
"@commitlint/config-conventional@npm:19.0.3":
version: 19.0.3
resolution: "@commitlint/config-conventional@npm:19.0.3"
dependencies:
"@commitlint/types": "npm:^18.6.1"
"@commitlint/types": "npm:^19.0.3"
conventional-changelog-conventionalcommits: "npm:^7.0.2"
checksum: 10/4e7ba8c1e80e4fbb1677e820f1d07a16fc092a4d4f8e87c46100b01fb682ceb4b3e625c322daccbc7c6ae801d0a129810b47a69854edb76581f5ae70a596c112
checksum: 10/6fa0aec688739c5da97848ff42d17625f4f81b282a512049f16a2699ecfbbd06673ea04a10dba6d4756414aded858cadccf7b8cb8a50e74174a7268dd7c4b2cc
languageName: node
linkType: hard

Expand Down Expand Up @@ -566,15 +566,6 @@ __metadata:
languageName: node
linkType: hard

"@commitlint/types@npm:^18.6.1":
version: 18.6.1
resolution: "@commitlint/types@npm:18.6.1"
dependencies:
chalk: "npm:^4.1.0"
checksum: 10/fb37bdefd25e05e353eb568b26a7dd5aff488f1e3fbfc42080bde49ae6834ffde996acac4b7767df650b38e03692889b636b8290465823cd27276662d3b471cf
languageName: node
linkType: hard

"@commitlint/types@npm:^19.0.0":
version: 19.0.0
resolution: "@commitlint/types@npm:19.0.0"
Expand All @@ -584,6 +575,16 @@ __metadata:
languageName: node
linkType: hard

"@commitlint/types@npm:^19.0.3":
version: 19.0.3
resolution: "@commitlint/types@npm:19.0.3"
dependencies:
"@types/conventional-commits-parser": "npm:^5.0.0"
chalk: "npm:^5.3.0"
checksum: 10/44e67f4861f9b137f43a441f8ab255676b7a276c82ca46ba7846ca1057d170af92a87d3e2a1378713dc4e33a68c8af513683cb96dcd29544e48e2c825109ea6f
languageName: node
linkType: hard

"@cypress/code-coverage@npm:3.12.26":
version: 3.12.26
resolution: "@cypress/code-coverage@npm:3.12.26"
Expand Down Expand Up @@ -2472,6 +2473,15 @@ __metadata:
languageName: node
linkType: hard

"@types/conventional-commits-parser@npm:^5.0.0":
version: 5.0.0
resolution: "@types/conventional-commits-parser@npm:5.0.0"
dependencies:
"@types/node": "npm:*"
checksum: 10/0992617c7274e9ddcbdb30cc5b735fa067343c40e16f539615b3ad9213cacbe9a32483bc8e0302d297c6de9cc7fd3794549635761a66bd9dc220d609822d86e7
languageName: node
linkType: hard

"@types/debug@npm:^4.0.0":
version: 4.1.12
resolution: "@types/debug@npm:4.1.12"
Expand Down Expand Up @@ -6249,7 +6259,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "graasp-player@workspace:."
dependencies:
"@commitlint/config-conventional": "npm:18.6.2"
"@commitlint/config-conventional": "npm:19.0.3"
"@cypress/code-coverage": "npm:3.12.26"
"@emotion/cache": "npm:11.11.0"
"@emotion/react": "npm:11.11.3"
Expand Down

0 comments on commit b506f84

Please sign in to comment.