1import{D as y,b as v,r as p,f as w,i as C,j as e,o as h,g as x,G as S,I as u,B as T,aO as D}from"./index-QiiZ-xPT.js";import{C as n,b as c,c as i,d as m,a as j}from"./card-DkXabqFf.js";import{L as g}from"./label-BA9Xin3m.js";import{u as E}from"./useTranslation-XedzLvcK.js";import{C as F}from"./circle-check-BOGFOgJv.js";import{T as P}from"./trophy-DJhYgmDN.js";import{U as q}from"./users-JkJLChox.js";function I(){const{t:s}=E(),{token:a}=y();v();const[l,N]=p.useState(""),[d,f]=p.useState(""),{data:t,isLoading:b,error:k}=w({queryKey:["sponsorship",a],queryFn:async()=>{const r=await fetch(`/api/sponsorship/token/${a}`);if(!r.ok)throw new Error("Sponsorship not found");return r.json()},enabled:!!a}),o=C({mutationFn:async()=>(await D("POST","/api/sponsorship/checkout",{sponsorshipToken:a,sponsorEmail:l,sponsorName:d})).json(),onSuccess:r=>{r.url&&(window.location.href=r.url)}});return b?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-blue-50","data-testid":"loading-spinner",children:e.jsx(h,{className:"h-8 w-8 animate-spin text-primary"})}):k||!t?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-blue-50",children:e.jsx(n,{className:"max-w-md",children:e.jsxs(c,{children:[e.jsx(i,{children:s("sponsor.checkout.notFoundTitle")}),e.jsx(m,{children:s("sponsor.checkout.notFoundDescription")})]})})}):t.status!=="pending"?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-green-50 to-emerald-50",children:e.jsx(n,{className:"max-w-md",children:e.jsxs(c,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-green-100 flex items-center justify-center",children:e.jsx(F,{className:"h-10 w-10 text-green-600"})}),e.jsx(i,{children:s("sponsor.checkout.alreadySponsoredTitle")}),e.jsx(m,{children:s("sponsor.checkout.alreadySponsoredDescription",{name:t.sponseeName})})]})})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 py-12 px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-primary/10 rounded-full mb-4",children:e.jsx(x,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2","data-testid":"page-title",children:s("sponsor.checkout.pageTitle",{name:t.sponseeName})}),e.jsx("p",{className:"text-gray-600 max-w-xl mx-auto",children:s("sponsor.checkout.pageSubtitle",{name:t.sponseeName})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-8",children:[e.jsxs(n,{className:"order-2 md:order-1",children:[e.jsx(c,{children:e.jsx(i,{children:s("sponsor.checkout.whatProvides")})}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 rounded-lg shrink-0",children:e.jsx(S,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s("sponsor.checkout.learningModulesTitle")}),e.jsx("p",{className:"text-sm text-gray-600",children:s("sponsor.checkout.learningModulesDesc")})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-100 rounded-lg shrink-0",children:e.jsx(P,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s("sponsor.checkout.progressReportsTitle")}),e.jsx("p",{className:"text-sm text-gray-600",children:s("sponsor.checkout.progressReportsDesc")})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-amber-100 rounded-lg shrink-0",children:e.jsx(q,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:s("sponsor.checkout.communityAccessTitle")}),e.jsx("p",{className:"text-sm text-gray-600",children:s("sponsor.checkout.communityAccessDesc")})]})]}),e.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-amber-50 to-yellow-50 rounded-lg border border-amber-200",children:e.jsxs("p",{className:"text-sm text-amber-800",children:[e.jsx("strong",{children:s("sponsor.checkout.taxBenefit")})," ",s("sponsor.checkout.taxBenefitDesc")]})})]})]}),e.jsxs(n,{className:"order-1 md:order-2",children:[e.jsxs(c,{children:[e.jsx(i,{children:s("sponsor.checkout.completeSponsorship")}),e.jsx(m,{children:s("sponsor.checkout.priceDescription")})]}),e.jsx(j,{children:e.jsxs("form",{onSubmit:r=>{r.preventDefault(),o.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"sponsor-name",children:s("sponsor.checkout.yourName")}),e.jsx(u,{id:"sponsor-name","data-testid":"input-sponsor-name",placeholder:s("sponsor.checkout.yourNamePlaceholder"),value:d,onChange:r=>f(r.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"sponsor-email",children:s("sponsor.checkout.yourEmail")}),e.jsx(u,{id:"sponsor-email","data-testid":"input-sponsor-email",type:"email",placeholder:s("sponsor.checkout.yourEmailPlaceholder"),value:l,onCh
1ange:r=>N(r.target.value),required:!0}),e.jsx("p",{className:"text-xs text-gray-500",children:s("sponsor.checkout.emailHelp")})]}),e.jsx("div",{className:"pt-4",children:e.jsx(T,{type:"submit",className:"w-full",size:"lg","data-testid":"button-checkout",disabled:o.isPending||!l||!d,children:o.isPending?e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"mr-2 h-4 w-4 animate-spin"}),s("sponsor.checkout.processing")]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"mr-2 h-4 w-4"}),s("sponsor.checkout.sponsorButton",{name:t.sponseeName})]})})}),o.isError&&e.jsx("p",{className:"text-sm text-red-600","data-testid":"error-message",children:s("sponsor.checkout.checkoutError")}),e.jsx("p",{className:"text-xs text-center text-gray-500 pt-2",children:s("sponsor.checkout.securePayment")})]})})]})]})]})})}export{I 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.