From 34b37da865bd15cdfb0d7f0ed5f812c8f35ffae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 12 Jul 2026 02:16:42 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20wire=20lazy=20routes=20and?= =?UTF-8?q?=20mount=20the=20app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app.tsx declares the route table with per-page lazy imports so the first paint ships only the shell plus the page in view. Everything except /login sits behind the auth gate, unknown paths fall through to a 404 page, and index.tsx renders the app into #root. --- src/app.tsx | 56 ++++++++++++++++++++++++++++++++++++++++++ src/index.tsx | 6 +++++ src/pages/NotFound.tsx | 13 ++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/app.tsx create mode 100644 src/index.tsx create mode 100644 src/pages/NotFound.tsx 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 +
+
+ ); +}