From 955f9f2861c1bf6656cac88c44c4b8c6bd1bd5c8 Mon Sep 17 00:00:00 2001 From: headlesdev Date: Sat, 17 May 2025 20:17:39 +0200 Subject: [PATCH] Settings Page --- app/dashboard/DashboardPage.tsx | 4 +-- app/dashboard/settings/SettingsPage.tsx | 31 +++++++++++++++++++ app/dashboard/settings/page.tsx | 41 +++++++++++++++++++++++++ components/Breadcrumbs.tsx | 3 +- components/Sidebar.tsx | 4 ++- 5 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 app/dashboard/settings/SettingsPage.tsx create mode 100644 app/dashboard/settings/page.tsx diff --git a/app/dashboard/DashboardPage.tsx b/app/dashboard/DashboardPage.tsx index b39a130..b1f1cfe 100644 --- a/app/dashboard/DashboardPage.tsx +++ b/app/dashboard/DashboardPage.tsx @@ -13,9 +13,9 @@ export default function DashboardPage({ username, name }: DashboardPageProps) { -
+

Dashboard

diff --git a/app/dashboard/settings/SettingsPage.tsx b/app/dashboard/settings/SettingsPage.tsx new file mode 100644 index 0000000..b16fe65 --- /dev/null +++ b/app/dashboard/settings/SettingsPage.tsx @@ -0,0 +1,31 @@ +"use client"; + +import Sidebar from "@/components/Sidebar"; + +interface DashboardPageProps { + username: string; + name: string; +} + +export default function DashboardPage({ username, name }: DashboardPageProps) { + return ( +
+ +
+

Settings

+

Manage your instance settings

+ +
+ +
User Settings
+
+ +
+
+
+ ); +} \ No newline at end of file diff --git a/app/dashboard/settings/page.tsx b/app/dashboard/settings/page.tsx new file mode 100644 index 0000000..446fb7e --- /dev/null +++ b/app/dashboard/settings/page.tsx @@ -0,0 +1,41 @@ +"use client"; + +import SettingsPage from "./SettingsPage"; +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/Breadcrumbs.tsx b/components/Breadcrumbs.tsx index 33c8a74..9ed88eb 100644 --- a/components/Breadcrumbs.tsx +++ b/components/Breadcrumbs.tsx @@ -6,7 +6,7 @@ interface BreadcrumbsProps { export default function Breadcrumbs({ breadcrumbPath = ['Home'] }: BreadcrumbsProps) { return(
-
+
    {breadcrumbPath.map((item, index) => (
  • @@ -18,7 +18,6 @@ export default function Breadcrumbs({ breadcrumbPath = ['Home'] }: BreadcrumbsPr
  • ))}
-
) diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index a6354c1..6efdf71 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -180,7 +180,9 @@ export default function Sidebar({ children, username, fullName, breadcrumbPath } {/* Main content */}
- {children} +
+ {children} +
)