1import{r,j as e,L as C,S,t as f}from"./app-C6p48e8N.js";import{A as w,H as A}from"./app-layout-DcPDlNcC.js";import{B as D}from"./button-CAf71g0-.js";import{C as L,a as P,b as M,c as R}from"./card-GWr8t3Tu.js";import{I as k}from"./index-Ct-SOtzA.js";import{S as I,a as E,b as H,c as F,d as B,e as u}from"./select-CyuuO_XL.js";import{A as V,a as q,b as z,c as O,d as G,e as J,f as K,g as Q}from"./alert-dialog-Cx3u5SPq.js";import{T}from"./trash-2-Ztm8I3eX.js";/* empty css */import"./x-D3yH_Umz.js";import"./createLucideIcon-9vwK9uKM.js";import"./check-BoymFsoE.js";import"./log-out-DirxfntM.js";import"./app-logo-icon-EBXIhfPm.js";import"./chevron-down-CbO_87kv.js";const U=[{title:"Admin",href:"/admin"},{title:"Devices",href:"/admin/devices"}];function ce({devices:m}){const[x,g]=r.useState(""),[l,N]=r.useState(10),[y,o]=r.useState(1),[h,p]=r.useState(null),[t,c]=r.useState(null),b=s=>{c(s)},v=()=>{t&&(p(t.id),S.delete(route("admin.devices.destroy",t.id),{preserveScroll:!0,onSuccess:()=>{f.success("Device removed successfully."),c(null)},onError:()=>f.error("Failed to remove device."),onFinish:()=>p(null)}))},n=r.useMemo(()=>{const s=x.trim().toLowerCase();return s?m.filter(d=>d.name.toLowerCase().includes(s)||d.customer.toLowerCase().includes(s)||d.email.toLowerCase().includes(s)||d.platform.toLowerCase().includes(s)):m},[m,x]),i=Math.max(1,Math.ceil(n.length/l)),a=Math.min(y,i),j=n.slice((a-1)*l,a*l);return e.jsxs(w,{breadcrumbs:U,children:[e.jsx(C,{title:"Admin Devices",children:e.jsx("meta",{name:"robots",content:"noindex, nofollow"})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-6 p-4",children:[e.jsx(A,{title:"Devices",description:"Audit registered machines and identify slots that can be cleared."}),e.jsxs(L,{children:[e.jsx(P,{children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(M,{children:"Registered Devices"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(I,{className:"absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(k,{placeholder:"Search device, name or email...",value:x,onChange:s=>{g(s.target.value),o(1)},className:"w-72 pl-9"})]}),e.jsxs(E,{value:String(l),onValueChange:s=>{N(Number(s)),o(1)},children:[e.jsx(H,{className:"w-24",children:e.jsx(F,{})}),e.jsxs(B,{children:[e.jsx(u,{value:"10",children:"10"}),e.jsx(u,{value:"20",children:"20"}),e.jsx(u,{value:"50",children:"50"})]})]})]})]})}),e.jsxs(R,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"text-muted-foreground border-b",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-3 font-medium",children:"Device"}),e.jsx("th",{className:"py-3 font-medium",children:"Customer"}),e.jsx("th",{className:"py-3 font-medium",children:"Email"}),e.jsx("th",{className:"py-3 font-medium",children:"Platform"}),e.jsx("th",{className:"py-3 font-medium",children:"Last Seen"}),e.jsx("th",{className:"py-3 font-medium",children:"State"}),e.jsx("th",{className:"py-3 font-medium",children:"Action"})]})}),e.jsxs("tbody",{children:[j.map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-3",children:s.name}),e.jsx("td",{className:"py-3",children:s.customer}),e.jsx("td",{className:"py-3",children:s.email}),e.jsx("td",{className:"py-3",children:s.platform}),e.jsx("td",{className:"py-3",children:s.lastSeen}),e.jsx("td",{className:"py-3",children:s.state}),e.jsx("td",{className:"py-3",children:e.jsx(D,{type:"button",variant:"outline",size:"icon",onClick:()=>b(s),disabled:h===s.id,className:"h-8 w-8",title:"Remove device",children:e.jsx(T,{className:"h-4 w-4"})})})]},s.id)),j.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"py-6 text-center text-muted-foreground",children:"No devices found."})})]})]})}),i>1&&e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Showing ",n.length>0?(a-1)*l+1:0,"â",Math.min(a*l,n.length)," of ",n.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(s=>Math.max(1,s-1)),disabled:a===1,className:"rounded-md border px-3 py-1.5 text-xs font-medium disabled:opacity-40",children:"Previous"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Page ",a," of ",i]}),e.jsx("button",{type:"button",onClick:()=>o(s=>Math.min(i,s+1)),disabled:a===i,className:"rounded-md border px-3 py-1.5 text-xs font-medium disabled:opacity-40",children:"Next"})]})]})]})]}),e.jsx(V,{open:!!t,onOpenChange:s=>!s&&c(null),children:e.jsxs(q,{children:[e.jsxs(z,{children:[e.jsx(O,{children:"Remove Device"}),e.jsxs(G,{children:["Are you sure you want to remove ",e.jsx("strong",{children:t==null?void 0:t.name})," (",t==null?void 0:t.platform,")? This will free up one device slot for the customer."]})]}),e.jsxs(J,{children:[e.jsx(K,{onClick:()=>c(null),children:"Cancel"}),e.jsx(Q,{onClick:v,disabled:h===(t==null?void 0:t.id),children:h===(t==null?void 0:t.id)?"Removing...":"Remove"})]})]})})]})]})}export{ce as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.