2025-05-18 11:53:40 +02:00
|
|
|
"use client";
|
|
|
|
|
import Sidebar from "@/components/Sidebar";
|
|
|
|
|
import { Plus } from "lucide-react";
|
|
|
|
|
import AddSite from "@/components/dialogues/AddSite";
|
2025-05-18 12:06:21 +02:00
|
|
|
import Sites from "@/components/cards/Sites";
|
2025-05-18 12:17:18 +02:00
|
|
|
import axios from "axios";
|
|
|
|
|
import { useEffect, useState } from "react";
|
2025-05-18 11:53:40 +02:00
|
|
|
|
|
|
|
|
interface SitesPageProps {
|
|
|
|
|
username: string;
|
|
|
|
|
name: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function SitesPage({ username, name }: SitesPageProps) {
|
2025-05-18 12:17:18 +02:00
|
|
|
const [sites, setSites] = useState([]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
axios.get('/api/sites/get_all').then((response) => {
|
|
|
|
|
setSites(response.data.sites);
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-05-18 11:53:40 +02:00
|
|
|
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 />
|
2025-05-18 12:17:18 +02:00
|
|
|
<div className="flex flex-col gap-4 pt-4">
|
|
|
|
|
{sites.map((site: any) => (
|
|
|
|
|
<Sites key={site.id} id={site.id} name={site.name} description={site.description} networks={site.networks} />
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2025-05-18 11:53:40 +02:00
|
|
|
</main>
|
|
|
|
|
</Sidebar>
|
|
|
|
|
)
|
|
|
|
|
}
|