diff --git a/src/layout.tsx b/src/layout.tsx index 4d7633a..bbcdb39 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -1,9 +1,7 @@ import React from "react"; -import { useLocation } from "react-router-dom"; import Meta from "@/components/Meta"; import { Toaster } from "@/components/ui/toaster"; -import { ThemeProvider } from "@/components/theme-provider"; -import { Link, useNavigate } from "react-router-dom"; +import { Link, useNavigate, useLocation, Outlet } from "react-router-dom"; import { LucideHome, Settings, LayoutGrid, CircleDashed } from "lucide-react"; import { NavigationMenu, @@ -22,8 +20,6 @@ import { CommandList, } from "@/components/ui/command"; -import type { LayoutProps } from "@/types/layout"; - const links: { href: string; text: string; @@ -106,7 +102,7 @@ function Navbar() { ); } -const Layout = ({ children }: LayoutProps) => { +export default function Layout() { const location = useLocation(); const shouldDisplayNavbar = (!location.pathname.startsWith("/view/") && @@ -115,20 +111,16 @@ const Layout = ({ children }: LayoutProps) => { return (
- - {window.location.origin === "https://ephemeral.incognitotgt.me" && ( - - )} - {window.location.origin === "http://localhost:5173" && } -
- - {shouldDisplayNavbar && } - - {children} -
-
+ {window.location.origin === "https://ephemeral.incognitotgt.me" && ( + + )} + {window.location.origin === "http://localhost:5173" && } +
+ + {shouldDisplayNavbar && } + + +
); -}; - -export default Layout; +} diff --git a/src/main.tsx b/src/main.tsx index 5e462c0..b0d648b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,8 +1,10 @@ import React from "react"; import ReactDOM from "react-dom/client"; import { useEffect } from "react"; -import { BrowserRouter, Route, Routes } from "react-router-dom"; +import { createBrowserRouter, RouterProvider } from "react-router-dom"; import { Loader2 } from "lucide-react"; +import "@/index.css"; +import { ThemeProvider } from "@/components/theme-provider"; const Home = React.lazy(() => import("@/pages/Home")); const View = React.lazy(() => import("@/pages/View")); const Settings = React.lazy(() => import("@/pages/Settings")); @@ -13,7 +15,6 @@ const ServiceWorkerError = React.lazy( ); const PageNotFound = React.lazy(() => import("@/pages/PageNotFound")); import Layout from "@/layout"; -import "@/index.css"; import localforage from "localforage"; declare global { interface Window { @@ -22,7 +23,42 @@ declare global { }; } } - +const routes = createBrowserRouter([ + { + Component: Layout, + path: "/", + children: [ + { + Component: Home, + path: "/", + }, + { + Component: Settings, + path: "/settings", + }, + { + Component: Apps, + path: "/apps", + }, + { + Component: PageNotFound, + path: "*", + }, + { + Component: View, + path: "/view/:url", + }, + { + Component: StaticApp, + path: "/staticApp/:url", + }, + { + Component: ServiceWorkerError, + path: "/~/*", + }, + ], + }, +]); export default function App() { useEffect(() => { if ("serviceWorker" in navigator) { @@ -47,28 +83,18 @@ export default function App() { storeName: "__ephemeral_config", }); return ( - - - - - Ephemeral Is Loading... - - } - > - - - - - - - - - - - - + + + + Ephemeral Is Loading... + + } + > + + + ); } ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( diff --git a/src/pages/Apps.tsx b/src/pages/Apps.tsx index 4222e9d..37b7317 100644 --- a/src/pages/Apps.tsx +++ b/src/pages/Apps.tsx @@ -15,8 +15,8 @@ import { fetch } from "@/utils/fetch"; import type { Application } from "@/types/apps"; import { Loader2, X } from "lucide-react"; -const mapFunction = (app: Application) => ( -
+const mapFunction = (app: Application, key: number) => ( +
diff --git a/src/pages/PageNotFound.tsx b/src/pages/PageNotFound.tsx index a1252e8..924651b 100644 --- a/src/pages/PageNotFound.tsx +++ b/src/pages/PageNotFound.tsx @@ -1,24 +1,36 @@ import { Link } from "react-router-dom"; import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader } from "@/components/ui/card"; import Header from "@/components/Header"; export default function PageNotFound() { return ( <>
-
404
-
- Page Not Found -
- - + + + 404 + + +

+ The page you are looking for does not exist. +

+ +
+
);