1import{r as c,t as v,J as r,i as gs,j as s,U as hs,B as i,a6 as Cs,b,c as y,a7 as js,s as fs,V as q,D as Ns,n as vs,m as bs,l as ys,a8 as Ss,K as ws,O as ks,X as Es,Y as Is,Z as Ts,_ as Ps,$ as Ds}from"./index-U8D282DB.js";import{I}from"./input-DFtjl8GZ.js";import{S as T,a as P,b as D,c as M,d as l}from"./select-DGSESBU1.js";import{B as $}from"./badge-BmpMbrZ9.js";import{L as S}from"./label-BdqAIGhN.js";import{u as Ms,d as $s}from"./exportCsv-BsEni7Me.js";import{Z as Bs}from"./zap-g43IWq9a.js";import{T as As}from"./trending-up-CHKjT34O.js";import{S as Fs}from"./search-C5_ObWCH.js";import{P as Os}from"./pen-DpCzNTWb.js";import{C as Ls}from"./calendar-plus-Cxhnc07h.js";import{A as Us}from"./arrow-up-down-c5CkM_cb.js";import"./useComposition-DGvQVl2f.js";import"./index-BdQq_4o_.js";import"./index-Dyyrzgm7.js";import"./check-fK4IDB-m.js";import"./chevron-up-B1n65gyY.js";const _={member:{label:"Member",color:"bg-gray-100 text-gray-700",icon:ys,credit:5},gold:{label:"Gold",color:"bg-yellow-100 text-yellow-700",icon:bs,credit:6},signature:{label:"Signature",color:"bg-purple-100 text-purple-700",icon:vs,credit:7},black_sapphire:{label:"Black Sapphire",color:"bg-gray-900 text-white",icon:Ns,credit:8}};function o(j){return j.toLocaleString("en-AU",{style:"currency",currency:"AUD",minimumFractionDigits:2})}function ae(){const[j,ss]=c.useState(""),[Y,es]=c.useState("");c.useEffect(()=>{const e=setTimeout(()=>es(j.trim()),350);return()=>clearTimeout(e)},[j]);const[w,ts]=c.useState("all"),[d,as]=c.useState("all"),[a,p]=c.useState(null),[B,G]=c.useState(""),[A,Q]=c.useState(""),[F,Z]=c.useState(""),[O,H]=c.useState(""),[L,J]=c.useState(""),[u,cs]=c.useState("lifetimeSpend"),[k,K]=c.useState("desc"),E=v.adminCustomers.list.useQuery({search:Y||void 0,role:w!=="all"?w:void 0,companyId:d==="none"?null:d!=="all"?parseInt(d):void 0}),ns=v.companies.list.useQuery(),U=v.adminCustomers.setTier.useMutation({onSuccess:()=>{r.success("Membership tier updated"),E.refetch(),p(null)},onError:e=>r.error(e.message)}),V=v.adminCustomers.setCompany.useMutation({onSuccess:()=>{r.success("Company assignment updated"),E.refetch(),p(null)},onError:e=>r.error(e.message)}),R=v.adminCustomers.updateDetails.useMutation({onSuccess:()=>{r.success("Customer details updated"),E.refetch(),p(null)},onError:e=>r.error(e.message)}),g=E.data||[],W=ns.data||[],m=c.useMemo(()=>[...g].sort((e,t)=>{let n,C;return u==="name"?(n=(e.name||"").toLowerCase(),C=(t.name||"").toLowerCase()):(n=e[u]??0,C=t[u]??0),n<C?k==="asc"?-1:1:n>C?k==="asc"?1:-1:0}),[g,u,k]),{totalCreditsOwing:rs,totalYtdSpend:is,totalLifetimeSpend:ls}=c.useMemo(()=>({totalCreditsOwing:g.reduce((e,t)=>e+(t.creditBalance||0),0),totalYtdSpend:g.reduce((e,t)=>e+(t.ytdSpend||0),0),totalLifetimeSpend:g.reduce((e,t)=>e+(t.lifetimeSpend||0),0)}),[g]),h=50,[x,z]=c.useState(0);c.useEffect(()=>{z(0)},[Y,w,d,u,k]);const X=Math.max(1,Math.ceil(m.length/h)),os=c.useMemo(()=>m.slice(x*h,(x+1)*h),[m,x]),ds=e=>{u===e?K(t=>t==="asc"?"desc":"asc"):(cs(e),K("desc"))},f=({field:e,children:t})=>s.jsx("th",{"data-loc":"client/src/pages/admin/Customers.tsx:101",className:"text-left p-3 font-medium cursor-pointer hover:bg-muted/70 select-none transition-colors",onClick:()=>ds(e),children:s.jsxs("span",{"data-loc":"client/src/pages/admin/Customers.tsx:105",className:"flex items-center gap-1",children:[t,s.jsx(Us,{"data-loc":"client/src/pages/admin/Customers.tsx:107",className:`h-3 w-3 ${u===e?"text-primary":"text-muted-foreground/40"}`})]})}),[,N]=gs(),ms=e=>{const t=new URLSearchParams;t.set("customerId",String(e.id)),t.set("customerName",e.name||""),t.set("customerEmail",e.email||""),t.set("customerPhone",e.phone||""),e.companyId&&(t.set("companyId",String(e.companyId)),e.company?.discountPercent&&t.set("discountPercent",e.company.discountPercent),e.company?.name&&t.set("companyName",e.company.name)),N(`/admin/bookings?${t.toString()}`)},xs=e=>{p(e),G(e.membershipTier||"member"),Q(e.companyId?String(e.companyId):"none"),Z(e.name||""),H(e.email||""),J(e.phone||"")},ps=()=>{if(!a)return;const e=B,t=A==="none"?null:parseInt(A),n=F!==(a.name||"")||O!==(a.email||"")||L!==(a.phone||"");n&&R.mutate({userId:a.id,name:F||void 0,email:O||void 0,phone:L||void 0}),e!==a.membershipTier&&U.mutate({userId:a.id,tier:e}),t!==a.companyId&&V.mutate({userId:a.id,companyId:t}),!n&&e===a.membershipTier&&t===a.companyId&&p(null)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:159",className:"space-y-6",children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:160",className:"flex items-center justify-between",children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:161",children:[s.jsxs("h1",{"data-loc":"client/src/pages/admin/Customers.tsx:162",className:"text-2xl font-bold flex items-center gap-2",children:[s.jsx(hs,{"data-loc":"client/src/pages/admin/Customers.tsx:162",className:"h-6 w-6"})," Customer Management"]}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:163",className:"text-muted-foreground mt-1",children:"Manage customers, assign companies, and set membership tiers"})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:165",className:"flex items-center gap-2",children:[s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:166",variant:"outline",size:"sm",onClick:async()=>{try{const e=await fetch("/api/trpc/exports.customers",{credentials:"include"}),t=await e.json();if(!e.ok)throw new Error(t?.error?.json?.message||"Export failed");const n=Ms(t);if(!n?.length)throw new Error("No customers returned to export");$s(n,"drive4u_customers"),r.success(`Exported ${n.length} customers`)}catch(e){r.error(e?.message||"Export failed")}},children:[s.jsx(Cs,{"data-loc":"client/src/pages/admin/Customers.tsx:179",className:"h-4 w-4 mr-1"})," Export CSV"]}),s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:181",variant:"outline",size:"sm",onClick:()=>{confirm("Run auto-tier check for all customers? This will upgrade eligible customers and send notification emails.")&&fetch("/api/trpc/tiers.autoCheckAll",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).then(e=>e.json()).then(e=>{const t=e?.result?.data;t?.total>0?(r.success(`${t.total} customer(s) upgraded!`),window.location.reload()):r.info("No tier upgrades needed at this time.")}).catch(()=>r.error("Auto-tier check failed"))},children:[s.jsx(Bs,{"data-loc":"client/src/pages/admin/Customers.tsx:194",className:"h-4 w-4 mr-1"})," Auto-Tier Check"]}),s.jsxs($,{"data-loc":"client/src/pages/admin/Customers.tsx:196",variant:"outline",className:"text-sm",children:[m.length," customers"]})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:201",className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(b,{"data-loc":"client/src/pages/admin/Customers.tsx:202",children:s.jsxs(y,{"data-loc":"client/src/pages/admin/Customers.tsx:203",className:"p-4 flex items-center gap-3",children:[s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:204",className:"p-2 rounded-lg bg-amber-100 text-amber-700",children:s.jsx(js,{"data-loc":"client/src/pages/admin/Customers.tsx:205",className:"h-5 w-5"})}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:207",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:208",className:"text-xs text-muted-foreground font-medium",children:"Total Credits Owing"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:209",className:"text-xl font-bold text-amber-700",children:o(rs)})]})]})}),s.jsx(b,{"data-loc":"client/src/pages/admin/Customers.tsx:213",children:s.jsxs(y,{"data-loc":"client/src/pages/admin/Customers.tsx:214",className:"p-4 flex items-center gap-3",children:[s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:215",className:"p-2 rounded-lg bg-blue-100 text-blue-700",children:s.jsx(As,{"data-loc":"client/src/pages/admin/Customers.tsx:216",className:"h-5 w-5"})}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:218",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:219",className:"text-xs text-muted-foreground font-medium",children:"YTD Customer Spend"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:220",className:"text-xl font-bold text-blue-700",children:o(is)})]})]})}),s.jsx(b,{"data-loc":"client/src/pages/admin/Customers.tsx:224",children:s.jsxs(y,{"data-loc":"client/src/pages/admin/Customers.tsx:225",className:"p-4 flex items-center gap-3",children:[s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:226",className:"p-2 rounded-lg bg-green-100 text-green-700",children:s.jsx(fs,{"data-loc":"client/src/pages/admin/Customers.tsx:227",className:"h-5 w-5"})}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:229",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:230",className:"text-xs text-muted-foreground font-medium",children:"Lifetime Customer Spend"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:231",className:"text-xl font-bold text-green-700",children:o(ls)})]})]})})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:238",className:"flex flex-wrap gap-3",children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:239",className:"relative flex-1 min-w-[200px]",children:[s.jsx(Fs,{"data-loc":"client/src/pages/admin/Customers.tsx:240",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),s.jsx(I,{"data-loc":"client/src/pages/admin/Customers.tsx:241",placeholder:"Search by name...",value:j,onChange:e=>ss(e.target.value),className:"pl-9"})]}),s.jsxs(T,{"data-loc":"client/src/pages/admin/Customers.tsx:243",value:w,onValueChange:ts,children:[s.jsx(P,{"data-loc":"client/src/pages/admin/Customers.tsx:244",className:"w-[140px]",children:s.jsx(D,{"data-loc":"client/src/pages/admin/Customers.tsx:244",placeholder:"Role"})}),s.jsxs(M,{"data-loc":"client/src/pages/admin/Customers.tsx:245",children:[s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:246",value:"all",children:"All Roles"}),s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:247",value:"user",children:"Customer"}),s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:248",value:"admin",children:"Admin"}),s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:249",value:"driver",children:"Driver"})]})]}),s.jsxs(T,{"data-loc":"client/src/pages/admin/Customers.tsx:252",value:d,onValueChange:as,children:[s.jsx(P,{"data-loc":"client/src/pages/admin/Customers.tsx:253",className:"w-[180px]",children:s.jsx(D,{"data-loc":"client/src/pages/admin/Customers.tsx:253",placeholder:"Company"})}),s.jsxs(M,{"data-loc":"client/src/pages/admin/Customers.tsx:254",children:[s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:255",value:"all",children:"All Companies"}),s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:256",value:"none",children:"No Company"}),W.map(e=>s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:257",value:String(e.id),children:e.name},e.id))]})]}),d!=="all"&&d!=="none"&&s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:261",variant:"outline",size:"sm",onClick:()=>N(`/admin/companies/${d}/bookings`),children:[s.jsx(q,{"data-loc":"client/src/pages/admin/Customers.tsx:262",className:"h-4 w-4 mr-1"})," View Company Bookings"]})]}),s.jsx(b,{"data-loc":"client/src/pages/admin/Customers.tsx:268",children:s.jsx(y,{"data-loc":"client/src/pages/admin/Customers.tsx:269",className:"p-0",children:s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:270",className:"overflow-x-auto",children:[s.jsxs("table",{"data-loc":"client/src/pages/admin/Customers.tsx:271",className:"w-full text-sm",children:[s.jsx("thead",{"data-loc":"client/src/pages/admin/Customers.tsx:272",children:s.jsxs("tr",{"data-loc":"client/src/pages/admin/Customers.tsx:273",className:"border-b bg-muted/50",children:[s.jsx(f,{"data-loc":"client/src/pages/admin/Customers.tsx:274",field:"name",children:"Customer"}),s.jsx("th",{"data-loc":"client/src/pages/admin/Customers.tsx:275",className:"text-left p-3 font-medium",children:"Company"}),s.jsx("th",{"data-loc":"client/src/pages/admin/Customers.tsx:276",className:"text-left p-3 font-medium",children:"Tier"}),s.jsx(f,{"data-loc":"client/src/pages/admin/Customers.tsx:277",field:"creditBalance",children:"Credits Owing"}),s.jsx(f,{"data-loc":"client/src/pages/admin/Customers.tsx:278",field:"ytdSpend",children:"YTD Spend"}),s.jsx(f,{"data-loc":"client/src/pages/admin/Customers.tsx:279",field:"lifetimeSpend",children:"Lifetime Spend"}),s.jsx(f,{"data-loc":"client/src/pages/admin/Customers.tsx:280",field:"totalBookings",children:"Bookings"}),s.jsx("th",{"data-loc":"client/src/pages/admin/Customers.tsx:281",className:"text-left p-3 font-medium",children:"Actions"})]})}),s.jsx("tbody",{"data-loc":"client/src/pages/admin/Customers.tsx:284",children:m.length===0?s.jsx("tr",{"data-loc":"client/src/pages/admin/Customers.tsx:286",children:s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:286",colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No customers found"})}):os.map((e,t)=>{const n=_[e.membershipTier||"member"],C=n.icon;return s.jsxs("tr",{"data-loc":"client/src/pages/admin/Customers.tsx:291",className:"border-b hover:bg-muted/30 transition-colors",children:[s.jsxs("td",{"data-loc":"client/src/pages/admin/Customers.tsx:292",className:"p-3",children:[s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:293",className:"font-medium cursor-pointer hover:text-primary transition-colors",onClick:()=>e.name&&N(`/admin/customers/${encodeURIComponent(e.name)}
1`),children:e.name||"â"}),s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:294",className:"text-xs text-muted-foreground",children:e.email||"â"})]}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:296",className:"p-3",children:e.company?s.jsxs($,{"data-loc":"client/src/pages/admin/Customers.tsx:298",variant:"outline",className:"gap-1 cursor-pointer hover:bg-primary/10 transition-colors",onClick:us=>{us.stopPropagation(),N(`/admin/companies/${e.company.id}/bookings`)},children:[s.jsx(q,{"data-loc":"client/src/pages/admin/Customers.tsx:299",className:"h-3 w-3"}),e.company.name,parseFloat(e.company.discountPercent)>0&&s.jsxs("span",{"data-loc":"client/src/pages/admin/Customers.tsx:300",className:"text-green-600 ml-1",children:["-",e.company.discountPercent,"%"]})]}):s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:302",className:"text-muted-foreground text-xs",children:"â"})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:304",className:"p-3",children:s.jsxs($,{"data-loc":"client/src/pages/admin/Customers.tsx:305",className:`gap-1 ${n.color}`,children:[s.jsx(C,{"data-loc":"client/src/pages/admin/Customers.tsx:305",className:"h-3 w-3"}),n.label]})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:307",className:"p-3",children:e.creditBalance>0?s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:309",className:"font-semibold text-amber-700",children:o(e.creditBalance)}):s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:311",className:"text-muted-foreground",children:"$0.00"})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:314",className:"p-3",children:e.ytdSpend>0?s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:316",className:"font-medium",children:o(e.ytdSpend)}):s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:318",className:"text-muted-foreground",children:"$0.00"})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:321",className:"p-3",children:e.lifetimeSpend>0?s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:323",className:"font-semibold text-green-700",children:o(e.lifetimeSpend)}):s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:325",className:"text-muted-foreground",children:"$0.00"})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:328",className:"p-3 text-center",children:s.jsx("span",{"data-loc":"client/src/pages/admin/Customers.tsx:329",className:"font-medium",children:e.totalBookings||0})}),s.jsx("td",{"data-loc":"client/src/pages/admin/Customers.tsx:331",className:"p-3",children:s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:332",className:"flex gap-1",children:[s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:333",variant:"ghost",size:"sm",onClick:()=>e.name&&N(`/admin/customers/${encodeURIComponent(e.name)}`),children:[s.jsx(Ss,{"data-loc":"client/src/pages/admin/Customers.tsx:334",className:"h-4 w-4 mr-1"})," View"]}),s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:336",variant:"ghost",size:"sm",onClick:()=>xs(e),children:[s.jsx(Os,{"data-loc":"client/src/pages/admin/Customers.tsx:337",className:"h-4 w-4 mr-1"})," Edit"]}),s.jsxs(i,{"data-loc":"client/src/pages/admin/Customers.tsx:339",variant:"ghost",size:"sm",className:"text-primary",onClick:()=>ms(e),children:[s.jsx(Ls,{"data-loc":"client/src/pages/admin/Customers.tsx:340",className:"h-4 w-4 mr-1"})," Book"]})]})})]},`${e.name}-${e.email}-${t}`)})})]}),m.length>h&&s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:350",className:"flex items-center justify-between px-3 py-3 border-t",children:[s.jsxs("span",{"data-loc":"client/src/pages/admin/Customers.tsx:351",className:"text-sm text-muted-foreground",children:["Showing ",x*h+1,"â",Math.min((x+1)*h,m.length)," of ",m.length," customers"]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:354",className:"flex items-center gap-2",children:[s.jsx(i,{"data-loc":"client/src/pages/admin/Customers.tsx:355",variant:"outline",size:"sm",disabled:x===0,onClick:()=>z(e=>Math.max(0,e-1)),children:"Previous"}),s.jsxs("span",{"data-loc":"client/src/pages/admin/Customers.tsx:358",className:"text-sm text-muted-foreground",children:["Page ",x+1," of ",X]}),s.jsx(i,{"data-loc":"client/src/pages/admin/Customers.tsx:359",variant:"outline",size:"sm",disabled:x+1>=X,onClick:()=>z(e=>e+1),children:"Next"})]})]})]})})}),s.jsxs(b,{"data-loc":"client/src/pages/admin/Customers.tsx:370",children:[s.jsx(ws,{"data-loc":"client/src/pages/admin/Customers.tsx:371",children:s.jsx(ks,{"data-loc":"client/src/pages/admin/Customers.tsx:371",className:"text-sm",children:"Membership Tiers"})}),s.jsxs(y,{"data-loc":"client/src/pages/admin/Customers.tsx:372",children:[s.jsx("div",{"data-loc":"client/src/pages/admin/Customers.tsx:373",className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(_).map(([e,t])=>{const n=t.icon;return s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:377",className:"flex items-center gap-2 p-2 rounded-lg border",children:[s.jsxs($,{"data-loc":"client/src/pages/admin/Customers.tsx:378",className:t.color,children:[s.jsx(n,{"data-loc":"client/src/pages/admin/Customers.tsx:378",className:"h-3 w-3 mr-1"}),t.label]}),s.jsxs("span",{"data-loc":"client/src/pages/admin/Customers.tsx:379",className:"text-xs text-muted-foreground",children:[t.credit,"% credits"]})]},e)})}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:384",className:"text-xs text-muted-foreground mt-2",children:"Member: <$1,000/yr | Gold: $2,500/yr | Signature: $5,000/yr | Black Sapphire: Invite Only"})]})]})]}),s.jsx(Es,{"data-loc":"client/src/pages/admin/Customers.tsx:392",open:!!a,onOpenChange:e=>!e&&p(null),children:s.jsxs(Is,{"data-loc":"client/src/pages/admin/Customers.tsx:393",className:"max-w-md",children:[s.jsx(Ts,{"data-loc":"client/src/pages/admin/Customers.tsx:394",children:s.jsxs(Ps,{"data-loc":"client/src/pages/admin/Customers.tsx:395",children:["Edit Customer: ",a?.name||a?.email||"Unknown"]})}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:397",className:"space-y-4 py-4",children:[a&&s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:400",className:"grid grid-cols-3 gap-2 p-3 bg-muted/50 rounded-lg",children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:401",className:"text-center",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:402",className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Credits"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:403",className:"text-sm font-bold text-amber-700",children:o(a.creditBalance||0)})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:405",className:"text-center border-x",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:406",className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"YTD Spend"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:407",className:"text-sm font-bold",children:o(a.ytdSpend||0)})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:409",className:"text-center",children:[s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:410",className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Lifetime"}),s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:411",className:"text-sm font-bold text-green-700",children:o(a.lifetimeSpend||0)})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:416",children:[s.jsx(S,{"data-loc":"client/src/pages/admin/Customers.tsx:417",children:"Full Name"}),s.jsx(I,{"data-loc":"client/src/pages/admin/Customers.tsx:418",className:"mt-1",value:F,onChange:e=>Z(e.target.value),placeholder:"Customer name"})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:420",className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:421",children:[s.jsx(S,{"data-loc":"client/src/pages/admin/Customers.tsx:422",children:"Email"}),s.jsx(I,{"data-loc":"client/src/pages/admin/Customers.tsx:423",className:"mt-1",type:"email",value:O,onChange:e=>H(e.target.value),placeholder:"Email address"})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:425",children:[s.jsx(S,{"data-loc":"client/src/pages/admin/Customers.tsx:426",children:"Phone"}),s.jsx(I,{"data-loc":"client/src/pages/admin/Customers.tsx:427",className:"mt-1",value:L,onChange:e=>J(e.target.value),placeholder:"Phone number"})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:430",children:[s.jsx(S,{"data-loc":"client/src/pages/admin/Customers.tsx:431",children:"Company Assignment"}),s.jsxs(T,{"data-loc":"client/src/pages/admin/Customers.tsx:432",value:A,onValueChange:Q,children:[s.jsx(P,{"data-loc":"client/src/pages/admin/Customers.tsx:433",className:"mt-1",children:s.jsx(D,{"data-loc":"client/src/pages/admin/Customers.tsx:433",placeholder:"Select company"})}),s.jsxs(M,{"data-loc":"client/src/pages/admin/Customers.tsx:434",children:[s.jsx(l,{"data-loc":"client/src/pages/admin/Customers.tsx:435",value:"none",children:"No Company"}),W.map(e=>s.jsxs(l,{"data-loc":"client/src/pages/admin/Customers.tsx:437",value:String(e.id),children:[e.name," ",parseFloat(e.discountPercent)>0&&`(${e.discountPercent}% discount)`]},e.id))]})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/admin/Customers.tsx:444",children:[s.jsx(S,{"data-loc":"client/src/pages/admin/Customers.tsx:445",children:"Membership Tier"}),s.jsxs(T,{"data-loc":"client/src/pages/admin/Customers.tsx:446",value:
1B,onValueChange:G,children:[s.jsx(P,{"data-loc":"client/src/pages/admin/Customers.tsx:447",className:"mt-1",children:s.jsx(D,{"data-loc":"client/src/pages/admin/Customers.tsx:447"})}),s.jsx(M,{"data-loc":"client/src/pages/admin/Customers.tsx:448",children:Object.entries(_).map(([e,t])=>s.jsxs(l,{"data-loc":"client/src/pages/admin/Customers.tsx:450",value:e,children:[t.label," (",t.credit,"% credits)",e==="black_sapphire"?" â Invite Only":""]},e))})]}),B==="black_sapphire"&&s.jsx("p",{"data-loc":"client/src/pages/admin/Customers.tsx:457",className:"text-xs text-amber-600 mt-1",children:"Black Sapphire is invite-only and will not auto-downgrade based on spend."})]})]}),s.jsxs(Ds,{"data-loc":"client/src/pages/admin/Customers.tsx:461",children:[s.jsx(i,{"data-loc":"client/src/pages/admin/Customers.tsx:462",variant:"outline",onClick:()=>p(null),children:"Cancel"}),s.jsx(i,{"data-loc":"client/src/pages/admin/Customers.tsx:463",onClick:ps,disabled:U.isPending||V.isPending||R.isPending,children:U.isPending||V.isPending||R.isPending?"Saving...":"Save Changes"})]})]})})]})}export{ae 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.