Skip to content

Commit

Permalink
Add not found error for nonexisting questions
Browse files Browse the repository at this point in the history
  • Loading branch information
ucanyiit committed Feb 9, 2023
1 parent 439174b commit 6792e00
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
28 changes: 22 additions & 6 deletions fe/src/components/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,31 @@ const getAutocompleteName = (option: any, lang: string) =>
export default function Question({ paths }: { paths: string[] }) {
const location = useLocation();
const navigate = useNavigate();
const { i18n } = useTranslation();
const { i18n, t } = useTranslation();

const { data: selectedNode, isLoading } = useQuestionData(paths);

if (isLoading || !selectedNode) {
if (isLoading) {
return <></>;
}

if (!selectedNode) {
return <Box>
<Box
sx={{
textAlign: 'center',
display: 'flex',
flexFlow: 'column nowrap',
justifyContent: 'center',
}}
>
<Typography variant='h4'>
{t('notFound')}
</Typography>
</Box>
</Box>;
}

if (selectedNode.type !== TreeNodeType.NODE_TYPE_QUESTION) {
return <Data dataNode={selectedNode as any} />;
}
Expand Down Expand Up @@ -119,12 +136,11 @@ export default function Question({ paths }: { paths: string[] }) {
</Button>
))
)}
{selectedNode.externalData &&
selectedNode.externalData.usefulLinks?.length > 0 && (
{selectedNode.externalData?.usefulLinks?.length > 0 && (
<Box width='100%' mt={8}>
<Typography variant='h4'>
{selectedNode.externalData?.[`text_${i18n.language}`] ||
selectedNode.externalData?.text}
{selectedNode.externalData[`text_${i18n.language}`] ||
selectedNode.externalData.text}
</Typography>
<UsefulLinksData value={selectedNode.externalData} noTitle />
</Box>
Expand Down
1 change: 1 addition & 0 deletions fe/src/utils/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"data.vpn.subtitle": "تتيح لك الشّبكة الافْتراضيّة الخَاصَّة الوصول إلى المواقع الإلكترونية المحجوبة",
"data.container_pharmacy": "",

"notFound": "لم يتم العثور على الصفحة",
"button.back": "السابق",
"button.language": "تغيير",
"button.google_maps": "رابط خرائط جوجل",
Expand Down
1 change: 1 addition & 0 deletions fe/src/utils/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"data.vpn.subtitle": "VPN allows you to access blocked sites.",
"data.container_pharmacy": "Container Pharmacy",

"notFound": "Page not found",
"button.back": "Back",
"button.language": "Change Language",
"button.google_maps": "Google Maps Link",
Expand Down
1 change: 1 addition & 0 deletions fe/src/utils/locales/ku/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"data.vpn.subtitle": " VPN dihêle hûn bigihîjin malperên astengkirî.",
"data.container_pharmacy": "",

"notFound": "Rûpel nehat dîtin",
"button.back": "paş",
"button.language": "Ziman biguherîne",
"button.google_maps": "Girêdana Google Mapsê ",
Expand Down
1 change: 1 addition & 0 deletions fe/src/utils/locales/tr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"data.vpn.title": "İnternete bağlanmak için aşağıdaki ücretsiz VPN'leri kullanabilirsiniz.",
"data.vpn.subtitle": "VPN bloklanan sitelere girmenizi sağlar.",

"notFound": "Sayfa bulunamadı",
"button.back": "Geri",
"button.language": "Dili Değiştir",
"button.google_maps": "Google Maps Linki",
Expand Down

0 comments on commit 6792e00

Please sign in to comment.