Display Networks on Sites

This commit is contained in:
headlesdev 2025-05-18 15:44:55 +02:00
parent fd4b8feaaf
commit c01458e394
3 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,9 @@ export async function GET(request: NextRequest) {
mode: "insensitive", mode: "insensitive",
}, },
}, },
include: {
networks: true,
},
}); });
const total = await prisma.site.count({ const total = await prisma.site.count({
where: { where: {

View File

@ -24,6 +24,7 @@ export default function SitesPage({ username, name }: SitesPageProps) {
setItemPerPage, setItemPerPage,
loadSites loadSites
} = useSites(); } = useSites();
console.log(sites);
return ( return (
<Sidebar <Sidebar

View File

@ -5,7 +5,15 @@ interface SitesProps {
id: string; id: string;
name: string; name: string;
description: string; description: string;
networks: string[]; networks: Network[];
}
interface Network {
id: number;
name: string;
ipv4Subnet?: string;
ipv6Subnet?: string;
gateway?: string;
} }
export default function Sites({ id, name, description, networks }: SitesProps) { export default function Sites({ id, name, description, networks }: SitesProps) {
@ -16,7 +24,7 @@ export default function Sites({ id, name, description, networks }: SitesProps) {
<h2 className="card-title">{name}</h2> <h2 className="card-title">{name}</h2>
<p>{description}</p> <p>{description}</p>
{ networks && networks.length > 0 && ( { networks && networks.length > 0 && (
<p>Networks: {networks.join(', ')}</p> <p>Networks: {networks.map((network) => network.name).join(", ")}</p>
)} )}
<div className="card-actions justify-end"> <div className="card-actions justify-end">
<button className="btn btn-secondary btn-sm btn-outline" onClick={() => router.push(`/dashboard/sites/${id}`)}>View</button> <button className="btn btn-secondary btn-sm btn-outline" onClick={() => router.push(`/dashboard/sites/${id}`)}>View</button>