diff --git a/src/app.tsx b/src/app.tsx new file mode 100644 index 0000000..ccacca2 --- /dev/null +++ b/src/app.tsx @@ -0,0 +1,56 @@ +// Route table. Pages are lazy so the first paint ships only the shell plus the +// page in view. Everything except /login sits behind the auth gate. + +import { Navigate, Route, Router } from "@solidjs/router"; +import { Show, lazy, type ParentProps } from "solid-js"; +import { Layout } from "./components/Layout"; +import { Loading } from "./components/Feedback"; +import { AuthProvider, useAuth } from "./lib/auth"; + +const Login = lazy(() => import("./pages/Login")); +const Home = lazy(() => import("./pages/Home")); +const Notes = lazy(() => import("./pages/Notes")); +const Events = lazy(() => import("./pages/Events")); +const EventDetail = lazy(() => import("./pages/EventDetail")); +const Courses = lazy(() => import("./pages/Courses")); +const CourseDetail = lazy(() => import("./pages/CourseDetail")); +const Exams = lazy(() => import("./pages/Exams")); +const ExamDetail = lazy(() => import("./pages/ExamDetail")); +const Marks = lazy(() => import("./pages/Marks")); +const Profile = lazy(() => import("./pages/Profile")); +const Users = lazy(() => import("./pages/Users")); +const NotFound = lazy(() => import("./pages/NotFound")); + +/** Renders children once the session is known; bounces to /login when absent. */ +function Protected(props: ParentProps) { + const { user } = useAuth(); + return ( + }> + }> + {props.children} + + + ); +} + +export function App() { + return ( + {props.children}}> + + + + + + + + + + + + + + + + + ); +} diff --git a/src/index.tsx b/src/index.tsx new file mode 100644 index 0000000..f15e53c --- /dev/null +++ b/src/index.tsx @@ -0,0 +1,6 @@ +/* @refresh reload */ +import { render } from "solid-js/web"; +import { App } from "./app"; +import "./styles.css"; + +render(() => , document.getElementById("root")!); diff --git a/src/pages/NotFound.tsx b/src/pages/NotFound.tsx new file mode 100644 index 0000000..84dc5e3 --- /dev/null +++ b/src/pages/NotFound.tsx @@ -0,0 +1,13 @@ +import { A } from "@solidjs/router"; + +export default function NotFound() { + return ( +
+
+

404

+

This page flew away.

+ Back home +
+
+ ); +}