PageSourceSearch

https://smackah.com/assets/ParticipantShirtCleanupPanel-B0BqzNdu.js

js smackah.com collected 2026-10-10 00:46:37 UTC 4,553 bytes, 1 lines download raw bytes

1import{u as E,r as m,s as b,j as s,C as A,l as P,m as R,au as $,n as B,B as y,w as _,a as O,k as q,aj as H,bE as L}from"./index-DbUPl3PC.js";import{P as D}from"./ParticipantEditDialog-Cyq6_L3z.js";import{T as M,a as F,b as T,c as h,d as G,e as u}from"./table-CHZFxP31.js";import{R as J}from"./refresh-cw-CJLggVLQ.js";const W=()=>{const{activeEvent:i}=E(),[j,N]=m.useState(!1),[k,v]=m.useState([]),[n,g]=m.useState(null),x=m.useCallback(async()=>{if(i!=null&&i.id){N(!0);try{const{data:t,error:r}=await b.from("registrations").select("id, order_number, email, participants, sku_id").eq("event_id",i.id).eq("status","completed").or("refund_status.is.null,refund_status.neq.full");if(r)throw r;const c=new Set;(t||[]).forEach(a=>{a.sku_id&&c.add(a.sku_id),(Array.isArray(a.participants)?a.participants:[]).forEach(e=>{e!=null&&e.skuId&&c.add(e.skuId)})});const w=new Map;if(c.size>0){const{data:a}=await b.from("registration_skus").select("id, includes_shirt").in("id",Array.from(c));(a||[]).forEach(f=>w.set(f.id,!!f.includes_shirt))}const C=[];for(const a of t||[])(Array.isArray(a.participants)?a.participants:[]).forEach((e,z)=>{if(e!=null&&e.deleted)return;const I=(e==null?void 0:e.skuId)||a.sku_id;if(I&&w.get(I)===!1)return;const d=((e==null?void 0:e.shirtOptionName)||"").toString().trim(),p=((e==null?void 0:e.shirtOptionId)||"").toString().trim(),l=((e==null?void 0:e.shirtSize)||"").toString().trim(),S=d.toLowerCase()==="no shirt";let o=null;!d&&!p&&!l?o="Completely blank shirt selection":l&&!d&&!p?o=`Size "${l}" with no shirt option`:S&&l?o=`Marked "No Shirt" but size "${l}" recorded`:!S&&(d||p)&&!l&&(o=`Shirt "${d||p}" with no size`),o&&C.push({registrationId:a.id,orderNumber:a.order_number,email:a.email,participantIndex:z,participant:e,skuId:a.sku_id??null,reason:o})});v(C)}catch(t){console.error("[ParticipantShirtCleanup] scan failed",t)}finally{N(!1)}}},[i==null?void 0:i.id]);return m.useEffect(()=>{x()},[x]),s.jsxs(A,{children:[s.jsxs(P,{className:"flex flex-row items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs(R,{className:"flex items-center gap-2",children:[s.jsx($,{className:"w-5 h-5 text-warning"}),"Participant Shirt Cleanup"]}),s.jsx(B,{children:"Repair participants whose shirt selection is incomplete or contradictory. Edits route through the standard participant editor so inventory and the audit log stay in sync."})]}),s.jsxs(y,{variant:"outline",size:"sm",onClick:x,disabled:j,children:[j?s.jsx(_,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(J,{className:"w-4 h-4 mr-2"}),"Rescan"]})]}),s.jsx(O,{children:j?s.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[s.jsx(_,{className:"w-6 h-6 animate-spin mr-2"}),"Scanning participants…"]}):k.length===0?s.jsxs("div",{className:"flex items-center gap-2 py-8 text-success",children:[s.jsx(q,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"All participant shirt records look clean."})]}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs(M,{children:[s.jsx(F,{children:s.jsxs(T,{children:[s.jsx(h,{children:"Order"}),s.jsx(h,{children:"Participant"}),s.jsx(h,{children:"Issue"}),s.jsx(h,{children:"Current shirt"}),s.jsx(h,{className:"text-right",children:"Action"})]})}),s.jsx(G,{children:k.map(t=>{const r=t.participant||{},c=`${r.firstName||""} ${r.lastName||""}`.trim()||"(no name)";return s.jsxs(T,{children:[s.jsxs(u,{children:[s.jsx("div",{className:"font-mono text-xs",children:t.orderNumber||t.registrationId.slice(0,8)}),s.jsx("div",{className:"text-xs text-muted-foreground",children:t.email})]}),s.jsxs(u,{children:[s.jsx("div",{className:"text-sm font-medium",children:c}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:["#",t.participantIndex+1]})]}),s.jsx(u,{children:s.jsx(H,{variant:"outline",className:"text-warning border-warning/40",children:t.reason})}),s.jsxs(u,{className:"text-xs text-muted-foreground",children:["opt: ",s.jsx("span",{className:"font-mono",children:r.shirtOptionName||"—"}),s.jsx("br",{}),"size: ",s.jsx("span",{className:"font-mono",children:r.shirtSize||"—"})]}),s.jsx(u,{className:"text-right",children:s.jsxs(y,{size:"sm",variant:"outline",onClick:()=>g(t),children:[s.jsx(L,{className:"w-3 h-3 mr-1"}),"Repair"]})})]},`${t.registrationId}-${t.participantIndex}`)})})]})})}),n&&s.jsx(D,{open:!!n,onClose:()=>g(null),registrationId:n.registrationId,participantIndex:n.participantIndex,participant:n.participant,skuId:n.skuId,onSuccess:()=>{g(null),x()}})]})};export{W as ParticipantShirtCleanupPanel};

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.