Skip to content

Commit

Permalink
Une erreur apparaît quand on essaie d'accéder à une page qui nécessit…
Browse files Browse the repository at this point in the history
…e une authent si l'utilisateut n'est pas authentifié #46
  • Loading branch information
benjaminpochat committed Nov 11, 2024
1 parent b5b6d44 commit 7d9c4c1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<Void> processRegistration(Registration registration) {
<b>Description de la production :</b><br>
%s<br>
</div>
</html>
</html>
""",
registration.getProducer().getUser().getFirstName(),
registration.getProducer().getUser().getLastName(),
Expand Down
30 changes: 28 additions & 2 deletions frontend/app/src/layouts/ErrorLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import { Typography } from "@mui/material";
import { AppBar, Box, CssBaseline, Toolbar, Typography } from "@mui/material";
import React from "react";
import { useRouteError } from "react-router-dom";

export function ErrorLayout({message: message}) {
return <Typography>{message}</Typography>

return (
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBar
position="fixed"
sx={{
zIndex: (theme) => theme.zIndex.drawer + 1,
}}
>
<Toolbar>
<Typography variant="h5" component="div" sx={{ flexGrow: 1 }}>
Viande en direct
</Typography>
</Toolbar>
</AppBar>
<Box component="main" sx={{ flexGrow: 1, p: 3 }}>
<Toolbar />
<Typography variant="h3">Oups... y a un soucis :(</Typography>
<Typography variant="h5">{message}</Typography>
<Typography sx={{marginTop: '1rem', marginBottom: '1rem'}} variant="h5">N'hésitez pas à nous signaler le problème</Typography>
<Typography variant="h5"><a href='mailto:[email protected]'>Signaler le problème à [email protected]</a></Typography>
<Typography variant="h5"><a href='/..'>Revenir à la page d'accueil</a></Typography>
</Box>
</Box>
)
}
2 changes: 2 additions & 0 deletions frontend/app/src/layouts/customer/CustomerRouterFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CustomerCreationForm, { loadCustomerCreationFormData } from "../../domain
import NotAuthorizedForProducers, { loadNotAuthorizedForProducerData } from "../../authentication/views/NotAuthorizedForProducers.tsx";
import Welcome, { loadWelcomeData } from "../../domains/welcome/Welcome.tsx";
import PaymentLayout from "./PaymentLayout.tsx";
import { ErrorLayout } from "../ErrorLayout.tsx";

export class CustomerRouterFactory {
getRouter(keycloak) {
Expand All @@ -16,6 +17,7 @@ export class CustomerRouterFactory {
path: "/",
element: <CustomerLayout/>,
loader: async () => loadCustomerLayoutData(keycloak),
errorElement: <ErrorLayout message=''/>,
children: [
{
index: true,
Expand Down
7 changes: 4 additions & 3 deletions frontend/app/src/layouts/producer/ProducerRouterFactory.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { createBrowserRouter, Navigate } from "react-router-dom";
import { createBrowserRouter, Navigate, useRouteError } from "react-router-dom";

import AuthenticatedLayout, { loadAuthenticatedLayoutData } from "./AuthenticatedLayout.tsx";

Expand All @@ -18,6 +18,7 @@ import ProducerOrderForm, { loadProducerOrderFormData } from "../../domains/sale
import CustomersList, { loadCustomersListData } from "../../domains/customer/views/CustomersList.tsx";
import PublicationBeefProductionToSale, { loadPublicationBeefProductionToSaleData } from "../../domains/production/views/beefProduction/PublicationBeefProductionToSale.tsx";
import RegistrationForm from "./RegistrationForm.tsx";
import { ErrorLayout } from "../ErrorLayout.tsx";

export class ProducerRouterFactory {
getRouter(keycloak) {
Expand All @@ -26,6 +27,7 @@ export class ProducerRouterFactory {
path: "/",
element: <AuthenticatedLayout/>,
loader: async () => loadAuthenticatedLayoutData(keycloak),
errorElement: <ErrorLayout message=''/>,
children: [
{
index: true,
Expand Down Expand Up @@ -108,5 +110,4 @@ export class ProducerRouterFactory {
])

}

}
}

0 comments on commit 7d9c4c1

Please sign in to comment.