1import{u as f,r as a,q as p,j as e,C as o,g as i,h as r,B as d,y as j}from"./index-CbnhyKOh.js";function N(){const[u]=f(),[m,l]=a.useState(!0),[s,x]=a.useState(null),[n,h]=a.useState(null);return a.useEffect(()=>{const c=new URLSearchParams(window.location.search).get("session_id");if(!c){l(!1);return}fetch(`/api/stripe/session/${c}`,{credentials:"include"}).then(t=>{if(!t.ok)throw new Error("Failed to fetch purchase details");return t.json()}).then(t=>{x(t),l(!1),p.invalidateQueries({queryKey:["/api/auth/user"]})}).catch(t=>{console.error("Error fetching purchase details:",t),h(t.message||"Failed to load purchase details"),l(!1)})},[u]),m?e.jsxs("div",{className:"max-w-2xl mx-auto py-16 px-4 text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Processing your purchase..."})]}):n||!s?e.jsx("div",{className:"max-w-2xl mx-auto py-16 px-4",children:e.jsx(o,{children:e.jsxs(i,{className:"pt-8 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4","data-testid":"text-error-title",children:"Unable to Load Purchase Details"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:n||"Something went wrong while loading your purchase information."}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Don't worry - your payment was processed successfully. Please check your email for a receipt or contact support if you need assistance."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsx(r,{href:"/customer/images",children:e.jsx(d,{className:"w-full sm:w-auto","data-testid":"button-go-dashboard",children:"Go to Dashboard"})}),e.jsx(r,{href:"/customer/credits",children:e.jsx(d,{variant:"secondary",className:"w-full sm:w-auto","data-testid":"button-buy-more",children:"Buy More Credits"})})]})]})})}):e.jsx("div",{className:"max-w-2xl mx-auto py-16 px-4",children:e.jsx(o,{children:e.jsxs(i,{className:"pt-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(j,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h1",{className:"text-3xl font-bold mb-2","data-testid":"text-success-title",children:"Purchase Complete!"}),s&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground mb-6",children:"Thank you for your purchase!"}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-6 mb-6",children:[e.jsxs("p",{className:"text-4xl font-bold text-blue-600 dark:text-blue-400 mb-2","data-testid":"text-credits-added",children:["+",s.credits]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"credits added to your account"})]}),e.jsxs("div",{className:"text-left bg-muted rounded-lg p-4 mb-6 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Package:"}),e.jsx("span",{className:"font-medium","data-testid":"text-package-name",children:s.packageName})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Amount Paid:"}),e.jsxs("span",{className:"font-medium","data-testid":"text-amount-paid",children:["$",s.amount.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"New Balance:"}),e.jsxs("span",{className:"font-semibold text-blue-600 dark:text-blue-400","data-testid":"text-new-balance",children:[s.newBalance," credits"]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Receipt sent to ",s.email]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsx(r,{href:"/customer/images",children:e.jsx(d,{className:"w-full sm:w-auto","data-testid":"button-upload-images",children:"Upload Images"})}),e.jsx(r,{href:"/customer/dashboard",children:e.jsx(d,{variant:"secondary",className:"w-full sm:w-auto","data-testid":"button-view-dashboard",children:"View Dashboard"})})]})]})})})}export{N 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.