1import{g as R,i as U,a as V,r as a,j as e,I as $,B as P,s as H}from"./index-DuDy-C7E.js";import{C as l,a as c,b as v,c as N}from"./card-D-PGMmUQ.js";import{L as q}from"./label-z-eHHwqe.js";import{S as J,P as Q}from"./PaymentForm-Cj_R9lw0.js";import{W as X}from"./WhitelabelFooter-CDzm01h5.js";import{C as T}from"./circle-alert-CWipkNuB.js";import{C as A}from"./circle-check-big-CJqUkAVV.js";import{T as D}from"./tag-CDQCOUhu.js";import"./react-stripe.esm-DE25JpEI.js";const ae=()=>{const{toast:o}=R(),y=U(),h=V(),[f,F]=a.useState(""),[w,B]=a.useState(!0),[s,L]=a.useState(null),[C,W]=a.useState(""),[j,k]=a.useState(""),[p,S]=a.useState(!1),[E,b]=a.useState(0);a.useEffect(()=>{(async()=>{try{const{packageType:t,scanSubmissionId:i,packageName:m,amount:x,employeeCount:u}=y.state||{};if(console.log("Whitelabel checkout initialization:",{packageType:t,scanSubmissionId:i,packageName:m,amount:x,employeeCount:u}),!t||!i)throw new Error("Geen betalingsinformatie gevonden");L({packageType:t,packageName:m,amount:x,employeeCount:u}),b(x||d(t)),console.log("Creating whitelabel payment intent for:",{packageType:t,scanSubmissionId:i,employeeCount:u});const{data:r,error:g}=await H.functions.invoke("create-payment-intent",{body:{packageType:t,scanSubmissionId:i,employeeCount:u,customAmount:x}});if(console.log("Whitelabel payment intent response:",r),console.log("Whitelabel payment intent error:",g),g)throw console.error("Payment intent error:",g),new Error(`Betaling fout: ${g.message}`);if(!r)throw new Error("Geen response ontvangen van payment service");if(r.error)throw console.error("Payment service error:",r.error),new Error(r.error);if(r!=null&&r.client_secret)console.log("Setting client secret:",r.client_secret),F(r.client_secret);else throw console.error("No client secret in response:",r),new Error("Geen client secret ontvangen")}catch(t){console.error("Whitelabel payment initialization error:",t);const i=t instanceof Error?t.message:"Er ging iets mis bij het initialiseren van de betaling";W(i),o({title:"Fout bij betaling",description:i,variant:"destructive"})}finally{B(!1)}})()},[y.state,h,o]);const d=n=>{switch(n){case"basic":return 24900;case"full":return 44900;case"scan360":return 99900;default:return 0}},_=()=>{const n=j.toLowerCase().trim();if(["premium20","smartadapt20"].includes(n)){const i=(s==null?void 0:s.amount)||d(s==null?void 0:s.packageType),m=Math.round(i*.8);b(m),S(!0),o({title:"Kortingscode toegepast!",description:"20% korting is verrekend in de prijs."})}else o({title:"Ongeldige kortingscode",description:"De ingevoerde kortingscode is niet geldig.",variant:"destructive"})},z=()=>{const n=(s==null?void 0:s.amount)||d(s==null?void 0:s.packageType);b(n),S(!1),k(""),o({title:"Korting verwijderd",description:"De oorspronkelijke prijs is hersteld."})},M=()=>{console.log("Whitelabel payment success callback triggered"),h("/payment-success")},K=()=>{if(E)return`â¬${(E/100).toLocaleString("nl-NL",{minimumFractionDigits:2,maximumFractionDigits:2})}`;switch(s==null?void 0:s.packageType){case"basic":return"â¬249,00";case"full":return"â¬449,00";case"scan360":return"â¬999,00";default:return""}},O=()=>`â¬${(((s==null?void 0:s.amount)||d(s==null?void 0:s.packageType))/100).toLocaleString("nl-NL",{minimumFractionDigits:2,maximumFractionDigits:2})}`,G=()=>s!=null&&s.employeeCount&&{under_10:"< 10 medewerkers",under_25:"< 25 medewerkers",under_50:"< 50 medewerkers",under_100:"< 100 medewerkers",over_100:"> 100 medewerkers"}[s.employeeCount]||"";return w?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-muted/30 to-accent/10",children:e.jsx("main",{className:"py-20 px-4",children:e.jsx("div",{className:"container mx-auto max-w-2xl text-center",children:e.jsx("p",{children:"Betalingspagina laden..."})})})}):C?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-muted/30 to-accent/10",children:e.jsx("main",{className:"py-20 px-4",children:e.jsx("div",{className:"container mx-auto max-w-2xl",children:e.jsx(l,{children:e.jsxs(c,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-600 mb-4",children:[e.jsx(T,{className:"w-5 h-5"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Fout bij laden van betaling"})]}),e.jsx("p",{className:"text-muted-foreground mb-4",children:C}),e.jsx("button",{onClick:()=>h("/whitelabel-options"),className:"bg-primary text-primary-foreground px-4 py-2 rounded hover:bg-primary/90",children:"Terug naar scan opties"})]})})})})}):f?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-background via-muted/30 to-accent/10",children:[e.jsx("main",{className:"py-20 px-4",children:e.jsxs("div",{className:"container mx-auto max-w-2xl",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Betaling voltooien"}),e.jsx("p",{className:"text-muted-foreground",children:"Voer je betalingsgegevens in om je whitelabel scan te bestellen. Na de betaling ontvang je van ons een factuur voor je administratie."})]}),e.jsxs("div",{className:"grid gap-8",children:[e.jsxs(l,{children:[e.jsx(v,{children:e.jsxs(N,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5 text-green-500"}),"Bestelling overzicht"]})}),e.jsx(c,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:(s==null?void 0:s.packageName)||"Scan pakket"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(s==null?void 0:s.packageType)==="basic"&&"Basis analyse van je website",(s==null?void 0:s.packageType)==="full"&&"Uitgebreide analyse van je employer brand",(s==null?void 0:s.packageType)==="scan360"&&e.jsxs(e.Fragment,{children:["Complete 360° analyse met adviesgesprek",(s==null?void 0:s.employeeCount)&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Medewerkersonderzoek: ",G()]})]})]}),p&&e.jsxs("p",{className:"text-sm text-green-600 mt-2",children:[e.jsx(D,{className:"w-4 h-4 inline mr-1"}),"20% korting toegepast (PREMIUM20)"]})]}),e.jsxs("div",{className:"text-right",children:[p&&e.jsx("p",{className:"text-sm text-muted-foreground line-through",children:O()}),e.jsx("p",{className:"text-xl font-bold",children:K()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"excl. btw"})]})]})})]}),e.jsxs(l,{children:[e.jsx(v,{children:e.jsxs(N,{className:"flex items-center gap-2",children:[e.jsx(D,{className:"w-5 h-5"}),"Kortingscode"]})}),e.jsx(c,{children:p?e.jsxs("div",{className:"flex items-center justify-between bg-green-50 p-4 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-700",children:[e.jsx(A,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Kortingscode PREMIUM20 toegepast"})]}),e.jsx(P,{onClick:z,variant:"ghost",size:"sm",className:"text-green-700 hover:text-green-800",children:"Verwijderen"})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(q,{htmlFor:"discount-code",children:"Kortingscode"}),e.jsx($,{id:"discount-code",type:"text",placeholder:"Voer je kortingscode in",value:j,onChange:n=>k(n.target.value)})]}),e.jsx("div",{className:"flex items-end",children:e.jsx(P,{onClick:_,disabled:!j.trim(),variant:"outline",children:"Toepassen"})})]})})]}),e.jsxs(l,{children:[e.jsx(v,{children:e.jsx(N,{children:"Betalingsgegevens"})}),e.jsx(c,{children:e.jsx(J,{clientSecret:f,children:e.jsx(Q,{onSuccess:M,isLoading:w})})})]})]})]})}),e.jsx(X,{})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-muted/30 to-accent/10",children:e.jsx("main",{className:"py-20 px-4",children:e.jsx("div",{className:"container mx-auto max-w-2xl",children:e.jsx(l,{children:e.jsxs(c,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 mb-4",children:[e.jsx(T,{className:"w-5 h-5"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Betalingsinformatie wordt geladen"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Een moment geduld..."})]})})})})})};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.