- Add hardware fingerprinting with cross-platform support - Implement secure device registration flow with X.509 certificates - Add WebSocket real-time communication for device status - Create comprehensive device management dashboard - Establish zero-trust security architecture with multi-layer protection - Add database migrations for device registration entities - Implement Rust edge client with hardware identification - Add certificate management and automated provisioning system 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import { useQuery } from "@tanstack/react-query"
|
|
import { devicesApi } from "@/services/devices"
|
|
import { DeviceDto } from "@/types/device"
|
|
import { useDeviceRegistration } from "@/contexts/device-registration-context"
|
|
|
|
// Legacy hook for backward compatibility - prefer useDeviceRegistration context
|
|
export function useDevices() {
|
|
return useQuery({
|
|
queryKey: ["devices"],
|
|
queryFn: () => devicesApi.getDevices(),
|
|
staleTime: 0, // Always consider data stale to enable frequent refetching
|
|
refetchInterval: 30 * 1000, // Refetch every 30 seconds
|
|
refetchIntervalInBackground: true, // Continue polling when tab is not in focus
|
|
})
|
|
}
|
|
|
|
// Legacy hook for backward compatibility - prefer useDeviceRegistration context
|
|
export function useDevicesList(): {
|
|
devices: DeviceDto[]
|
|
isLoading: boolean
|
|
isError: boolean
|
|
error: Error | null
|
|
refetch: () => void
|
|
} {
|
|
const {
|
|
data,
|
|
isLoading,
|
|
isError,
|
|
error,
|
|
refetch,
|
|
} = useDevices()
|
|
|
|
const devices = data?.devices ?? []
|
|
|
|
return {
|
|
devices,
|
|
isLoading,
|
|
isError,
|
|
error,
|
|
refetch,
|
|
}
|
|
}
|
|
|
|
// Enhanced hook that uses the device registration context
|
|
export function useDeviceManagement() {
|
|
const context = useDeviceRegistration()
|
|
|
|
return {
|
|
...context,
|
|
devices: context.state.registeredDevices,
|
|
isLoading: context.state.isLoading,
|
|
error: context.state.error,
|
|
currentSession: context.state.currentSession,
|
|
wsConnected: context.state.wsConnected,
|
|
}
|
|
} |