You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

65 lines
2.4 KiB

'use client';
import { Button } from '@/components/ui/button';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table';
import { useSensorGroups } from '@/hooks/useSensorGroups';
import Link from 'next/link';
export default function SensorGroupPage() {
const { data, isLoading, isError, refetch } = useSensorGroups();
return (
<main className="mx-auto px-4 py-6">
<div className="mb-4 flex items-center justify-between">
<h1 className="text-xl font-semibold"> </h1>
<Button onClick={() => refetch()}></Button>
</div>
{isLoading && <p className="text-gray-500"> ...</p>}
{isError && <p className="text-red-600"> .</p>}
{!isLoading && !isError && (
<div className="overflow-x-auto rounded border">
<Table>
<TableHeader>
<TableRow>
<TableHead className="px-4 py-2 text-center">ID</TableHead>
<TableHead className="px-4 py-2 text-center"></TableHead>
<TableHead className="px-4 py-2 text-center"></TableHead>
<TableHead className="px-4 py-2 text-center"></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data && data.length > 0 ? (
data.map((g) => (
<TableRow key={g.id}>
<TableCell className="px-4 py-2 text-center">{g.id}</TableCell>
<TableCell className="px-4 py-2 text-center">{g.name}</TableCell>
<TableCell className="px-4 py-2 text-center">{g.description ?? '-'}</TableCell>
<TableCell className="flex items-center justify-center px-4 py-2">
<Button asChild variant="outline">
<Link href={`/sensor-groups/${g.id}`}></Link>
</Button>
</TableCell>
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={4} className="px-4 py-6 text-center text-gray-500">
.
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</div>
)}
</main>
);
}