PageSourceSearch

https://book.minimozart.com/assets/DropinClassesView-wvgM5RSM.js

js minimozart.com collected 2026-10-09 22:03:48 UTC 7,254 bytes, 1 lines download raw bytes

1import{r as c,j as s,B as D,ag as ie,L as ce,l as B,f as le,J as N,a9 as de}from"./index-DKZta-WU.js";import{O as me}from"./OrdersTable-BYnF94UU.js";import{O as ue}from"./OrderDetailDialog-BKt6zi0J.js";import{D as pe}from"./download-DZP29Dp0.js";import{C as _e}from"./chevron-left-DT3ihNvd.js";import{C as he}from"./chevron-right-BhtpWQ1i.js";import"./HappityBadge-ztzB0nwK.js";import"./QuickDropinBadge-BJ8yBZs7.js";import"./table-nrlB0Mcp.js";import"./badge-qkv9PT1W.js";import"./arrow-up-down-BNKuFwFC.js";import"./arrow-up-70jWTRxH.js";import"./AttributionLine-DP-aTmln.js";const E=100,fe={order:"order_number",customer:"customer_name",classDate:"class_date",status:"status",date:"created_at",total:"total"},ge=h=>h,xe=h=>h.replace(/[,()]/g," ").trim(),$e=()=>{const[h,J]=c.useState([]),[O,P]=c.useState(!0),[w,M]=c.useState(""),[b,Q]=c.useState(""),[V,X]=c.useState(null),[G,A]=c.useState(!1),[u,C]=c.useState(1),[F,H]=c.useState(0),[q,U]=c.useState("date"),[L,Z]=c.useState("desc"),j=Math.max(1,Math.ceil(F/E)),K=async()=>{P(!0);try{const e=ge("id, order_number, customer_name, customer_email, total, created_at, class_date, status, metadata, line_items(id, product_name, product_id, metadata, products(product_type))"),a=(u-1)*E,d=a+E-1,i=q&&L?fe[q]:null,p=L==="asc";let t=B.from("orders").select(e,{count:"exact"}).not("class_date","is",null);const r=xe(b);r&&(t=t.or(`order_number.ilike.%${r}%,customer_name.ilike.%${r}%,customer_email.ilike.%${r}%,status.ilike.%${r}%`)),i?(t=t.order(i,{ascending:p}),i!=="created_at"&&(t=t.order("created_at",{ascending:!1}))):t=t.order("created_at",{ascending:!1});const{data:f,error:g,count:te}=await t.range(a,d).returns();if(g)throw g;H(te||0);const se=(f||[]).filter(o=>{const x=o.line_items||[];return x.length===0?!0:x.some(y=>{var v;const k=(v=y.products)==null?void 0:v.product_type;return k?k==="dropin":y.product_name&&y.product_name.toLowerCase().includes("drop")})}).map(o=>{var z,R;const x=o.metadata||{},y=(o.line_items||[]).map(n=>{var _;return(_=n==null?void 0:n.metadata)==null?void 0:_.child_name}).find(n=>typeof n=="string"&&n.trim().length>0)||null,k=x.child_name||y||null,v=n=>{const _=[];if(n.metadata&&Object.entries(n.metadata).forEach(([S,ne])=>{_.push({key:S,value:String(ne)})}),o.class_date&&!_.some(S=>S.key==="_option_date")){const S=new Date(o.class_date);_.push({key:"_option_date",value:le(S,"dd/MM/yyyy")})}return _},I=x||{},m=I.order_type||"",$=I.payment_method||"",ae=m==="happity_provisional"||m==="happity"||$==="happity",re=m==="quick_dropin_provisional"||m==="quick_dropin"||$==="quick_dropin"||m==="quick_taster_provisional"||m==="quick_taster"||$==="quick_taster",oe=m==="quick_dropin_provisional"||m==="quick_taster_provisional";return{id:o.id,number:o.order_number,status:o.status,total:String(o.total),date_created:o.created_at,customer_email:o.customer_email||null,child1_first_name:k||void 0,is_happity:ae,is_quick_dropin:re,is_quick_dropin_provisional:oe,billing_address:{first_name:((z=o.customer_name)==null?void 0:z.split(" ")[0])||"",last_name:((R=o.customer_name)==null?void 0:R.split(" ").slice(1).join(" "))||""},line_items:(o.line_items||[]).map(n=>({name:n.product_name,product_id:n.product_id,meta_data:v(n)}))}});J(se)}catch(e){console.error("Error fetching drop-in orders:",e),N.error("Failed to fetch drop-in orders")}finally{P(!1)}};c.useEffect(()=>{const e=setTimeout(()=>{Q(w),C(1)},350);return()=>clearTimeout(e)},[w]),c.useEffect(()=>{K()},[u,q,L,b]);const W=(e,a)=>{if(e==="product"){N.info("Sorting by product isn't available across pages");return}C(1),U(e),Z(a)},l=b.trim().toLowerCase(),T=l?h.filter(e=>{var i;const a=`${e.billing_address.first_name} ${e.billing_address.last_name}`.toLowerCase(),d=((i=e.line_items)==null?void 0:i.map(p=>{var t;return((t=p.name)==null?void 0:t.toLowerCase())||""}).join(" "))||"";return e.number.toLowerCase().includes(l)||a.includes(l)||(e.customer_email||"").toLowerCase().includes(l)||e.status.toLowerCase().includes(l)||d.includes(l)||e.is_happity&&"happity".includes(l)||e.is_quick_dropin&&("quick drop-in".includes(l)||"quick dropin".includes(l))}):h,Y=async e=>{try{const{data:a,error:d}=await B.from("orders").select("*, line_items(*)").eq("id",String(e)).single();if(d)throw d;const i=a.metadata||{},p={...a,order_number:a.order_number,date_created:a.created_at,date_modified:a.updated_at,class_date:a.class_date,customer_name:a.customer_name,customer_email:a.customer_email,payment_method:i.payment_method||"N/A",child1_first_name:i.child_
1name||(a.line_items||[]).map(t=>{var r;return(r=t==null?void 0:t.metadata)==null?void 0:r.child_name}).find(t=>typeof t=="string"&&t.trim().length>0)||null,total:String(a.total),line_items:(a.line_items||[]).map(t=>({name:t.product_name,product_id:t.product_id,quantity:t.quantity,total:String(t.total),meta_data:t.metadata?Object.entries(t.metadata).map(([r,f])=>({key:r,value:String(f)})):[]}))};X(p),A(!0)}catch{N.error("Failed to fetch order details")}},ee=async()=>{const e=await de(()=>import("./xlsx-C2piJvdv.js"),[]),a=T.map(r=>{var f,g;return{"Order Number":r.number,"Customer Name":`${r.billing_address.first_name} ${r.billing_address.last_name}`,"Child Name":r.child1_first_name||"N/A",Product:((g=(f=r.line_items)==null?void 0:f[0])==null?void 0:g.name)||"N/A",Status:r.status,"Order Date":new Date(r.date_created).toLocaleDateString(),Total:`£${r.total}`}}),d=e.utils.json_to_sheet(a),i=e.utils.book_new();e.utils.book_append_sheet(i,d,"Drop-in Classes");const p=new Date().toISOString().split("T")[0],t=`dropin-classes-page-${u}-${p}.xlsx`;e.writeFile(i,t),N.success(`Downloaded ${T.length} orders to ${t}`)};return s.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold",children:"Drop-in Classes"}),s.jsxs("p",{className:"text-muted-foreground",children:["Page ",u," of ",j," — ",F.toLocaleString()," ",b.trim()?"matching ":"","drop-in orders"]})]}),s.jsxs(D,{onClick:ee,variant:"outline",size:"sm",children:[s.jsx(pe,{className:"h-4 w-4 mr-2"}),"Download Excel"]})]}),s.jsxs("div",{className:"flex gap-4 items-center",children:[s.jsx(ie,{placeholder:"Search all drop-in orders (name, email, order no.)…",value:w,onChange:e=>M(e.target.value),className:"max-w-md"}),w&&s.jsx(D,{variant:"ghost",size:"sm",onClick:()=>M(""),children:"Clear search"})]}),O?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ce,{className:"h-8 w-8 animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"space-y-4",children:s.jsx(me,{orders:T,onOrderClick:Y,showClassDate:!0,showChildNames:!0,serverSideSorting:!0,onSort:W})}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsxs(D,{variant:"outline",size:"sm",onClick:()=>C(e=>Math.max(1,e-1)),disabled:u<=1||O,children:[s.jsx(_e,{className:"h-4 w-4 mr-1"}),"Previous"]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",u," of ",j]}),s.jsxs(D,{variant:"outline",size:"sm",onClick:()=>C(e=>Math.min(j,e+1)),disabled:u>=j||O,children:["Next",s.jsx(he,{className:"h-4 w-4 ml-1"})]})]}),s.jsx(ue,{order:V,open:G,onOpenChange:A})]})]})};export{$e 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.