From ad24a6e8e2fc314834c3f8f4445d3553636ccd79 Mon Sep 17 00:00:00 2001 From: headlesdev Date: Sun, 18 May 2025 11:53:40 +0200 Subject: [PATCH] Add Site modal & sites page --- app/dashboard/sites/SitesPage.tsx | 35 ++++++++++++++++++++++ app/dashboard/sites/page.tsx | 41 ++++++++++++++++++++++++++ components/dialogues/AddSite.tsx | 48 +++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 app/dashboard/sites/SitesPage.tsx create mode 100644 app/dashboard/sites/page.tsx create mode 100644 components/dialogues/AddSite.tsx diff --git a/app/dashboard/sites/SitesPage.tsx b/app/dashboard/sites/SitesPage.tsx new file mode 100644 index 0000000..c199c33 --- /dev/null +++ b/app/dashboard/sites/SitesPage.tsx @@ -0,0 +1,35 @@ +"use client"; +import Sidebar from "@/components/Sidebar"; +import { Plus } from "lucide-react"; +import AddSite from "@/components/dialogues/AddSite"; + +interface SitesPageProps { + username: string; + name: string; +} + + +export default function SitesPage({ username, name }: SitesPageProps) { + return ( + +
+
+
+

Sites

+

Manage your sites. Sites are real-world locations where you can monitor your assets & add networks.

+
+ +
+ + +
+
+ ) +} \ No newline at end of file diff --git a/app/dashboard/sites/page.tsx b/app/dashboard/sites/page.tsx new file mode 100644 index 0000000..b43cd8b --- /dev/null +++ b/app/dashboard/sites/page.tsx @@ -0,0 +1,41 @@ +"use client"; + +import SitesPage from "./SitesPage"; +import Loading from "@/components/Loading"; + +import { useState, useEffect } from "react"; +import { useRouter } from "next/navigation"; +import axios from "axios"; +import Cookies from "js-cookie"; + +export default function Dashboard() { + const router = useRouter(); + const [loading, setLoading] = useState(true); + const [username, setUsername] = useState(""); + const [name, setName] = useState(""); + + useEffect(() => { + const init = async () => { + const token = Cookies.get("token"); + if (!token) { + router.push("/"); + } + const response = await axios.post("/api/user/validate", { token }); + if (response.data.message !== "Valid") { + Cookies.remove("token"); + router.push("/"); + } else { + setUsername(response.data.username); + setName(response.data.name); + setLoading(false); + } + }; + init(); + }, []); + + if (loading) { + return ; + } else { + return ; + } +} \ No newline at end of file diff --git a/components/dialogues/AddSite.tsx b/components/dialogues/AddSite.tsx new file mode 100644 index 0000000..9aa4eaa --- /dev/null +++ b/components/dialogues/AddSite.tsx @@ -0,0 +1,48 @@ +export default function AddSite() { + return ( + +
+
+
+

Add New Site

+

Provide details for the new site location

+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+ + +
+
+
+
+
+ ) +} \ No newline at end of file