Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/swiper-11.1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelPelletierEvraire authored Dec 14, 2024
2 parents 6795c1c + 591c78b commit c0a23a7
Show file tree
Hide file tree
Showing 17 changed files with 1,135 additions and 25 deletions.
Empty file added Dockefile
Empty file.
42 changes: 24 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@mui/material": "^6.1.8",
"@mui/material-nextjs": "^6.1.4",
"axios": "^1.7.9",
"dotenv": "^16.4.5",
"i18next": "^23.16.5",
"dotenv": "^16.4.7",
"i18next": "^24.0.5",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-chained-backend": "^4.6.2",
"i18next-http-backend": "^2.6.2",
Expand All @@ -54,7 +54,7 @@
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"eslint-config-next": "15.0.4",
"jest": "^29.7.0",
"postcss": "^8",
"prettier": "^3.3.3",
Expand Down
30 changes: 30 additions & 0 deletions public/locales/en/authentication.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"login": {
"username": "Username",
"password": "Password",
"title": "Login",
"switchText": "Don't have an account? ",
"switchLink": "Sign up"
},
"signup": {
"username": "Username",
"password": "Password",
"confirmPassword": "Confirm Password",
"title": "Sign up",
"switchText": "Already have an account? ",
"switchLink": "Login",
"dataPolicy": "By checking this box I understand that the data I have entered will be stored and thus should not be sensitive information.",
"dataReminder": "As a reminder, work email, phone number or real name are considered sensitive information."
},
"errors": {
"username": "Username is required",
"password": "Password is required",
"confirmPassword": "Confirm Password is required",
"passwordMatch": "Passwords do not match",
"usernameTaken": "Username is already taken",
"notFound": "Could not find resource, backend is probably down",
"unknown": "An unknown error occurred",
"server": "Server error",
"unauthorized": "Invalid username or password"
}
}
30 changes: 30 additions & 0 deletions public/locales/fr/authentication.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Login": {
"username": "Nom d'utilisateur",
"password": "Mot de passe",
"title": "Connexion",
"switchText": "Vous n'avez pas de compte? ",
"switchLink": "Inscrivez-vous"
},
"Signup": {
"username": "Nom d'utilisateur",
"password": "Mot de passe",
"confirmPassword": "Confirmez le mot de passe",
"title": "Inscrivez-vous",
"switchText": "Vous avez déjà un compte? ",
"switchLink": "Connexion",
"dataPolicy": "En cochant cette case, je comprends que les données que j'ai saisies seront stockées et ne doivent donc pas être des informations sensibles.",
"dataReminder": "Pour rappel, l'adresse e-mail professionnelle, le numéro de téléphone ou le nom réel sont considérés comme des informations sensibles."
},
"Errors": {
"username": "Le nom d'utilisateur est requis",
"password": "Le mot de passe est requis",
"confirmPassword": "La confirmation du mot de passe est requise",
"passwordMatch": "Les mots de passe ne correspondent pas",
"usernameTaken": "Le nom d'utilisateur est déjà pris",
"notFound": "Impossible de trouver la ressource, le backend est probablement en panne",
"unknown": "Une erreur inconnue s'est produite",
"server": "Erreur du serveur",
"unauthorized": "Nom d'utilisateur ou mot de passe invalide"
}
}
29 changes: 29 additions & 0 deletions src/app/api/login/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { usersApi } from "@/utils/server/backend";

export async function POST(request: Request) {

const authHeader = request.headers.get("Authorization");
if (!authHeader) {
return new Response(
JSON.stringify({ error: "Missing Authorization header" }),
{
status: 401,
},
);
}

return usersApi.loginLoginPost({headers: { Authorization: authHeader }}).then((response) => {
return Response.json(response.data);
}).catch((error) => {
if (error.response) {
console.error("Error response:", error.response.data);
} else if (error.request) {
console.error("Error request:", error.request);
} else {
console.error("Error message:", error.message);
}
return new Response(JSON.stringify({ error: error.message }), {
status: error.status,
});
});
}
29 changes: 29 additions & 0 deletions src/app/api/signup/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { usersApi } from "@/utils/server/backend";

export async function POST(request: Request) {

const authHeader = request.headers.get("Authorization");
if (!authHeader) {
return new Response(
JSON.stringify({ error: "Missing Authorization header" }),
{
status: 401,
},
);
}

return usersApi.signupSignupPost({headers: { Authorization: authHeader }}).then((response) => {
return Response.json(response.data);
}).catch((error) => {
if (error.response) {
console.error("Error response:", error.response.data);
} else if (error.request) {
console.error("Error request:", error.request);
} else {
console.error("Error message:", error.message);
}
return new Response(JSON.stringify({ error: error.message }), {
status: error.status,
});
});
}
9 changes: 6 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
import "./globals.css";
import "./i18n";
import theme from "./theme";
import RouteGuard from "@/components/AuthComponents/RouteGuard";

export default function RootLayout({
children,
Expand Down Expand Up @@ -39,9 +40,11 @@ export default function RootLayout({
<body>
<AppRouterCacheProvider>
<ThemeProvider theme={theme}>
<SideNav open={sideNavOpen} onClose={handleDrawerClose} />
<Header setSideNavOpen={setSideNavOpen} />
<Box className="mt-16">{children}</Box>
<RouteGuard>
<SideNav open={sideNavOpen} onClose={handleDrawerClose} />
<Header setSideNavOpen={setSideNavOpen} />
<Box className="mt-16">{children}</Box>
</RouteGuard>
</ThemeProvider>
</AppRouterCacheProvider>
</body>
Expand Down
Loading

0 comments on commit c0a23a7

Please sign in to comment.