From 87617c1269367ece3544f43548316f8afea8f01b Mon Sep 17 00:00:00 2001 From: JohanGrims Date: Thu, 12 Dec 2024 21:07:33 +0100 Subject: [PATCH] New error-element implementation for admin -> login redirect --- src/admin/auth/Login.tsx | 6 +- src/main.jsx | 372 ++++++++++++++++++++------------------- 2 files changed, 190 insertions(+), 188 deletions(-) diff --git a/src/admin/auth/Login.tsx b/src/admin/auth/Login.tsx index e8b45b7..005891d 100644 --- a/src/admin/auth/Login.tsx +++ b/src/admin/auth/Login.tsx @@ -29,11 +29,7 @@ export default function Login() { signInWithEmailAndPassword(auth, email, password) .then((userCredential) => { const user = userCredential.user; - snackbar({ - message: `Willkommen, ${user.email}`, - closeable: true, - }); - setLoading(false); + window.location.reload(); }) .catch((error) => { console.error(error); diff --git a/src/main.jsx b/src/main.jsx index 01c5160..91d2331 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -118,124 +118,15 @@ const routes = [ }, children: [ { - path: "", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Overview" */ - "./admin/Overview" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "new", - lazy: async () => { - const module = await import( - /* webpackChunkName: "NewVote" */ - "./admin/NewVote" - ); - return { - Component: module.default, - }; - }, - }, - { - path: "students/:classId/:edit?", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Students" */ - "./admin/Students" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "settings", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Settings" */ - "./admin/Settings" - ); - return { - Component: module.default, - }; - }, - }, - { - path: "help", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Help" */ - "./admin/Help" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "help/edit", - lazy: async () => { - const loaderModule = await import( - /* webpackChunkName: "Help" */ - "./admin/Help" - ); - const componentModule = await import( - /* webpackChunkName: "CreateHelp" */ - "./admin/CreateHelp" - ); - return { - loader: loaderModule.default.loader, - Component: componentModule.default, - }; - }, - }, - { - path: "changelog", - lazy: async () => { - const module = await import( - /* webpackChunkName: "ReleaseNotes" */ - "./admin/ReleaseNotes" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "changelog/edit", - lazy: async () => { - const loaderModule = await import( - /* webpackChunkName: "ReleaseNotes" */ - "./admin/ReleaseNotes" - ); - const componentModule = await import( - /* webpackChunkName: "CreateReleaseNotes" */ - "./admin/CreateReleaseNotes" - ); - return { - loader: loaderModule.default.loader, - Component: componentModule.default, - }; - }, - }, - { - path: ":id/*", + path: "*", + errorElement: , children: [ { path: "", lazy: async () => { const module = await import( - /* webpackChunkName: "VoteAdmin" */ - "./admin/vote/index" + /* webpackChunkName: "Overview" */ + "./admin/Overview" ); return { loader: module.default.loader, @@ -244,24 +135,23 @@ const routes = [ }, }, { - path: "edit", + path: "new", lazy: async () => { const module = await import( - /* webpackChunkName: "EditVote" */ - "./admin/vote/Edit" + /* webpackChunkName: "NewVote" */ + "./admin/NewVote" ); return { - loader: module.default.loader, Component: module.default, }; }, }, { - path: "answers", + path: "students/:classId/:edit?", lazy: async () => { const module = await import( - /* webpackChunkName: "Answers" */ - "./admin/vote/Answers" + /* webpackChunkName: "Students" */ + "./admin/Students" ); return { loader: module.default.loader, @@ -270,11 +160,11 @@ const routes = [ }, }, { - path: "share", + path: "settings", lazy: async () => { const module = await import( - /* webpackChunkName: "Share" */ - "./admin/vote/Share" + /* webpackChunkName: "Settings" */ + "./admin/Settings" ); return { Component: module.default, @@ -282,32 +172,28 @@ const routes = [ }, }, { - path: "delete", + path: "help", lazy: async () => { - const loaderModule = await import( - /* webpackChunkName: "VoteAdmin" */ - "./admin/vote/index" - ); - const componentModule = await import( - /* webpackChunkName: "Delete" */ - "./admin/vote/Delete" + const module = await import( + /* webpackChunkName: "Help" */ + "./admin/Help" ); return { - loader: loaderModule.default.loader, - Component: componentModule.default, + loader: module.default.loader, + Component: module.default, }; }, }, { - path: "schedule", + path: "help/edit", lazy: async () => { const loaderModule = await import( - /* webpackChunkName: "VoteAdmin" */ - "./admin/vote/index" + /* webpackChunkName: "Help" */ + "./admin/Help" ); const componentModule = await import( - /* webpackChunkName: "Schedule" */ - "./admin/vote/Schedule" + /* webpackChunkName: "CreateHelp" */ + "./admin/CreateHelp" ); return { loader: loaderModule.default.loader, @@ -316,11 +202,11 @@ const routes = [ }, }, { - path: "match", + path: "changelog", lazy: async () => { const module = await import( - /* webpackChunkName: "Match" */ - "./admin/vote/Match" + /* webpackChunkName: "ReleaseNotes" */ + "./admin/ReleaseNotes" ); return { loader: module.default.loader, @@ -329,28 +215,15 @@ const routes = [ }, }, { - path: "assign", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Assign" */ - "./admin/vote/Assign" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "export", + path: "changelog/edit", lazy: async () => { const loaderModule = await import( - /* webpackChunkName: "VoteAdmin" */ - "./admin/vote/index" + /* webpackChunkName: "ReleaseNotes" */ + "./admin/ReleaseNotes" ); const componentModule = await import( - /* webpackChunkName: "Export" */ - "./admin/vote/Export" + /* webpackChunkName: "CreateReleaseNotes" */ + "./admin/CreateReleaseNotes" ); return { loader: loaderModule.default.loader, @@ -359,30 +232,163 @@ const routes = [ }, }, { - path: "results", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Results" */ - "./admin/vote/Results" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, - }, - { - path: "add", - lazy: async () => { - const module = await import( - /* webpackChunkName: "Add" */ - "./admin/vote/Add" - ); - return { - loader: module.default.loader, - Component: module.default, - }; - }, + path: ":id/*", + children: [ + { + path: "", + lazy: async () => { + const module = await import( + /* webpackChunkName: "VoteAdmin" */ + "./admin/vote/index" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "edit", + lazy: async () => { + const module = await import( + /* webpackChunkName: "EditVote" */ + "./admin/vote/Edit" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "answers", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Answers" */ + "./admin/vote/Answers" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "share", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Share" */ + "./admin/vote/Share" + ); + return { + Component: module.default, + }; + }, + }, + { + path: "delete", + lazy: async () => { + const loaderModule = await import( + /* webpackChunkName: "VoteAdmin" */ + "./admin/vote/index" + ); + const componentModule = await import( + /* webpackChunkName: "Delete" */ + "./admin/vote/Delete" + ); + return { + loader: loaderModule.default.loader, + Component: componentModule.default, + }; + }, + }, + { + path: "schedule", + lazy: async () => { + const loaderModule = await import( + /* webpackChunkName: "VoteAdmin" */ + "./admin/vote/index" + ); + const componentModule = await import( + /* webpackChunkName: "Schedule" */ + "./admin/vote/Schedule" + ); + return { + loader: loaderModule.default.loader, + Component: componentModule.default, + }; + }, + }, + { + path: "match", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Match" */ + "./admin/vote/Match" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "assign", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Assign" */ + "./admin/vote/Assign" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "export", + lazy: async () => { + const loaderModule = await import( + /* webpackChunkName: "VoteAdmin" */ + "./admin/vote/index" + ); + const componentModule = await import( + /* webpackChunkName: "Export" */ + "./admin/vote/Export" + ); + return { + loader: loaderModule.default.loader, + Component: componentModule.default, + }; + }, + }, + { + path: "results", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Results" */ + "./admin/vote/Results" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + { + path: "add", + lazy: async () => { + const module = await import( + /* webpackChunkName: "Add" */ + "./admin/vote/Add" + ); + return { + loader: module.default.loader, + Component: module.default, + }; + }, + }, + ], }, ], },