PageSourceSearch

https://restaurantai.consulting/assets/employee-checklists-3thZye5X.js

js restaurantai.consulting collected 2026-09-24 14:59:12 UTC 6,771 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-motion-CAS9Mrr8.js";import{a as p}from"./vendor-charts-CCcpKWTT.js";import{ab as S,d as E,I as K,J as $,O as B,Y as T,_ as R,$ as F,K as P,N as Y,x as A,P as O,Q as _,R as J}from"./index-CxC89PRg.js";import{B as U}from"./badge-DXnfPCD0.js";import{C as z}from"./clipboard-check-DwWiHv34.js";import{C as H}from"./circle-check-DI67LXtl.js";import{S as G,M as V}from"./sunrise-C9-tZEAJ.js";import{L as W}from"./list-checks-dXCqfFWO.js";import"./vendor-pdf-C9TCjkzL.js";const C={open:0,close:1,other:2};function X(t){return t==="open"?e.jsx(G,{className:"h-5 w-5 text-[#c8934e]"}):t==="close"?e.jsx(V,{className:"h-5 w-5 text-[#c8934e]"}):e.jsx(W,{className:"h-5 w-5 text-[#c8934e]"})}function Z(){const t=new Date,l=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${l}-${r}-${o}`}function ee(t){const[l,r,o]=t.split("-").map(Number);return new Date(l,r-1,o).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})}function me(){const t=Z(),l=S(),r=p.useMemo(()=>["/api/employee/checklists",t],[t]),o=E({queryKey:r,queryFn:async()=>{const c=await fetch(`/api/employee/checklists/${t}`,{credentials:"include"});if(!c.ok)throw new Error("Failed to load checklists");return c.json()}}),m=()=>l.invalidateQueries({queryKey:r}),u=o.data??[],h=p.useMemo(()=>[...u].sort((c,g)=>{const f=C[c.checklist.type]??9,i=C[g.checklist.type]??9;return f!==i?f-i:c.checklist.name.localeCompare(g.checklist.name)}),[u]);return e.jsxs("div",{className:"min-h-screen bg-[#1c1210] text-foreground pb-24",children:[e.jsx("div",{className:"sticky top-0 z-20 bg-[#1c1210]/95 backdrop-blur border-b border-white/10",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:e.jsx("div",{className:"container mx-auto px-4 max-w-2xl py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-6 w-6 text-[#c8934e]"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold leading-tight",children:"Station Checklists"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ee(t)})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 max-w-2xl py-4 space-y-4",children:o.isLoading?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):h.length===0?e.jsx($,{className:"bg-[#241812] border-white/10",children:e.jsx(B,{className:"py-12 text-center text-muted-foreground",children:"No checklists set up yet. Ask a manager to add the opening and closing lists."})}):h.map(c=>e.jsx(te,{entry:c,date:t,onChanged:m},c.checklist.id))})]})}function te({entry:t,date:l,onChanged:r}){const{toast:o}=T(),m=S(),u=["/api/employee/checklists",l],h=t.checklist.id,c=t.run?.status==="signed",[g,f]=p.useState(!1),i=c||g,[b,D]=p.useState(""),N=p.useMemo(()=>{const s=new Map;for(const n of t.checks)s.set(n.itemId,n);return s},[t.checks]),M=R({mutationFn:async s=>{const n=t.items.map(d=>{const k=s.get(d.id);return{itemId:d.id,done:k?.done??!1,note:k?.note??null}});return(await F("PUT",`/api/employee/checklists/${h}/${l}/checks`,{checks:n,checkedBy:b.trim()||null})).json()},onMutate:async s=>{await m.cancelQueries({queryKey:u});const n=m.getQueryData(u);return n&&m.setQueryData(u,n.map(a=>{if(a.checklist.id!==h)return a;const d=a.items.map(x=>{const v=s.get(x.id),Q=a.checks.find(q=>q.itemId===x.id);return{itemId:x.id,done:v?.done??!1,note:v?.note??null,checkedBy:b.trim()||Q?.checkedBy||null}}),k=d.filter(x=>x.done).length;return{...a,checks:d,rollup:{done:k,total:a.items.length}}})),{prev:n}},onError:(s,n,a)=>{a?.prev&&m.setQueryData(u,a.prev),String(s?.message??"").includes("409")?(f(!0),o({title:"Signed off",description:"A manager already verified this. See a manager to reopen."}),r()):o({title:"Couldn't save",description:"Try again.",variant:"destructive"})},onSettled:()=>r()}),I=()=>{const s=new Map;for(const n of t.items){const a=N.get(n.id);s.set(n.id,{done:!!a?.done,note:a?.note??null})}return s},L=(s,n)=>{if(i)return;const a=I(),d=a.get(s)??{done:!1,note:null};a.set(s,{...d,done:n}
1),M.mutate(a)},y=t.items.length,w=t.rollup?.done??t.checks.filter(s=>s.done).length,j=y>0&&w>=y;return e.jsxs($,{className:`bg-[#241812] ${i?"border-emerald-600/40":"border-white/10"}`,children:[e.jsx(P,{className:"pb-3",children:e.jsxs(Y,{className:"text-lg flex items-center gap-2 flex-wrap",children:[X(t.checklist.type),e.jsx("span",{className:"flex-1 min-w-0",children:t.checklist.name}),e.jsxs(U,{variant:j?"default":"secondary",className:`text-sm px-3 py-1 ${j?"bg-emerald-600/20 text-emerald-400 border border-emerald-600/40":""}`,"data-testid":`emp-checklists-progress-${h}`,children:[w,"/",y]})]})}),e.jsxs(B,{className:"space-y-3",children:[i?e.jsxs("div",{className:"flex items-center gap-2 rounded bg-emerald-600/10 border border-emerald-600/30 px-3 py-3",children:[e.jsx(A,{className:"h-5 w-5 text-emerald-500 shrink-0"}),e.jsxs("p",{className:"text-sm",children:["Signed",t.run?.signedBy?` by ${t.run.signedBy}`:""," — see a manager to reopen."]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-sm text-muted-foreground shrink-0",children:"Your initials"}),e.jsx(_,{value:b,onChange:s=>D(s.target.value),placeholder:"e.g. JD",maxLength:8,className:"h-12 max-w-[160px] text-lg font-semibold","data-testid":`emp-checklists-checkedby-${h}`})]}),y===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No items on this checklist yet."}):e.jsx("div",{className:"space-y-2.5",children:t.items.map(s=>{const n=N.get(s.id),a=!!n?.done;return e.jsxs("button",{type:"button",disabled:i,onClick:()=>L(s.id,!a),className:`w-full flex items-center gap-4 px-4 py-4 text-left rounded-xl border transition-colors ${a?"border-emerald-600/40 bg-emerald-600/10":"border-white/10 bg-[#1c1210]"} ${i?"opacity-80 cursor-default":"active:bg-white/5"}`,"data-testid":`emp-checklists-item-${s.id}`,children:[e.jsx("span",{className:`h-9 w-9 shrink-0 rounded-lg border-2 flex items-center justify-center ${a?"bg-emerald-600 border-emerald-600 text-white":"border-white/25 text-transparent"}`,children:e.jsx(J,{className:"h-6 w-6"})}),e.jsx("span",{className:`flex-1 text-[17px] leading-snug ${a?"line-through text-muted-foreground":""}`,children:s.label}),n?.checkedBy&&e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 uppercase font-medium",children:n.checkedBy})]},s.id)})}),j&&!i&&e.jsxs("div",{className:"flex items-center gap-2 rounded bg-emerald-600/10 border border-emerald-600/30 px-3 py-3",children:[e.jsx(H,{className:"h-5 w-5 text-emerald-500 shrink-0"}),e.jsx("p",{className:"text-sm",children:"All done — a manager will verify and lock this."})]})]})]})}export{me 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.