(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8558],{9766:(e,t,s)=>{Promise.resolve().then(s.bind(s,3021))},3021:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>l});var a=s(5155),r=s(2115);function l(){let[e,t]=(0,r.useState)([]),[s,l]=(0,r.useState)(!0),[d,i]=(0,r.useState)(null),c=async()=>{try{l(!0);let e=await fetch("/api/devices"),s=await e.json();if(s.error)throw Error(s.error);t(s.devices),i(null)}catch(e){i(e instanceof Error?e.message:"Failed to fetch devices")}finally{l(!1)}};return(0,r.useEffect)(()=>{c();let e=setInterval(c,5e3);return()=>clearInterval(e)},[]),(0,a.jsxs)("div",{className:"container mx-auto p-4",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold mb-2",children:"Connected Devices"}),(0,a.jsx)("button",{onClick:c,className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded",children:"Refresh Devices"})]}),s&&(0,a.jsx)("div",{className:"text-gray-600",children:"Loading devices..."}),d&&(0,a.jsx)("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:d}),!s&&!d&&0===e.length&&(0,a.jsx)("div",{className:"text-gray-600",children:"No devices connected"}),e.length>0&&(0,a.jsx)("div",{className:"bg-white shadow rounded-lg overflow-hidden",children:(0,a.jsxs)("table",{className:"min-w-full",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Device ID"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-gray-200",children:e.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:e.id}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:(0,a.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ".concat("device"===e.status?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"),children:e.status})})]},e.id))})]})})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[8441,1517,7358],()=>t(9766)),_N_E=e.O()}]);