This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App.tsx' | ||
import {createBrowserRouter, RouterProvider,} from "react-router-dom"; | ||
import './index.css' | ||
import Root from './pages/root.tsx' | ||
import ErrorPage from './pages/error.tsx' | ||
import LoginScreen from "./pages/login/LoginScreen.tsx"; | ||
import HomeAdmin from "./pages/admin/HomeAdmin.tsx"; | ||
import HomeStudent from "./pages/student/HomeStudent.tsx"; | ||
import HomeTeacher from "./pages/teacher/HomeTeacher.tsx"; | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <Root/>, | ||
errorElement: <ErrorPage/> | ||
}, | ||
{ | ||
path: "/login", | ||
element: <LoginScreen/> | ||
}, | ||
{ | ||
path: "/admin", | ||
element: <HomeAdmin/> | ||
}, | ||
{ | ||
path: "/student", | ||
element: <HomeStudent/> | ||
}, | ||
{ | ||
path: "/teacher", | ||
element: <HomeTeacher/> | ||
} | ||
]); | ||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
<React.StrictMode> | ||
<App /> | ||
<RouterProvider router={router}/> | ||
</React.StrictMode>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useRouteError } from "react-router-dom"; | ||
import {JSX} from 'react'; | ||
|
||
export default function ErrorPage(): JSX.Element { | ||
const error = useRouteError(); | ||
console.error(error); | ||
|
||
return ( | ||
<div id="error-page"> | ||
<h1>Oops!</h1> | ||
<p>Sorry, an unexpected error has occurred.</p> | ||
<p> | ||
<i>{error.statusText || error.message}</i> | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {JSX} from "react"; | ||
import {Link} from "react-router-dom"; | ||
|
||
export default function Root(): JSX.Element { | ||
// TODO: logic to send user to /login or | ||
return ( | ||
<> | ||
<>Redirecting ...</> | ||
<Link to={`/login`}>goto login page</Link> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters