1import{aD as m,be as u,aE as x,am as p,r as g,J as h,j as e,E as f,aV as b}from"./index-CQVfxCQm.js";const j=m({method:"GET"}).middleware([u]).handler(x("eeaf3448cf14ad1326812b9140c9122ba869654a6ef0d1d43a235c477686de9e"));function o(s){return new Date(s).toLocaleTimeString("it-IT",{timeZone:"Europe/Rome",hour:"2-digit",minute:"2-digit"})}function v(s){const[i,n,t]=s.split("-").map(Number);return new Date(Date.UTC(i,n-1,t)).toLocaleDateString("it-IT",{timeZone:"Europe/Rome",weekday:"long",day:"2-digit",month:"long",year:"numeric"})}function N(s){switch(s){case 1:case 4:return"App";case 7:case 8:return"Card";case 9:case 12:case 46:case 55:return"Remoto";case 32:case 33:case 36:case 37:case 44:case 47:case 48:return"Codice";case 57:return"Impronta";default:return s!=null?`#${s}`:"â"}}function w(){const s=p(j),[i,n]=g.useState(30),{data:t,isLoading:d,isError:l,error:c}=h({queryKey:["lavanderia-access-history",i],queryFn:()=>s({data:{days:i}})});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold text-foreground",children:[e.jsx(f,{className:"h-5 w-5"})," Accessi Lavanderia"]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Storico degli sblocchi della serratura della lavanderia."})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Periodo:"}),e.jsxs("select",{value:i,onChange:r=>n(Number(r.target.value)),className:"rounded-md border border-border bg-background px-2 py-1 text-sm",children:[e.jsx("option",{value:7,children:"Ultimi 7 giorni"}),e.jsx("option",{value:14,children:"Ultimi 14 giorni"}),e.jsx("option",{value:30,children:"Ultimi 30 giorni"}),e.jsx("option",{value:60,children:"Ultimi 60 giorni"}),e.jsx("option",{value:90,children:"Ultimi 90 giorni"}),e.jsx("option",{value:180,children:"Ultimi 180 giorni"}),e.jsx("option",{value:365,children:"Ultimo anno"})]})]})]}),d?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{className:"h-4 w-4 animate-spin"})," Caricamentoâ¦"]}):l?e.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive",children:["Errore: ",c instanceof Error?c.message:"sconosciuto"]}):!t||t.days.length===0?e.jsx("div",{className:"rounded-lg border border-border bg-card p-6 text-sm text-muted-foreground",children:"Nessun accesso registrato nel periodo selezionato. Gli accessi verranno raccolti automaticamente dal prossimo ciclo di sync TTLock (ogni 5 minuti)."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 text-sm",children:[e.jsx("span",{className:"font-semibold text-foreground",children:t.totalAccesses})," accessi totali in"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.days.length})," giorni con sblocchi."]}),e.jsx("div",{className:"space-y-4",children:t.days.map(r=>e.jsxs("div",{className:"rounded-xl border border-border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3",children:[e.jsx("div",{className:"text-sm font-semibold capitalize text-foreground",children:v(r.date)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.accesses.length," accessi · primo ",o(r.firstUnlockAt)," · ultimo"," ",o(r.lastUnlockAt)]})]}),e.jsx("ul",{className:"divide-y divide-border",children:r.accesses.map(a=>e.jsxs("li",{className:"flex items-center justify-between gap-2 px-4 py-2 text-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-foreground",children:a.username??"Utente sconosciuto"}),a.keyboardPwd&&e.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["cod. ",a.keyboardPwd]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-xs",children:[e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:N(a.recordType)}),e.jsx("span",{className:"font-mono font-medium text-foreground",children:o(a.unlockTime)})]})]},a.id))})]},r.date))})]})]})}export{w as component};
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.