"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[476],{476:(e,a,r)=>{r.r(a),r.d(a,{default:()=>d});var t=r(95155),o=r(12115),n=r(25683),s=r(90447),l=r(17506),c=r(80391),i=r(76046),u=r(34194);let m=(0,l.c)("pk_test_51QsHUPQRiToRp4EyOHg0zluMns7NRtQLOoQUGbGVfGMhcB0ZcsJXLssLHEfStNUgmd2lhaXULMLqViaALGki5pLc00lIQIT9Is");function d(e){let{isOpen:a,onClose:r}=e,[l,d]=(0,o.useState)({name:"",email:"",message:"",amount:"",currency:"NGN"}),[p,f]=(0,o.useState)(!1),g=(0,i.useRouter)(),h=e=>{d(a=>({...a,[e.target.name]:e.target.value}))},b=async()=>{try{let e=await fetch("/api/initialize-paystack",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:l.email,amount:parseFloat(l.amount),name:l.name})}),{data:a}=await e.json();localStorage.setItem("giftData",JSON.stringify({name:l.name,email:l.email,message:l.message,amount:parseFloat(l.amount),currency:l.currency})),new c.A().newTransaction({key:"pk_test_1155f5be5dddcfa3b61dd8e476ec35f6497847ec",ref:a.reference,email:l.email,amount:100*parseFloat(l.amount),onSuccess:()=>{g.push("/success?reference=".concat(a.reference))},onCancel:()=>{localStorage.removeItem("giftData"),f(!1)}})}catch(e){console.error("Error:",e),localStorage.removeItem("giftData"),f(!1)}},y=async e=>{if(e.preventDefault(),f(!0),"NGN"===l.currency){await b();return}try{localStorage.setItem("giftData",JSON.stringify({name:l.name,email:l.email,message:l.message,amount:parseFloat(l.amount),currency:l.currency}));let e=await fetch("/api/create-checkout-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!e.ok)throw Error("Failed to create checkout session");let{sessionId:a}=await e.json(),r=await m;if(r){let{error:e}=await r.redirectToCheckout({sessionId:a});e&&(console.error("Error:",e),localStorage.removeItem("giftData"))}}catch(e){console.error("Error:",e),localStorage.removeItem("giftData")}finally{f(!1)}};return(0,t.jsx)(n.N,{children:a&&(0,t.jsx)(s.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:r,children:(0,t.jsxs)(s.P.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-lg p-6 max-w-md w-full relative",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("h2",{className:"text-coral font-script text-3xl text-center my-6",children:"Be a part of Our\xa0Journey"}),(0,t.jsx)("button",{onClick:r,className:"absolute top-0 right-0 pr-1 pt-1 pl-1 pb-1 rounded-bl-2xl rounded-tr-lg bg-coral hover:bg-coral/80 transition-colors",children:(0,t.jsx)(u.A,{className:"w-6 h-6"})}),(0,t.jsxs)("form",{onSubmit:y,className:"space-y-4",children:[(0,t.jsx)("div",{children:(0,t.jsx)("input",{type:"text",name:"name",value:l.name,placeholder:"Your name",onChange:h,className:"w-full bg-transparent border-b border-[#222]/20 py-2 px-1 focus:outline-none focus:border-coral",required:!0})}),(0,t.jsx)("div",{children:(0,t.jsx)("input",{type:"email",name:"email",value:l.email,onChange:h,placeholder:"Your email",className:"w-full bg-transparent border-b border-[#222]/20 py-2 px-1 focus:outline-none focus:border-coral",required:!0})}),(0,t.jsxs)("div",{className:"grid grid-cols-12 gap-4",children:[(0,t.jsx)("div",{className:"col-span-5",children:(0,t.jsxs)("select",{name:"currency",value:l.currency,onChange:h,className:"w-full bg-transparent border-b border-[#222]/20 py-2 px-1 pt-[14px] focus:outline-none focus:border-coral",children:[(0,t.jsx)("option",{value:"NGN",children:"Nigerian Naira (NGN)"}),(0,t.jsx)("option",{value:"GBP",children:"British Pound (GBP)"}),(0,t.jsx)("option",{value:"USD",children:"United States Dollar (USD)"})]})}),(0,t.jsx)("div",{className:"col-span-7",children:(0,t.jsx)("input",{type:"number",name:"amount",value:l.amount,onChange:h,placeholder:"Amount",className:"w-full bg-transparent border-b border-[#222]/20 py-2 px-1 focus:outline-none focus:border-coral",min:"1",required:!0})})]}),(0,t.jsx)("div",{children:(0,t.jsx)("textarea",{name:"message",value:l.message,placeholder:"Message (Optional)",onChange:h,className:"w-full bg-transparent border-b border-[#222]/20 py-2 px-1 focus:outline-none focus:border-coral",rows:3})}),(0,t.jsx)("button",{type:"submit",disabled:p,className:"btn-outline-dark w-full",children:p?"Processing...":"Confirm"})]})]})})})}}}]);