mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Add Site modal & sites page
This commit is contained in:
35
app/dashboard/sites/SitesPage.tsx
Normal file
35
app/dashboard/sites/SitesPage.tsx
Normal file
@@ -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 (
|
||||
<Sidebar
|
||||
username={username}
|
||||
fullName={name}
|
||||
breadcrumbPath={['/', 'Dashboard', 'Ressources', 'Sites']}
|
||||
>
|
||||
<main>
|
||||
<div className="flex gap-4 items-center">
|
||||
<div className="flex-1">
|
||||
<h1 className="text-2xl font-bold">Sites</h1>
|
||||
<p className="text-sm opacity-70">Manage your sites. Sites are real-world locations where you can monitor your assets & add networks.</p>
|
||||
</div>
|
||||
<button className="btn btn-primary" onClick={() => document.getElementById('add_site')?.showModal()}>
|
||||
<Plus className="w-5 h-5" />
|
||||
Add Site
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<AddSite />
|
||||
</main>
|
||||
</Sidebar>
|
||||
)
|
||||
}
|
||||
41
app/dashboard/sites/page.tsx
Normal file
41
app/dashboard/sites/page.tsx
Normal file
@@ -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 <Loading />;
|
||||
} else {
|
||||
return <SitesPage username={username} name={name} />;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user