1import{u as M,a as i,d as _,e as T,j as e}from"./vendor-query-B-_nDQQY.js";import{n as U,aq as C,J as c,U as L,s as Q,af as A,t as E,b as u}from"./index-D8ww6b7J.js";import{D as B,K as z}from"./KioskStatusBoard-CJfAv8ix.js";import{C as J}from"./circle-check-big-4Ew-rpqG.js";import{U as R}from"./user-CHo1Apvy.js";import{f}from"./format-C2V2JF1Z.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-react-BUIlT3ms.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";import"./constants-yGZMfuMC.js";function W(d){const n=new Date(d),o=n.getDay(),r=n.getDate()-o+(o===0?-6:1);return n.setDate(r),n.toISOString().split("T")[0]}function oe(){const d=M(),[n,o]=i.useState(""),[r,m]=i.useState(null),[y,S]=i.useState(new Date),[a,j]=i.useState(null);i.useEffect(()=>{const t=setInterval(()=>S(new Date),1e3);return()=>clearInterval(t)},[]);const{data:p=[]}=_({queryKey:["employees"],queryFn:()=>u.entities.Employee.filter({kiosk_enabled:!0})}),h=W(new Date),{data:I=[],refetch:D}=_({queryKey:["kiosk-entries",h],queryFn:()=>u.entities.TimeEntry.filter({week_start:h}),refetchInterval:15e3}),x=t=>I.find(s=>s.employee_id===t&&!s.clock_out_time),F=()=>{const t=p.find(s=>s.kiosk_pin===n);if(!t){E.error("Invalid PIN"),o("");return}m(t),o("")},g=T({mutationFn:async({emp:t,action:s})=>{if(s==="in"){const l=await u.entities.TimeEntry.create({employee_id:t.id,employee_name:t.name,entry_type:"on_site",clock_in_time:new Date().toISOString(),week_start:h,job_label:"Shop"});return{action:s,entry:l}}else{const l=x(t.id);if(!l)throw new Error("No active clock-in found");const v=new Date,w=(v-new Date(l.clock_in_time))/36e5,O=t.cost_per_hour||0,b=w*O,k=b*((t.tax_rate_pct||15)/100),P=await u.entities.TimeEntry.update(l.id,{clock_out_time:v.toISOString(),total_hours:parseFloat(w.toFixed(2)),gross_pay:parseFloat(b.toFixed(2)),tax_amount:parseFloat(k.toFixed(2)),net_pay:parseFloat((b-k).toFixed(2))});return{action:s,entry:P}}},onSuccess:t=>{j({type:t.action==="in"?"in":"out",name:r.name,time:f(new Date,"h:mm:ss a")}),m(null),D(),d.invalidateQueries({queryKey:["kiosk-entries"]}),d.invalidateQueries({queryKey:["time-entries"]}),setTimeout(()=>j(null),5e3)},onError:t=>{E.error(t.message),m(null)}}),N=t=>{if(n.length<4){const s=n+t;o(s),s.length===4&&setTimeout(F,200)}},K=()=>o(n.slice(0,-1)),q=p.filter(t=>x(t.id));return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary flex items-center justify-center",children:e.jsx(U,{className:"w-6 h-6 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold",children:"Shop Time Clock"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Punch In / Out Kiosk"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold font-mono tabular-nums",children:f(y,"h:mm:ss a")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f(y,"EEEE, MMMM d, yyyy")})]})]}),a&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:c("bg-card rounded-2xl p-10 text-center border-2 max-w-md",a.type==="in"?"border-green-500":"border-blue-500"),children:[a.type==="in"?e.jsx(J,{className:"w-20 h-20 text-green-500 mx-auto mb-4"}):e.jsx(C,{className:"w-20 h-20 text-blue-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold mb-1",children:a.type==="in"?"Clocked In!":"Clocked Out!"}),e.jsx("p",{className:"text-lg text-muted-foreground mb-1",children:a.name}),e.jsx("p",{className:"text-3xl font-mono font-bold",children:a.time})]})}),e.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 p-6 overflow-auto",children:[e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center max-w-md mx-auto w-full",children:r?e.jsx("div",{className:"text-center w-full",children:(()=>{const t=x(r.id),s=!!t;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-28 h-28 rounded-full mx-auto mb-4 overflow-hidden border-4 border-primary",children:r.profile_photo_url||r.selfie_url?e.jsx("img",{src:r.profile_photo_url||r.selfie_url,alt:r.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full bg-slate-700 flex items-center justify-center",children:e.jsx(R,{className:"w-12 h-12 text-slate-400"})})}),e.jsx("h2",{className:"text-3xl font-bold mb-1",children:r.name}),e.jsx("p",{className:"text-slate-400 mb-2",children:r.role||"Employee"}),e.jsxs("div",{className:c("inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-semibold mb-8",s?"bg-green-900/40 text-green-400":"bg-slate-700 text-slate-400"),children:[e.jsx("div",{className:c("w-2 h-2 rounded-full",s?"bg-green-500 animate-pulse":"bg-muted-foreground")}),s?`Clocked in since ${f(new Date(t.clock_in_time),"h:mm a")}`:"Clocked out"]}),e.jsx("div",{className:"flex gap-3 justify-center",children:e.jsxs("button",{onClick:()=>g.mutate({emp:r,action:s?"out":"in"}),disabled:g.isPending,className:c("px-10 py-6 rounded-2xl text-xl font-bold transition-all flex flex-col items-center gap-2 min-w-[180px]",s?"bg-blue-600 hover:bg-blue-500 text-white":"bg-green-600 hover:bg-green-500 text-white",g.isPending&&"opacity-50"),children:[s?e.jsx(C,{className:"w-8 h-8"}):e.jsx(A,{className:"w-8 h-8"}),s?"CLOCK OUT":"CLOCK IN"]})}),e.jsx("button",{onClick:()=>m(null),className:"mt-6 text-sm text-muted-foreground hover:text-foreground",children:"Cancel"})]})})()}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx(L,{className:"w-12 h-12 text-primary mx-auto mb-2"}),e.jsx("h2",{className:"text-2xl font-bold",children:"Enter Your PIN"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Type your 4-digit code to punch in or out"})]}),e.jsx("div",{className:"flex gap-3 mb-8",children:[0,1,2,3].map(t=>e.jsx("div",{className:c("w-6 h-6 rounded-full border-2 transition-colors",t<n.length?"bg-primary border-primary":"border-muted")},t))}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 w-full max-w-xs",children:[[1,2,3,4,5,6,7,8,9].map(t=>e.jsx("button",{onClick:()=>N(String(t)),className:"aspect-square rounded-xl bg-muted hover:bg-muted/80 active:bg-primary active:text-primary-foreground text-2xl font-bold transition-colors border",children:t},t)),e.jsx("div",{}),e.jsx("button",{onClick:()=>N("0"),className:"aspect-square rounded-xl bg-muted hover:bg-muted/80 active:bg-primary active:text-primary-foreground text-2xl font-bold transition-colors border",children:"0"}),e.jsx("button",{onClick:K,className:"aspect-square rounded-xl bg-muted hover:bg-destructive/10 text-muted-foreground hover:text-destructive text-xl font-bold transition-colors border flex items-center justify-center",children:e.jsx(B,{className:"w-6 h-6"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-6 flex items-center gap-1",children:[e.jsx(Q,{className:"w-3 h-3"}),"Don't have a PIN? Ask your manager to set one up."]})]})}),e.jsx("div",{className:"lg:w-96",children:e.jsx(z,{employees:p,clockedInEmployees:q,getActiveEntry:x})})]})]})}export{oe 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.