import { useQuery } from "@tanstack/react-query"; import type { Device, Service } from "@launchpad/shared"; export interface DeviceWithServices extends Device { services: Service[]; } async function fetchDevices(): Promise { const res = await fetch("/api/devices"); if (!res.ok) { throw new Error(`Geräte konnten nicht geladen werden (HTTP ${res.status})`); } return res.json(); } export function useDevices() { return useQuery({ queryKey: ["devices"], queryFn: fetchDevices, }); }