From afd0b65f8c7cd8e155797b51729cbac6e4e51135 Mon Sep 17 00:00:00 2001 From: headlesdev Date: Sun, 18 May 2025 13:31:25 +0200 Subject: [PATCH] Site Page --- app/dashboard/sites/[siteId]/SitePage.tsx | 30 ++++++++++++++++ app/dashboard/sites/[siteId]/page.tsx | 43 +++++++++++++++++++++++ components/cards/Sites.tsx | 6 +++- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 app/dashboard/sites/[siteId]/SitePage.tsx create mode 100644 app/dashboard/sites/[siteId]/page.tsx diff --git a/app/dashboard/sites/[siteId]/SitePage.tsx b/app/dashboard/sites/[siteId]/SitePage.tsx new file mode 100644 index 0000000..e4cb477 --- /dev/null +++ b/app/dashboard/sites/[siteId]/SitePage.tsx @@ -0,0 +1,30 @@ +"use client" +import Sidebar from "@/components/Sidebar"; + +interface SitesPageProps { + username: string; + name: string; + siteId: string; +} + +export default function SitesPage({ username, name, siteId }: SitesPageProps) { + return ( + +
+
+
+

Site

+

+ 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/[siteId]/page.tsx b/app/dashboard/sites/[siteId]/page.tsx new file mode 100644 index 0000000..412ed29 --- /dev/null +++ b/app/dashboard/sites/[siteId]/page.tsx @@ -0,0 +1,43 @@ +"use client"; + +import SitePage from "./SitePage"; +import Loading from "@/components/Loading"; + +import { useState, useEffect } from "react"; +import { useRouter } from "next/navigation"; +import axios from "axios"; +import Cookies from "js-cookie"; +import { useParams } from "next/navigation"; + +export default function Dashboard() { + const router = useRouter(); + const [loading, setLoading] = useState(true); + const [username, setUsername] = useState(""); + const [name, setName] = useState("") + const { siteId } = useParams(); + + 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/cards/Sites.tsx b/components/cards/Sites.tsx index 2bce871..1233ff5 100644 --- a/components/cards/Sites.tsx +++ b/components/cards/Sites.tsx @@ -1,3 +1,6 @@ +"use client" +import { useRouter } from "next/navigation"; + interface SitesProps { id: string; name: string; @@ -6,6 +9,7 @@ interface SitesProps { } export default function Sites({ id, name, description, networks }: SitesProps) { + const router = useRouter(); return (
@@ -15,7 +19,7 @@ export default function Sites({ id, name, description, networks }: SitesProps) {

Networks: {networks.join(', ')}

)}
- +