PageSourceSearch

https://www.stateofhopefoundation.org/assets/GigisCheckIn-DZ2RT2dE.js

js stateofhopefoundation.org collected 2026-10-09 22:03:38 UTC 11,900 bytes, 1 lines download raw bytes

1import{r as i,j as s,ac as ne,I as N,B as l,s as P,Z as g}from"./index-CnefEix6.js";import{C as R}from"./card-COFAljtZ.js";import{B as L}from"./badge-BCw8tEFX.js";import{P as ke}from"./plus-BvBRpyZf.js";import{L as _e}from"./log-out-Dss4UIKh.js";import{S as be}from"./search-AsSQL_jP.js";import{U as re}from"./user-plus-B4TgfxxW.js";import{L as ce}from"./loader-circle-B1zufDUH.js";import{U as ve}from"./users-BLLCe_ZR.js";import{U as Ce}from"./user-check-CGaJQgU9.js";import{C as Se}from"./circle-check-CcjDT5kI.js";import{C as ye}from"./circle-x-CsE1ZO_B.js";const Ie="sohf_gigis_volunteer_creds",K="gigis-checkin-auth",ie=2026;function Ge(){try{const d=localStorage.getItem(Ie);if(d)return JSON.parse(d)}catch{}return{username:"volunteer",password:"stateofhope123"}}const j=d=>{const p=[d.name,...(d.guest_names||[]).filter(Boolean)],b=Math.max(p.length,d.guest_count||p.length);for(;p.length<b;)p.push(`Guest ${p.length+1}`);return p},u=d=>d.trim().toLowerCase().replace(/\s+/g,"_"),Fe=()=>{const[d,p]=i.useState(()=>sessionStorage.getItem(K)==="1"),[b,F]=i.useState(""),[M,T]=i.useState(""),[oe,W]=i.useState(!0),[f,$]=i.useState([]),[v,le]=i.useState(""),[C,Y]=i.useState(null),[de,z]=i.useState(!1),[k,q]=i.useState(""),[H,J]=i.useState(""),[V,X]=i.useState("1"),[Z,Q]=i.useState(!1),[ee,O]=i.useState(null),[S,U]=i.useState(""),[y,B]=i.useState(""),[se,E]=i.useState(null),[I,G]=i.useState(""),me=async()=>{W(!0);const{data:e,error:t}=await P.rpc("get_gigis_checkin_list",{_year:ie});t?g.error("Failed to load guests",{description:t.message}):$((e||[]).map(a=>({...a,guest_names:Array.isArray(a.guest_names)?a.guest_names:[]}))),W(!1)};i.useEffect(()=>{d&&me()},[d]);const ue=e=>{e.preventDefault();
1const t=Ge();b.trim().toLowerCase()===String(t.username).trim().toLowerCase()&&M===t.password?(sessionStorage.setItem(K,"1"),p(!0)):g.error("Invalid credentials",{description:"Check the username and password and try again."})},he=()=>{sessionStorage.removeItem(K),p(!1),F(""),T("")},te=i.useMemo(()=>{const e=v.trim().toLowerCase();return e?f.filter(t=>j(t).some(a=>a.toLowerCase().includes(e))||(t.business_name||"").toLowerCase().includes(e)||(t.group_name||"").toLowerCase().includes(e)||(t.email||"").toLowerCase().includes(e)):f},[f,v]),A=i.useMemo(()=>{let e=0,t=0,a=0;for(const n of f){const c=j(n);e+=c.length;const h=n.checkin_status||{},o=c.filter(r=>{var m;return(m=h[u(r)])==null?void 0:m.checked_in}).length;t+=o,o===c.length&&c.length>0&&(a+=1)}return{people:e,checkedIn:t,groups:f.length,groupsIn:a}},[f]),_=async(e,t)=>{Y(e.id);const{error:a}=await P.rpc("gigis_update_checkin_fields",{_id:e.id,_updates:t});return Y(null),a?(g.error("Save failed",{description:a.message}),!1):($(n=>n.map(c=>c.id===e.id?{...c,...t}:c)),!0)},xe=async(e,t)=>{var r;const a=u(t),n={...e.checkin_status||{}};(r=n[a])!=null&&r.checked_in?delete n[a]:n[a]={checked_in:!0,at:new Date().toISOString(),by:"volunteer"};const o=j(e).filter(m=>{var w;return(w=n[u(m)])==null?void 0:w.checked_in}).length===0?"pending":"checked_in";await _(e,{checkin_status:n,attendance_status:o})},pe=async e=>{const t={},a=new Date().toISOString();for(const c of j(e))t[u(c)]={checked_in:!0,at:a,by:"volunteer"};await _(e,{checkin_status:t,attendance_status:"checked_in"})&&g.success("Group checked in",{description:`${e.name} (${j(e).length})`})},ge=async e=>{await _(e,{checkin_status:{},attendance_status:"no_show"})},fe=async()=>{if(!k.trim()){g.error("Name is required");return}const e=Math.max(1,parseInt(V)||1);Q(!0);const{data:t,error:a}=await P.rpc("gigis_add_walkin",{_name:k.trim(),_business_name:H.trim()||null,_guest_count:e,_year:ie,_checkin_status:{[u(k.trim())]:{checked_in:!0,at:new Date().toISOString(),by:"volunteer-walkin"}}});if(Q(!1),a){g.error("Add failed",{description:a.message});return}g.success("Walk-in added",{description:k}),q(""),J(""),X("1"),z(!1),$(n=>[...n,{...t,guest_names:[]}])},Ne=async()=>{const e=f.find(x=>x.id===ee);if(!e||!y.trim())return;const t=y.trim(),a=u(S),n=u(t),h=j(e).findIndex(x=>u(x)===a);let o=[...e.guest_names||[]];if(h===0)o.push(t);else{const x=o.findIndex(D=>u(D)===a);x>=0?o[x]=t:o.push(t)}const r={...e.checkin_status||{}};delete r[a],r[n]={checked_in:!0,at:new Date().toISOString(),by:"volunteer-swap"};const m=`${e.notes?e.notes+" | ":""}Swap @ check-in: ${S} → ${t}`;await _(e,{guest_names:o,checkin_status:r,attendance_status:"checked_in",notes:m})&&(g.success("Swap recorded",{description:`${S} → ${t}`}),O(null),U(""),B(""))},je=async()=>{const e=f.find(r=>r.id===se);if(!e||!I.trim())return;const t=I.trim(),a=[...e.guest_names||[],t],n=(e.guest_count||0)+1,c={...e.checkin_status||{}};c[u(t)]={checked_in:!0,at:new Date().toISOString(),by:"volunteer-added"};const h=`${e.notes?e.notes+" | ":""}Added @ check-in: ${t}`;await _(e,{guest_names:a,guest_count:n,checkin_status:c,attendance_status:"checked_in",notes:h})&&(g.success("Guest added",{description:`${t} added to ${e.name}`}),E(null),G(""))};return d?s.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-emerald-50 via-background to-amber-50",children:[s.jsx(ne,{children:s.jsx("title",{children:"Night at Gigi's Check-In"})}),s.jsxs("header",{className:"sticky top-0 z-20 bg-background/95 backdrop-blur border-b",children:[s.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-3 flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"font-bold text-primary",children:"Night at Gigi's Check-In"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[A.groupsIn,"/",A.groups," groups • ",A.checkedIn,"/",A.people," guests"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(l,{variant:"outline",size:"sm",onClick:()=>z(e=>!e),children:[s.jsx(ke,{className:"w-4 h-4 mr-1"})," Walk-in"]}),s.jsxs(l,{variant:"outline",size:"sm",onClick:he,children:[s.jsx(_e,{className:"w-4 h-4 mr-1"})," Sign out"]})]})]}),s.jsx("div",{className:"max-w-3xl mx-auto px-4 pb-3",children:s.jsxs("div",{className:"relative",children:[s.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}
1),s.jsx(N,{value:v,onChange:e=>le(e.target.value),placeholder:"Search by guest, business, or email…",className:"pl-9",autoFocus:!0})]})})]}),s.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-4 space-y-3",children:[de&&s.jsxs(R,{className:"p-4 border-2 border-amber-400 bg-amber-50/40",children:[s.jsxs("div",{className:"font-semibold flex items-center gap-2 mb-2 text-amber-900",children:[s.jsx(re,{className:"w-4 h-4"})," Add walk-in guest"]}),s.jsxs("div",{className:"grid sm:grid-cols-3 gap-2",children:[s.jsx(N,{placeholder:"Guest name *",value:k,onChange:e=>q(e.target.value)}),s.jsx(N,{placeholder:"Business (optional)",value:H,onChange:e=>J(e.target.value)}),s.jsx(N,{type:"number",min:1,placeholder:"# of people",value:V,onChange:e=>X(e.target.value)})]}),s.jsxs("div",{className:"flex gap-2 mt-2 justify-end",children:[s.jsx(l,{variant:"ghost",size:"sm",onClick:()=>z(!1),children:"Cancel"}),s.jsx(l,{size:"sm",onClick:fe,disabled:Z,children:Z?s.jsx(ce,{className:"w-4 h-4 animate-spin"}):"Add & check in"})]})]}),oe?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ce,{className:"w-6 h-6 animate-spin text-primary"})}):te.length===0?s.jsx("p",{className:"text-center text-muted-foreground py-8",children:v?"No matches. Try a different name.":"No guests yet."}):te.map(e=>{const t=j(e),a=e.checkin_status||{},n=t.filter(r=>{var m;return(m=a[u(r)])==null?void 0:m.checked_in}).length,c=n===t.length&&t.length>0,h=e.attendance_status==="no_show",o=e.business_name||e.group_name;return s.jsxs(R,{className:`p-4 ${c?"border-emerald-500 bg-emerald-50/50":h?"border-destructive/40 bg-destructive/5":""}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-semibold flex items-center gap-2 flex-wrap",children:[e.name,o&&o!==e.name&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",o,")"]}),e.source&&e.source!=="manual"&&s.jsx(L,{variant:"outline",className:"text-[10px]",children:e.source})]}),s.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2 mt-0.5 flex-wrap",children:[s.jsx(ve,{className:"w-3 h-3"})," Group of ",t.length,c&&s.jsx(L,{variant:"default",className:"bg-emerald-600",children:"All in"}),h&&s.jsx(L,{variant:"destructive",children:"No-show"}),!c&&!h&&n>0&&s.jsxs(L,{variant:"secondary",children:[n,"/",t.length," in"]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[!c&&s.jsxs(l,{size:"sm",onClick:()=>pe(e),disabled:C===e.id,children:[s.jsx(Ce,{className:"w-4 h-4 mr-1"})," All in"]}),!h&&n===0&&s.jsx(l,{size:"sm",variant:"outline",onClick:()=>ge(e),disabled:C===e.id,children:"No-show"})]})]}),s.jsx("div",{className:"space-y-1.5",children:t.map((r,m)=>{var ae;const w=u(r),x=!!((ae=a[w])!=null&&ae.checked_in),D=ee===e.id&&S===r;return s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>xe(e,r),disabled:C===e.id,className:`flex-1 flex items-center justify-between px-3 py-2 rounded-md border text-left transition ${x?"bg-emerald-100 border-emerald-400 text-emerald-900":"bg-background border-border hover:bg-muted"}`,children:[s.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[x?s.jsx(Se,{className:"w-4 h-4 text-emerald-600"}):s.jsx(ye,{className:"w-4 h-4 text-muted-foreground"}),r," ",m===0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"(host)"})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:x?"Checked in":"Tap to check in"})]}),!x&&s.jsx(l,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>{O(e.id),U(r),B("")},children:"Swap"})]}),D&&s.jsxs("div",{className:"flex items-center gap-2 pl-3",children:[s.jsx(N,{placeholder:`Replacement for ${r}`,value:y,onChange:we=>B(we.target.value),className:"h-8 text-sm"}),s.jsx(l,{size:"sm",onClick:Ne,disabled:!y.trim(),children:"Save"}),s.jsx(l,{size:"sm",variant:"ghost",onClick:()=>{O(null),U("")},children:"Cancel"})]})]},w+m)})}),se===e.id?s.jsxs("div",{className:"flex items-center gap-2 mt-2 pl-1",children:[s.jsx(N,{placeholder:"New guest name",value:I,onChange:r=>G(r.target.value),className:"h-8 text-sm",autoFocus:!0}),s.jsx(l,{size:"sm",onClick:je,disabled:!I.trim()||C===e.id,children:"Add"}),s.jsx(l,{size:"sm",variant:"ghost",onClick:()=>{E(null),G("")},children:"Cancel"})]}):s.jsxs(l,{size:"sm",variant:"outline",className:"mt-2 text-xs",onClick:()=>{E(e.id),G("")},children:[s.jsx(re,{className:"w-3.5 h-3.5 mr-1"})," Add guest to this group"]}),e.notes&&s.jsxs("p",{className:"text-xs text-muted-foreground mt-2 italic",children:["Note: ",e.notes]})]},e.id)})]})]}):s.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-gradient-to-br from-emerald-50 via-background to-amber-50",children:[s.jsx(ne,{children:s.jsx("title",{children:"Night at Gigi's Check-In"})}),s.jsxs(R,{className:"w-full max-w-md p-6 space-y-4 border-2 border-primary/20",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"text-2xl font-bold text-primary",children:"A Night at Gigi's"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Volunteer Check-In Portal"})]}),s.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-semibold",children:"Username"}),s.jsx(N,{value:b,onChange:e=>F(e.target.value),autoFocus:!0,autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs font-semibold",children:"Password"}),s.jsx(N,{type:"password",value:M,onChange:e=>T(e.target.value),autoComplete:"current-password"})]}),s.jsx(l,{type:"submit",className:"w-full",children:"Sign In"})]})]})]})};export{Fe 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.