import { useMemo } from "react"; import { Link, useParams } from "react-router-dom"; import { Card, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { useGroups } from "@/context/GroupsContext"; import { useCompartmentsByGroup } from "@/hooks/useCompartmentsByGroup"; export function GroupPage() { const { groupId: groupIdParam } = useParams(); const { groups } = useGroups(); const groupId = useMemo(() => { if (!groupIdParam) return ""; return decodeURIComponent(groupIdParam); }, [groupIdParam]); const groupTitle = useMemo(() => { if (!groupId) return "Group"; const match = groups.find((g) => g.groupId === groupId); return match?.displayName ?? groupId; }, [groupId, groups]); const { compartments, status, error } = useCompartmentsByGroup(groupId); return (

{groupTitle}

Compartments

{status === "loading" ? (

Loading compartments…

) : null} {status === "error" ? (

{error}

) : null}
{compartments.map((c) => ( {c.displayName} {c.id} ))}
{status !== "loading" && groupId && compartments.length === 0 ? (

No compartments found.

) : null}
); }