PageSourceSearch

https://futuresummit.ai/assets/AdminOrdersTab-6rkL3upO.js

js futuresummit.ai collected 2026-10-05 12:00:03 UTC 15,093 bytes, 1 lines download raw bytes

1import{r as i,u as ae,j as e,R as O}from"./index-Cb0uFkxi.js";import{s as N}from"./client-3Rgyq3FX.js";import{B as g}from"./button-BXT4L8KI.js";import{I}from"./input-CyLPhXcX.js";import{S as ne}from"./switch-BEnOmFxW.js";import{L as ie}from"./label-BuZ4UdiW.js";import{T as de,a as oe,b as u,c as o,d as ce,e as a}from"./table-DG9zpLGi.js";import{u as le,i as me}from"./postgrestSearch-DYL3b5Ts.js";import{d as ue}from"./csv-WYRQGzP5.js";import{u as xe}from"./useCsvExportAccess-BZyQJUjH.js";import{S as U}from"./StatusBadge-CFv7nYv7.js";import{U as pe,f as F,c as w}from"./AdminDashboard-DbhI5JLi.js";import{R as he}from"./refresh-cw-D_fuxE1r.js";import{D as fe}from"./download-DMvlHEr0.js";import{C as B}from"./chevron-up-Co9HabI0.js";import{C as M}from"./chevron-down-CNHxCdIc.js";import{C as ge}from"./chevron-left-BtEncjtN.js";import{C as _e}from"./chevron-right-1Co9RUio.js";import"./tslib.es6-CmEaCU22.js";import"./index-BHD-fViZ.js";import"./users-C4vacUnP.js";import"./arrow-left-right-SUQyFqNL.js";import"./mail-D84mECxx.js";import"./globe-rk7kRW71.js";const C=20,be={completed:"success",pending:"pending",failed:"danger",expired:"neutral"},je={captured:"success",paid:"success",link_sent:"pending",authorized:"pending",unpaid:"neutral"};function He(){const[k,V]=i.useState(""),[p,_]=i.useState(0),[T,D]=i.useState(!0),[v,H]=i.useState([]),[x,y]=i.useState(null),[S,Q]=i.useState({}),[A,E]=i.useState(null),[R,Y]=i.useState({}),[L,G]=i.useState([]),[h,W]=i.useState(!1),c=le(k),[X,Z]=i.useState(c);c!==X&&(Z(c),_(0));const{toast:l}=ae(),J=xe(),b=i.useCallback(async()=>{D(!0);try{let r=N.from("orders").select("*").order("created_at",{ascending:!1});h||(r=r.neq("status","expired")),c&&(r=r.or(me(["order_number","buyer_name","buyer_email"],c)));const[s,t]=await Promise.all([r,N.from("investor_applications").select("id, created_at, full_name, email, firm, title, accredited, check_size, aum, focus_sectors, focus_stage, linkedin_url, authorized_at, captured_at, pass_quantity, payment_status, confirmation_number, captured_amount_cad_cents, authorized_amount_cad_cents, fee_cad_cents").eq("status","approved").order("created_at",{ascending:!1})]);if(s.error)throw s.error;const d=s.data??[],m=c.trim().toLowerCase(),se=(t.data??[]).map(n=>{const re=n.captured_amount_cad_cents??n.authorized_amount_cad_cents??(n.fee_cad_cents??0)*(n.pass_quantity??1);return{id:n.id,created_at:n.created_at,full_name:n.full_name,email:n.email,firm:n.firm,title:n.title,accredited:n.accredited,check_size:n.check_size,aum:n.aum,focus_sectors:n.focus_sectors,focus_stage:n.focus_stage,linkedin_url:n.linkedin_url,authorized_at:n.authorized_at,captured_at:n.captured_at,pass_quantity:n.pass_quantity??1,payment_status:n.payment_status,confirmation_number:n.confirmation_number,total_cad:(re??0)/100}}).filter(n=>!m||n.full_name.toLowerCase().includes(m)||n.email.toLowerCase().includes(m)||(n.confirmation_number??"").toLowerCase().includes(m));H(d),G(se)}catch(r){l({title:"Error loading orders",description:r.message,variant:"destructive"})}finally{D(!1)}},[c,h,l]);i.useEffect(()=>{b()},[b]);const f=i.useMemo(()=>h?v:v.filter(r=>r.status!=="expired"),[v,h]),z=i.useMemo(()=>[...f.map(s=>({type:"order",data:s})),...L.map(s=>({type:"investor",data:s}))].sort((s,t)=>{const d=new Date((s.type==="order",s.data.created_at)).getTime();return new Date((t.type==="order",t.data.created_at)).getTime()-d}),[f,L]),q=z.length,j=Math.ceil(q/C)||0,$=z.slice(p*C,(p+1)*C),P=i.useCallback(()=>{b()},[b]),K=async r=>{if(x===r){y(null);return}if(y(r),!S[r]){const{data:s}=await N.from("attendees").select("full_name, email, ticket_tier, confirmation_number, pitch_session, is_buyer").eq("order_id",r).order("is_buyer",{ascending:!1});s&&Q(t=>({...t,[r]:s}))}},ee=async r=>{E(r.id);try{const s=(R[r.id]??r.buyer_email).trim(),{data:t,error:d}=await N.functions.invoke("resend-order-invoice",{body:{order_id:r.id,recipient_email:s}});d?l({title:"Send failed",description:d.message,variant:"destructive"}):(t==null?void 0:t.error)==="too_recent"?l({title:"Wait a moment",description:`Try again in ${t.retry_after_s??60}s.`,variant:"destructive"}):t!=null&&t.error?l({title:"Send failed",description:t.error,variant:"destructive"}):(l({title:"Invoice sent",description:t!=null&&t.with_pdf?`PDF attached → ${t.sent_to}`:`Receipt link → ${(t==null?void 0:t.sent_to)??s}`}),P())}catch(s){l({title:"Send failed",description:s.message,variant:"destructive"})}finally{E(null)}},te=()=>{if(f.length===0)return;const r=["Order #","Date","Buyer","Email","Summit","All Access","Expo","Investor","Pitch Qty","Total USD","Total CAD","Status","Address Line 1","Address Line 2","City","State/Province","Postal Code","Country"],s=f.map(t=>[t.order_number,new Date(t.created_at).toISOString().slice(0,10),t.buyer_name,t.buyer_email,t.summit_qty,t.all_access_qty,t.expo_qty??0,0,t.pitch_qty,w(t.total_ca
1d).toFixed(2),t.total_cad.toFixed(2),t.status,t.billing_address_line1??"",t.billing_address_line2??"",t.billing_city??"",t.billing_state??"",t.billing_postal_code??"",t.billing_country??""].map(String));ue(`fs26_orders_${new Date().toISOString().slice(0,10)}.csv`,r,s)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-5",children:[e.jsx("div",{className:"relative flex-1",children:e.jsx(I,{placeholder:"Search order #, buyer name or email…",value:k,onChange:r=>V(r.target.value),className:"bg-card border-border/50"})}),e.jsx(g,{variant:"outline",size:"icon",onClick:P,className:"border-border/50 shrink-0",children:e.jsx(he,{className:`w-4 h-4 ${T?"animate-spin":""}`})}),e.jsxs("div",{className:"flex items-center gap-2 border border-border/50 rounded-md px-3 shrink-0",children:[e.jsx(ne,{id:"show-expired",checked:h,onCheckedChange:r=>{W(r),_(0)}}),e.jsx(ie,{htmlFor:"show-expired",className:"text-xs text-muted-foreground cursor-pointer",children:"Show expired"})]}),J&&e.jsxs(g,{variant:"outline",size:"sm",onClick:te,disabled:f.length===0,className:"border-border/50 shrink-0",children:[e.jsx(fe,{className:"w-4 h-4 mr-2"})," Export CSV"]})]}),e.jsxs("p",{className:"-mt-2 mb-4 text-xs text-muted-foreground",children:["Totals shown in USD (charged in CAD, converted @ ",pe,"). CSV includes both."]}),e.jsx("div",{className:"border border-border/30 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(de,{children:[e.jsx(oe,{children:e.jsxs(u,{className:"border-border/30 hover:bg-transparent",children:[e.jsx(o,{className:"w-8"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider",children:"ORDER #"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider",children:"DATE"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider",children:"BUYER"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-center",children:"SUMMIT"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-center",children:"ALL ACCESS"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-center",children:"EXPO"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-center",children:"INVESTOR"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-center",children:"PITCH"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider text-right",children:"TOTAL (USD)"}),e.jsx(o,{className:"text-muted-foreground font-heading text-xs tracking-wider",children:"STATUS"})]})}),e.jsx(ce,{children:T?e.jsx(u,{children:e.jsx(a,{colSpan:11,className:"text-center py-12 text-muted-foreground",children:"Loading…"})}):$.length===0?e.jsx(u,{children:e.jsx(a,{colSpan:11,className:"text-center py-12 text-muted-foreground",children:"No orders found."})}):$.map(r=>{if(r.type==="investor"){const t=r.data;return e.jsxs(O.Fragment,{children:[e.jsxs(u,{className:"border-border/20 cursor-pointer hover:bg-muted/30 transition-colors",onClick:()=>y(x===`inv-${t.id}`?null:`inv-${t.id}`),children:[e.jsx(a,{className:"text-muted-foreground",children:x===`inv-${t.id}`?e.jsx(B,{className:"w-3.5 h-3.5"}):e.jsx(M,{className:"w-3.5 h-3.5"})}),e.jsx(a,{className:"font-mono text-xs text-primary",children:t.confirmation_number??"INVESTOR"}),e.jsx(a,{className:"text-sm text-muted-foreground whitespace-nowrap",children:new Date(t.created_at).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"})}),e.jsxs(a,{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t.full_name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.email,t.firm?` · ${t.firm}`:""]})]}),e.jsx(a,{className:"text-center text-sm text-muted-foreground",children:"—"}),e.jsx(a,{className:"text-center text-sm text-muted-foreground",children:"—"}),e.jsx(a,{className:"text-center text-sm text-muted-foreground",children:"—"}),e.jsx(a,{className:"text-center text-sm text-foreground",children:t.pass_quantity}),e.jsx(a,{className:"text-center text-sm text-muted-foreground",children:"—"}),e.jsx(a,{className:"text-right font-medium text-foreground",children:t.total_ca
1d>0?F(w(t.total_cad),2):"—"}),e.jsx(a,{children:e.jsx(U,{label:t.payment_status.replace(/_/g," "),tone:je[t.payment_status]??"pending"})})]}),x===`inv-${t.id}`&&e.jsx(u,{className:"border-border/20 bg-muted/10 hover:bg-muted/10",children:e.jsxs(a,{colSpan:11,className:"py-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-2",children:"Investor application"}),e.jsxs("div",{className:"grid gap-x-8 gap-y-2 sm:grid-cols-2 lg:grid-cols-3 text-sm",children:[[["Title",t.title],["Firm",t.firm],["Accredited",t.accredited==null?null:t.accredited?"Yes":"No"],["Typical check size",t.check_size],["AUM",t.aum],["Focus sectors",t.focus_sectors],["Focus stage",t.focus_stage],["Passes",String(t.pass_quantity)],["Total (CAD)",t.total_cad>0?`$${t.total_cad.toFixed(2)}`:null],["Authorized",t.authorized_at?new Date(t.authorized_at).toLocaleString("en-CA"):null],["Captured",t.captured_at?new Date(t.captured_at).toLocaleString("en-CA"):null]].map(([d,m])=>e.jsxs("div",{children:[e.jsxs("span",{className:"text-muted-foreground",children:[d,": "]}),e.jsx("span",{className:"text-foreground",children:m||"—"})]},d)),t.linkedin_url&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"LinkedIn: "}),e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2",onClick:d=>d.stopPropagation(),children:"Profile"})]})]})]})})]},`inv-${t.id}`)}const s=r.data;return e.jsxs(O.Fragment,{children:[e.jsxs(u,{className:"border-border/20 cursor-pointer hover:bg-muted/30 transition-colors",onClick:()=>K(s.id),children:[e.jsx(a,{className:"text-muted-foreground",children:x===s.id?e.jsx(B,{className:"w-3.5 h-3.5"}):e.jsx(M,{className:"w-3.5 h-3.5"})}),e.jsx(a,{className:"font-mono text-xs text-primary",children:s.order_number}),e.jsx(a,{className:"text-sm text-muted-foreground whitespace-nowrap",children:new Date(s.created_at).toLocaleDateString("en-CA",{month:"short",day:"numeric",year:"numeric"})}),e.jsxs(a,{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s.buyer_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.buyer_email})]}),e.jsx(a,{className:"text-center text-sm",children:s.summit_qty||"—"}),e.jsx(a,{className:"text-center text-sm",children:s.all_access_qty||"—"}),e.jsx(a,{className:"text-center text-sm",children:s.expo_qty||"—"}),e.jsx(a,{className:"text-center text-sm text-muted-foreground",children:"—"}),e.jsx(a,{className:"text-center text-sm",children:s.pitch_qty||"—"}),e.jsx(a,{className:"text-right font-medium text-foreground",children:s.total_cad>0?F(w(s.total_cad),2):"—"}),e.jsx(a,{children:e.jsx(U,{label:s.status,tone:be[s.status]??"pending"})})]}),x===s.id&&e.jsx(u,{className:"border-border/20",children:e.jsxs(a,{colSpan:11,className:"bg-muted/20 px-6 py-4",children:[s.billing_address_line1&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground/60 uppercase tracking-wider mb-1",children:"Billing Address"}),e.jsxs("p",{className:"text-sm text-foreground",children:[s.billing_address_line1,s.billing_address_line2&&`, ${s.billing_address_line2}`," · ",[s.billing_city,s.billing_state,s.billing_postal_code].filter(Boolean).join(", "),s.billing_country&&` · ${s.billing_country}`]})]}),e.jsx("p",{className:"text-xs text-muted-foreground/60 uppercase tracking-wider mb-3",children:"Attendees"}),S[s.id]?e.jsx("div",{className:"flex flex-col gap-2",children:S[s.id].map((t,d)=>e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("span",{className:"text-foreground font-medium min-w-[160px]",children:t.full_name}),e.jsx("span",{className:"text-muted-foreground text-xs",children:t.email}),e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium border ${t.ticket_tier==="all_access"?"bg-primary/10 text-primary border-primary/20":"bg-muted text-muted-foreground border-border/30"}`,children:t.ticket_tier==="all_access"?"All Access":"Summit"}),t.pitch_session&&e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-primary/10 text-primary border border-primary/20",children:"Pitch"}),t.is_buyer&&e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium bg-green-500/10 text-green-400 border border-green-500/20",children:"Buyer"}),e.jsx("span",{className:"font-mono text-xs text-muted-foreground ml-auto",children:t.confirmation_number})]},d))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading attendees…"}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground
1/60 uppercase tracking-wider mb-2",children:"Send Invoice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{type:"email",value:R[s.id]??s.buyer_email,onChange:t=>Y(d=>({...d,[s.id]:t.target.value})),className:"flex-1 max-w-sm h-8 text-sm",placeholder:"[email protected]"}),e.jsx(g,{size:"sm",variant:"outline",disabled:A===s.id||s.status!=="completed",onClick:()=>ee(s),children:A===s.id?"Sending…":"Send"})]}),s.last_invoice_resent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground/60 mt-1",children:["Last sent ",new Date(s.last_invoice_resent_at).toLocaleString("en-CA")]})]})]})},`${s.id}-detail`)]},s.id)})})]})})}),j>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",p+1," of ",j," · ",q," records"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",onClick:()=>_(r=>Math.max(0,r-1)),disabled:p===0,className:"border-border/50",children:e.jsx(ge,{className:"w-4 h-4"})}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>_(r=>Math.min(j-1,r+1)),disabled:p>=j-1,className:"border-border/50",children:e.jsx(_e,{className:"w-4 h-4"})})]})]})]})}export{He 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.