PageSourceSearch

https://www.wrap-up.ai/assets/account-DcFXl8-o.js

js wrap-up.ai collected 2026-10-05 13:18:31 UTC 28,083 bytes, 6 lines download raw bytes

1import{c as X,r as l,v as Z,u as O,f as K,j as e}from"./index-B7Esrfq-.js";import{u as q}from"./useQuery-CLcE7GV6.js";import{u as E}from"./useMutation-GpyYneN8.js";import{C as m,a as u,b as p,c as g,d as C}from"./card-XS4BSNp9.js";import{B as y}from"./button-CL7L0UQ-.js";import{L as v,I as N}from"./input-MulFogVX.js";import{A as ee,b as se,a as te,C as ae}from"./alert-CZXufYcr.js";import{D as ie,a as ne,b as re,c as ce,d as le}from"./dialog-Dj_5dHm1.js";import{B as oe}from"./badge-NZjLZ7bf.js";import{F as de,S as J,D as me,f as $,W as ue,T as xe,a as he,b as B,c as W,d as pe,e as F}from"./format-DeZwkyKT.js";import{U as G,B as ge}from"./before-after-slider-AQfQn6KC.js";import{A as je}from"./arrow-left-bEzmlWAK.js";import{C as fe,I as ye,S as _}from"./star-ChMXZqUL.js";import{C as be}from"./chart-column-ClD8msdg.js";import{C as ve}from"./camera-D67Qvk0k.js";import{C as Ne}from"./circle-alert-Bk8t2Vfu.js";import{E as V}from"./external-link-WQa_svPf.js";import{D as Q}from"./download-CpOjbb9e.js";import{C as we}from"./check-CRrTjEJx.js";import{C as Ce}from"./clock-XiIy9VTl.js";import"./index-Ba_trOvd.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Se=X("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);async function f(s,c){const n=await fetch(s,{headers:{"Content-Type":"application/json"},credentials:"include",...c});if(!n.ok){const a=await n.json().catch(()=>({message:"Request failed"}));throw new Error(a.message||"Request failed")}return n.json()}function es(){const[s,c]=l.useState(()=>new URLSearchParams(window.location.search).get("tab")==="ambassador"?"ambassador":"profile"),[,n]=Z();O(),K();const{data:a,isLoading:b}=q({queryKey:["/api/account/profile"],queryFn:()=>f("/api/account/profile")});if(b)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});if(!a)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-background gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Please sign in to access your account."}),e.jsx(y,{onClick:()=>n("/"),children:"Go Home"})]});const S=[{id:"profile",label:"Profile & Contact",icon:G},{id:"billing",label:"Plan & Billing",icon:fe},{id:"usage",label:"Usage Stats",icon:be},{id:"designs",label:"My Designs",icon:ye},{id:"invoices",label:"Invoice Settings",icon:de},{id:"ambassador",label:"Ambassador",icon:_}];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"border-b bg-card",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center gap-4",children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>n("/"),children:[e.jsx(je,{className:"h-4 w-4 mr-2"})," Back"]}),e.jsx("h1",{className:"text-xl font-semibold",children:"My Account"})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-6 flex flex-col md:flex-row gap-6",children:[e.jsx("aside",{className:"w-full md:w-64 shrink-0",children:e.jsx(m,{children:e.jsx(u,{className:"p-2",children:S.map(x=>e.jsxs("button",{onClick:()=>c(x.id),className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-sm transition-colors ${s===x.id?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(x.icon,{className:"h-4 w-4"}),x.label]},x.id))})})}),e.jsxs("main",{className:"flex-1 min-w-0",children:[s==="profile"&&e.jsx(ke,{profile:a}),s==="billing"&&e.jsx(Pe,{profile:a}),s==="usage"&&e.jsx(De,{}),s==="designs"&&e.jsx(Le,{}),s==="invoices"&&e.jsx(Te,{profile:a}),s==="ambassador"&&e.jsx(Ie,{})]})]})]})}function ke({profile:s}){const{toast:c}=O(),n=K(),[a,b]=l.useState(s.firstName||""),[S,x]=l.useState(s.lastName||""),[k,o]=l.useState(s.email||""),[P,w]=l.useState(""),A=E({mutationFn:t=>f("/api/account/profile",{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/account/profile"]}),c({title:"Profile updated"})},onError:t=>c({title:"Error",description:t.message,variant:"destructive"})}),d=E({mutationFn:t=>f("/api/account/password",{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{w(""),c({title:"Password changed successfully"})},onError:t=>c({title:"Error",description:t.message,variant:"destructive"})}),T=E({mutationFn:t=>f("/api/account/profile-photo",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/account/profile"]}),c({title:"Photo updated"})},onError:t=>c({title:"Error",description:t.message,variant:"destructive"})}),D=t=>{var i;const L=(i=t.target.files)==null?void 0:i[0];if(!L)return;const U=new FileReader;U.onloadend=()=>{T.mutate({imageData:U.result})},U.readAsDataURL(L)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Profile"}),e.jsx(C,{children:"Manage your personal information"})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative",children:[s.profileImageUrl?e.jsx("img",{src:s.profileImageUrl,alt:"Profile",className:"w-20 h-20 rounded-full object-cover border",width:"80",height:"80"}):e.jsx("div",{className:"w-20 h-20 rounded-full bg-muted flex items-center justify-center border",children:e.jsx(G,{className:"h-8 w-8 text-muted-foreground"})}),e.jsxs("label",{className:"absolute bottom-0 right-0 bg-primary text-primary-foreground rounded-full p-1 cursor-pointer hover:bg-primary/90",children:[e.jsx(ve,{className:"h-3 w-3"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:D})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[s.firstName," ",s.lastName]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Member since ",new Date(s.createdAt).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"First Name"}),e.jsx(N,{value:a,onChange:t=>b(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Last Name"}),e.jsx(N,{value:S,onChange:t=>x(t.target.value)})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(v,{children:"Email"}),e.jsx(N,{value:k,onChange:t=>o(t.target.value),type:"email"})]})]}),e.jsxs(y,{onClick:()=>A.mutate({firstName:a,lastName:S,email:k}),disabled:A.isPending,children:[e.jsx(J,{className:"h-4 w-4 mr-2"})," Save Changes"]})]})]}),e.jsxs(m,{children:[e.jsx(p,{children:e.jsx(g,{children:"Change Password"})}),e.jsxs(u,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"New Password"}),e.jsx(N,{type:"password",value:P,onChange:t=>w(t.target.value),placeholder:"Min 6 characters"})]}),e.jsx(y,{onClick:()=>d.mutate({newPassword:P}),disabled:d.isPending||P.length<6,children:"Update Password"})]})]})]})}function Pe({profile:s}){const{toast:c}=O(),n=E({mutationFn:()=>f("/api/account/billing-portal",{method:"POST"}),onSuccess:b=>{window.open(b.url,"_blank")},onError:b=>c({title:"Error",description:b.message,variant:"destructive"})}),{data:a}=q({queryKey:["/api/account/usage-stats"],queryFn:()=>f("/api/account/usage-stats")});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Plan & Credits"}),e.jsx(C,{children:"Your current subscription and credit balance"})]}),e.jsxs(u,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-primary",children:(a==null?void 0:a.credits)??s.credits}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Credits Remaining"}),((a==null?void 0:a.subscriptionStatus)==="active"||((a==null?void 0:a.subscriptionCredits)??0)>0)&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[(a==null?void 0:a.subscriptionCredits)??0," monthly credits renew · ",(a==null?void 0:a.purchasedCredits)??0," extra credits you keep"]})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-lg font-semibold capitalize",children:(a==null?void 0:a.subscriptionStatus)||"No subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Status"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-lg font-semibold",children:(a==null?void 0:a.subscriptionCreditsTotal)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Monthly Credits"})]})]}),(a==null?void 0:a.subscriptionResetDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:[e.jsx(Se,{className:"h-3 w-3 inline mr-1"}),"Credits reset on ",new Date(a.subscriptionResetDate).toLocaleDateString()]})]})]}),e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Manage Billing"}),e.jsx(C,{children:"Update payment methods, view invoices, and manage your subscription via Stripe"})]}),e.jsxs(u,{children:[(a==null?void 0:a.cancelAtPeriodEnd)&&(a==null?void 0:a.subscriptionStatus)==="active"&&e.jsxs(ee,{className:"mb-4 border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Ne,{className:"h-4 w-4 !text-yellow-400"}),e.jsxs(se,{className:"text-yellow-200",children:["Subscription will end on ",a!=null&&a.cancelsAt?new Date(a.cancelsAt).toLocaleDateString():"end of current billing period"]}),e.jsx(te,{className:"text-yellow-100/90",children:"You'll keep full access until then. Open the billing portal to renew if you change your mind."})]}),e.jsxs(y,{onClick:()=>n.mutate(),disabled:n.isPending,children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),n.isPending?"Opening...":"Manage subscription"]}),!s.stripeCustomerId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"You need to make a purchase before you can access the billing portal."})]})]}),e.jsx(Ae,{})]})}function Ae(){const{data:s,isLoading:c}=q({queryKey:["/api/account/purchases"],queryFn:()=>f("/api/account/purchases")});return e.jsxs(m,{children:[e.jsx(p,{children:e.jsx(g,{children:"Purchase History"})}),e.jsx(u,{children:c?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading..."}):s!=null&&s.length?e.jsx("div",{className:"space-y-2",children:s.map(n=>e.jsxs("div",{className:"flex justify-between items-center py-2 border-b last:border-0",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium",children:[n.credits," credits"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(n.createdAt).toLocaleDateString()})]}),e.jsxs("p",{className:"font-medium",children:["$",(n.amountPaid/100).toFixed(2)]})]},n.id))}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"No purchases yet."})})]})}function De(){const{data:s,isLoading:c}=q({queryKey:["/api/account/usage-stats"],queryFn:()=>f("/api/account/usage-stats")});return c?e.jsx(m,{children:e.jsx(u,{className:"p-6",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading stats..."})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Usage Overview"}),e.jsx(C,{children:"Your activity summary"})]}),e.jsxs(u,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-primary",children:(s==null?void 0:s.credits)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Credits Left"}),((s==null?void 0:s.subscriptionStatus)==="active"||((s==null?void 0:s.subscriptionCredits)??0)>0)&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[(s==null?void 0:s.subscriptionCredits)??0," monthly credits renew · ",(s==null?void 0:s.purchasedCredits)??0," extra credits you keep"]})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:(s==null?void 0:s.designsGenerated)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Designs Created"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:(s==null?void 0:s.totalCreditsPurchased)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Credits Purchased"})]}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-center",children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",(((s==null?void 0:s.totalSpent)||0)/100).toFixed(0)]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Spent"})]})]}),(s==null?void 0:s.memberSince)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:["Member since ",new Date(s.memberSince).toLocaleDateString()]})]})]})})}function Le(){const[s,c]=l.useState([]),[n,a]=l.useState(null),[b,S]=l.useState(!0),[x,k]=l.useState(!1),[o,P]=l.useState(null),[w,A]=l.useState(!1),[d]=l.useState(()=>typeof window>"u"||!("IntersectionObserver"in window)?null:new IntersectionObserver((i,h)=>
6{i.forEach(j=>{if(j.isIntersecting){const I=j.target,r=I.dataset.src;r&&!I.src&&(I.src=r),h.unobserve(I)}})},{rootMargin:"100px"}));l.useEffect(()=>()=>d==null?void 0:d.disconnect(),[d]),l.useEffect(()=>{let i=!1;return(async()=>{try{const h=await f("/api/account/designs?limit=20&offset=0");if(i)return;c(Array.isArray(h==null?void 0:h.items)?h.items:[]),a(Number((h==null?void 0:h.total)??0))}catch{}finally{i||S(!1)}})(),()=>{i=!0}},[]);const T=l.useCallback(i=>{!i||!i.dataset.src||(d?d.observe(i):i.src=i.dataset.src)},[d]),D=async()=>{if(!x){k(!0);try{const i=await f(`/api/account/designs?limit=100&offset=${s.length}`),h=Array.isArray(i==null?void 0:i.items)?i.items:[];c(j=>[...j,...h]),a(Number((i==null?void 0:i.total)??n??0))}catch{}finally{k(!1)}}},t=(i,h)=>{const j=document.createElement("a");j.href=`/api/designs/${i}/image`,j.download=`wrap-design-${h||"custom"}.jpg`,document.body.appendChild(j),j.click(),document.body.removeChild(j)},L=()=>{P(null),A(!1)};if(b)return e.jsx(m,{children:e.jsx(u,{className:"p-6",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading designs..."})})});const U=n!==null&&s.length<n;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"My Designs"}),e.jsxs(C,{children:[n??0," designs generated"]})]}),e.jsx(u,{children:s.length===0?e.jsxs("div",{className:"text-sm text-muted-foreground space-y-3",children:[e.jsx("p",{children:"No designs yet. Generate your first wrap visualization on the home page."}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>window.location.assign("/"),children:"Go to home"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s.map(i=>{const h=`/api/designs/${i.id}/image`;return e.jsxs("div",{className:"group relative rounded-lg overflow-hidden border bg-muted cursor-pointer",onClick:()=>{P(i),A(!1)},children:[e.jsx("img",{ref:T,"data-src":h,alt:i.colorName||"Design",className:"w-full aspect-[4/3] object-cover bg-muted",width:"400",height:"300"}),e.jsxs("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center gap-2",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:i.colorName||"Custom Color"}),e.jsx("p",{className:"text-white/70 text-xs",children:new Date(i.createdAt).toLocaleDateString()}),e.jsxs(y,{size:"sm",variant:"secondary",onClick:j=>{j.stopPropagation(),t(i.id,i.colorName)},children:[e.jsx(Q,{className:"h-3 w-3 mr-1"})," Download"]})]})]},i.id)})}),U&&e.jsx("div",{className:"mt-6 text-center",children:e.jsx(y,{variant:"outline",onClick:D,disabled:x,children:x?"Loading...":"Load more"})})]})})]}),e.jsx(ie,{open:!!o,onOpenChange:i=>{i||L()},children:e.jsxs(ne,{className:"max-w-4xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:(o==null?void 0:o.colorName)||"Design"}),e.jsx(le,{children:o!=null&&o.createdAt?new Date(o.createdAt).toLocaleDateString():""})]}),o&&e.jsxs("div",{className:"space-y-3",children:[w&&o.hasOriginal?e.jsx(ge,{beforeImage:`/api/designs/${o.id}/original`,afterImage:`/api/designs/${o.id}/image`}):e.jsx("img",{src:`/api/designs/${o.id}/image`,alt:o.colorName||"Design",className:"w-full max-h-[70vh] object-contain rounded-lg"}),e.jsxs("div",{className:"flex gap-2",children:[o.hasOriginal&&e.jsx(y,{variant:"outline",size:"sm",onClick:()=>A(i=>!i),children:w?"Show render only":"Show before/after"}),e.jsxs(y,{size:"sm",onClick:()=>t(o.id,o.colorName),children:[e.jsx(Q,{className:"h-4 w-4 mr-1"})," Download"]})]})]})]})})]})}function Te({profile:s}){const{toast:c}=O(),n=K(),[a,b]=l.useState(s.companyName||""),[S,x]=l.useState(s.companyAddress||""),[k,o]=l.useState(s.vatNumber||""),[P,w]=l.useState(s.phone||""),[A,d]=l.useState(s.invoiceEmail||""),T=E({mutationFn:t=>f("/api/account/invoice-settings",{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/account/profile"]}),c({title:"Invoice settings saved"})},onError:t=>c({title:"Error",description:t.message,variant:"destructive"})}),D=E({mutationFn:()=>f("/api/account/billing-portal",{method:"POST"}),onSuccess:t=>{window.open(t.url,"_blank")},onError:t=>c({title:"Error",description:t.message,variant:"destructive"})});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Invoice Details"}),e.jsx(C,{children:"These details will appear on your invoices and PDF downloads"})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"Company Name"}),e.jsx(N,{value:a,onChange:t=>b(t.target.value),placeholder:"Your company name"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"VAT / Tax Number"}),e.jsx(N,{value:k,onChange:t=>o(t.target.value),placeholder:"e.g. NL123456789B01"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(v,{children:"Company Address"}),e.jsx(N,{value:S,onChange:t=>x(t.target.value),placeholder:"Street, City, Country"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Phone"}),e.jsx(N,{value:P,onChange:t=>w(t.target.value),placeholder:"+31 6 12345678"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Invoice Email"}),e.jsx(N,{value:A,onChange:t=>d(t.target.value),placeholder:"[email protected]",type:"email"})]})]}),e.jsxs(y,{onClick:()=>T.mutate({companyName:a,companyAddress:S,vatNumber:k,phone:P,invoiceEmail:A}),disabled:T.isPending,children:[e.jsx(J,{className:"h-4 w-4 mr-2"})," Save Invoice Settings"]})]})]}),e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{children:"Download Invoices"}),e.jsx(C,{children:"Access and download your invoices from the Stripe billing portal"})]}),e.jsxs(u,{children:[e.jsxs(y,{onClick:()=>D.mutate(),disabled:D.isPending,children:[e.jsx(V,{className:"h-4 w-4 mr-2"}
6),D.isPending?"Opening...":"View Invoices in Stripe Portal"]}),!s.stripeCustomerId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Invoices will be available after your first purchase."})]})]})]})}function Ie(){const{toast:s}=O(),c=K(),[n,a]=l.useState(""),[b,S]=l.useState(""),[x,k]=l.useState(""),[o,P]=l.useState(""),[w,A]=l.useState(""),{data:d,isLoading:T}=q({queryKey:["/api/influencer/status"],queryFn:()=>f("/api/influencer/status")}),D=(d==null?void 0:d.hasApplication)===!0&&d.status==="approved",{data:t,isLoading:L}=q({queryKey:["/api/ambassador/dashboard"],queryFn:()=>f("/api/ambassador/dashboard"),enabled:D}),[U,i]=l.useState(!1);function h(r){const R=`https://wrap-up.ai/?ref=${r}`;navigator.clipboard.writeText(R).then(()=>{i(!0),setTimeout(()=>i(!1),2e3),s({title:"Tracking link copied!"})},()=>{s({title:"Could not copy link",variant:"destructive"})})}const j=E({mutationFn:r=>f("/api/influencer/apply",{method:"POST",body:JSON.stringify(r)}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/influencer/status"]}
6),s({title:"Application submitted!",description:"We will review your application and get back to you."})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})}),I=E({mutationFn:()=>f("/api/influencer/withdraw",{method:"POST"}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/influencer/status"]}),s({title:"Application withdrawn",description:"You can now submit a new application."})},onError:r=>{s({title:"Error",description:r.message,variant:"destructive"})}});if(T)return e.jsx(m,{children:e.jsx(u,{className:"p-6",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})})});if(d!=null&&d.hasApplication&&d.status){const r=d.status,R={pending:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",approved:"bg-green-500/20 text-green-400 border-green-500/30",rejected:"bg-red-500/20 text-red-400 border-red-500/30"},z={pending:"Your application is being reviewed. We will contact you here in your account when we have made a decision.",approved:"Congratulations! You have been approved as a Wrap Up AI Ambassador!",rejected:"Unfortunately, your application was not approved at this time. Feel free to apply again in the future."};if(r==="approved"){const Y=(t==null?void 0:t.referral_handle)??null,H=Y?`https://wrap-up.ai/?ref=${Y}`:null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsxs(g,{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5"})," Ambassador Program"]}),e.jsx(C,{children:"Your dashboard"})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsx("div",{className:`inline-flex items-center px-3 py-1 rounded-full border text-sm font-medium ${R.approved}`,children:"Approved"}),e.jsx("p",{className:"text-muted-foreground",children:z.approved})]})]}),e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{className:"text-base",children:"Your tracking link"}),e.jsx(C,{children:"Share this link. New customers who sign up after clicking it earn you 20% commission on their first purchase."})]}),e.jsx(u,{children:Y&&H?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{readOnly:!0,value:H,className:"font-mono text-sm"}),e.jsx(y,{variant:"outline",size:"icon",onClick:()=>h(Y),"aria-label":"Copy tracking link",children:U?e.jsx(we,{className:"h-4 w-4"}):e.jsx(ae,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"Your tracking handle has not been set yet. Contact the team if you don’t see one within a day of approval."})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(m,{children:[e.jsxs(p,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(g,{className:"text-sm font-medium",children:"Total earned"}),e.jsx(me,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:L?"...":$(t==null?void 0:t.stats.total_cents)})})]}),e.jsxs(m,{children:[e.jsxs(p,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(g,{className:"text-sm font-medium",children:"Pending payout"}),e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:L?"...":$(t==null?void 0:t.stats.pending_cents)})})]}),e.jsxs(m,{children:[e.jsxs(p,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(g,{className:"text-sm font-medium",children:"Paid out"}),e.jsx(ue,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:L?"...":$(t==null?void 0:t.stats.paid_cents)})})]})]}),e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsx(g,{className:"text-base",children:"Recent commissions"}),e.jsx(C,{children:"Last 10 commissions earned from your referrals."})]}),e.jsx(u,{className:"p-0",children:e.jsxs(xe,{children:[e.jsx(he,{children:e.jsxs(B,{children:[e.jsx(W,{className:"w-32",children:"Date"}),e.jsx(W,{children:"Referred customer"}),e.jsx(W,{className:"w-28",children:"Amount"}),e.jsx(W,{className:"w-28",children:"Status"})]})}),e.jsx(pe,{children:L?e.jsx(B,{children:e.jsx(F,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):t!=null&&t.recent_commissions.length?t.recent_commissions.map(M=>e.jsxs(B,{children:[e.jsx(F,{className:"text-sm",children:new Date(M.created_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}),e.jsx(F,{className:"text-sm",children:M.referred_first_name??"—"}),e.jsx(F,{className:"text-sm font-medium",children:$(M.amount_cents)}),e.jsx(F,{children:e.jsx(oe,{variant:M.status==="paid"?"secondary":M.status==="voided"?"destructive":"default",children:M.status})})]},M.id)):e.jsx(B,{children:e.jsx(F,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No commissions yet. Share your tracking link to start earning."})})})]})})]})]})}return e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsxs(g,{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5"})," Ambassador Program"]}),e.jsx(C,{children:"Your application status"})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsx("div",{className:`inline-flex items-center px-3 py-1 rounded-full border text-sm font-medium ${R[r]||""}`,children:r.charAt(0).toUpperCase()+r.slice(1)}),e.jsx("p",{className:"text-muted-foreground",children:z[r]}),d.adminNotes&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Note from our team:"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.adminNotes})]}),r==="pending"&&e.jsx(y,{variant:"outline",className:"mt-4",onClick:()=>I.mutate(),disabled:I.isPending,children:I.isPending?"Withdrawing...":"Withdraw Application"})]})]})}return e.jsxs(m,{children:[e.jsxs(p,{children:[e.jsxs(g,{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5"})," Become an Ambassador"]}),e.jsx(C,{children:"Want to be an Ambassador for Wrap Up AI? Fill in the form below and tell us why you would be the perfect influencer. We will evaluate your application and contact you here in your account."})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"Instagram Page *"}),e.jsx(N,{value:n,onChange:r=>a(r.target.value),placeholder:"https://instagram.com/yourpage"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"TikTok (optional)"}),e.jsx(N,{value:b,onChange:r=>S(r.target.value),placeholder:"https://tiktok.com/@yourpage"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"YouTube (optional)"}),e.jsx(N,{value:x,onChange:r=>k(r.target.value),placeholder:"https://youtube.com/@yourchannel"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Other Social Media (optional)"}),e.jsx(N,{value:o,onChange:r=>P(r.target.value),placeholder:"Any other social media link"})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Why would you be a great ambassador? *"}),e.jsx("textarea",{className:"flex min-h-[120px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
6ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",value:w,onChange:r=>A(r.target.value),placeholder:"Tell us about yourself, your audience, and why you'd be a great ambassador for Wrap Up AI (minimum 50 characters)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[w.length,"/50 characters minimum"]})]}),e.jsx(y,{onClick:()=>j.mutate({instagramUrl:n,tiktokUrl:b,youtubeUrl:x,otherSocialUrl:o,motivation:w}),disabled:j.isPending||!n||w.length<50,children:j.isPending?"Submitting...":"Submit Application"})]})]})}export{es 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.