import { useState } from "react"; import ActivityIndicator from "@/components/ui/activity-indicator"; import { Switch } from "@/components/ui/switch"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { useDetectState } from "@/api/ws"; import useSWR from "swr"; import { FrigateConfig } from "@/types/frigateConfig"; import Heading from "@/components/ui/heading"; export function Dashboard() { const { data: config } = useSWR("config"); const [selectedCamera, setSelectedCamera] = useState( undefined ); let cameras; if (config?.cameras) { cameras = Object.keys(config.cameras).map((name) => (
setSelectedCamera(name)}> {name}
)); } return ( <> {!config && } Components testing
{selectedCamera && } ); } function Camera({ cameraName }: { cameraName: string }) { const { payload: detectValue, send: sendDetect } = useDetectState(cameraName); return ( <> {cameraName}
sendDetect(detectValue === "ON" ? "OFF" : "ON", true) } />
); } export default Dashboard;