import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { Loader2, Tablet, Trash2 } from 'lucide-react'; import { useClient } from 'hooks/useClient'; import type { KioskDevice } from '../db/types'; /* Registered devices — yours, or everyone's if you are the owner. The server decides which; this panel does not ask, so a member cannot request somebody else's list by omitting a parameter. Enrolment itself is not here. Capturing a UDID needs a `.mobileconfig` served without a session and a callback the device posts to, and neither can exist until the platform can serve a plugin's route above the account gate. Until then this shows what the standalone service registered. */ const STATUS_TONE: Record = { registered: 'bg-success/10 text-success', captured: 'bg-info/10 text-info', pending: 'bg-muted text-muted-foreground', failed: 'bg-destructive/10 text-destructive', }; export const DevicesPanel = () => { const client = useClient(); const queryClient = useQueryClient(); const { data, isLoading } = useQuery({ queryKey: ['kiosk', 'devices'], queryFn: () => client.get<{ devices: KioskDevice[] }>('/kiosk/devices'), }); const remove = useMutation({ mutationFn: (id: number) => client.delete(`/kiosk/devices/${id}`), onSuccess: () => queryClient.invalidateQueries({ queryKey: ['kiosk', 'devices'] }), }); if (isLoading) { return (
); } const devices = data?.devices ?? []; return (
Devices
{!devices.length ? (
No devices registered. A device is registered by installing an enrolment profile, which is not wired up yet.
) : ( devices.map((device) => (
{device.label}
{device.status} {device.product ? {device.product} : null} {device.osVersion ? iOS {device.osVersion} : null} {/* The UDID is deliberately not shown in full: it identifies a person's hardware, and the whole reason artefacts stay private is that a `.ipa` leaks the full list of them. */} {device.udid ? …{device.udid.slice(-6)} : null} {device.failureReason ? ( {device.failureReason} ) : null}
)) )}
); };