Skip to content

Commit

Permalink
Merge pull request #91 from SELab-2/81-custom-404-and-403-pages
Browse files Browse the repository at this point in the history
81 custom 404 and 403 pages
  • Loading branch information
PJDeSmijter authored Apr 16, 2024
2 parents 2aa4bb7 + e743c0e commit 4f2868f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Analysing the code with flake8
working-directory: ./backend
run: |
flake8 pigeonhole/
flake8 .
ESLint:
runs-on: self-hosted
Expand Down
16 changes: 16 additions & 0 deletions frontend/app/[...not-found]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
27 changes: 27 additions & 0 deletions frontend/app/[...not-found]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import NavBar from "@app/[locale]/components/NavBar";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import initTranslations from "@app/i18n";
import TranslationsProvider from "@app/[locale]/components/TranslationsProvider";


async function Page_404({params: {locale}}: { params: { locale: any } }) {
const {t, resources} = await initTranslations(locale, ["common"])

return (
<TranslationsProvider
resources={resources}
locale={locale}
namespaces={["common"]}
>
<NavBar/>
<Box sx={{marginTop: '64px'}}>
<Typography variant="h3">
{t("page_not_found")}
</Typography>
</Box>
</TranslationsProvider>
);
}

export default Page_404;
26 changes: 26 additions & 0 deletions frontend/app/[locale]/403/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import NavBar from "@app/[locale]/components/NavBar";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import initTranslations from "@app/i18n";
import TranslationsProvider from "@app/[locale]/components/TranslationsProvider";

async function Page_403({params: {locale}}: { params: { locale: any } }) {
const {t, resources} = await initTranslations(locale, ["common"])

return (
<TranslationsProvider
resources={resources}
locale={locale}
namespaces={["common"]}
>
<NavBar/>
<Box sx={{marginTop: '64px'}}>
<Typography variant="h3">
{t("no_access_message")}
</Typography>
</Box>
</TranslationsProvider>
);
}

export default Page_403;
2 changes: 1 addition & 1 deletion frontend/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export async function getUserData() : Promise<UserData>{
return user;
}*/else{
let user : UserData = await getRequest('/users/current');
localStorage.setItem('user', JSON.stringify(user));
//localStorage.setItem('user', JSON.stringify(user));
console.log(user);
return user;
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"add_project": "Add project",
"details": "Details",
"no_courses": "No courses to display.",
"page_not_found": "Page not found",
"no_access_message": "You don't have access to this page",
"title": "Title",
"max_score": "Maximal score",
"title_required": "Title is required",
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"add_project": "Project toevoegen",
"details": "Details",
"no_courses": "Geen cursussen om weer te geven.",
"page_not_found": "Pagina niet gevonden",
"no_access_message": "Je hebt geen toegang tot deze pagina.",
"title": "Titel",
"max_score": "Maximale score",
"title_required": "Titel is verplicht",
Expand Down

0 comments on commit 4f2868f

Please sign in to comment.