PageSourceSearch

https://www.faithassembly.org.uk/assets/Checkout-LE1ZhDCx.js

js faithassembly.org.uk collected 2026-10-03 18:59:45 UTC 6,833 bytes, 1 lines download raw bytes

1import{ay as y,r as d,j as e,aj as j,ai as b,ao as N,ap as v,aq as w}from"./vendor-BFIOfVip.js";import{aw as S,as as C,am as P}from"./vendor-icons-BjlO8Ivt.js";import{u as E,d as F}from"./index-BWk9MH7v.js";import{l as I,m as k,n as V}from"./vendor-firebase-IWWIlHC2.js";import"./vendor-motion-C4-LgF0B.js";const U="pk_live_51SZc1Y9jXqeC5IB8r1sdsIBPVuUQ2J0zCpU2KXuMV6yXVLWIJg9opDERjDwwUfKCz7bxIFWpEvKEKRHdmFrH7Ixc00wBU6XVbU",B=b(U),L=({amount:n,formData:t,cart:g,clearCart:m,navigate:l})=>{const p=N(),c=v(),[x,r]=d.useState(null),[s,a]=d.useState(!1),i=()=>!t.firstName||!t.lastName||!t.email||!t.address||!t.city||!t.postcode?(r("Please fill in all shipping fields."),!1):/^\S+@\S+\.\S+$/.test(t.email)?!0:(r("Please enter a valid email address."),!1),h=async f=>{if(f.preventDefault(),r(""),!(!p||!c)&&i()){a(!0);try{const{error:u,paymentIntent:o}=await p.confirmPayment({elements:c,redirect:"if_required"});u?(r(u.message||"An unexpected error occurred."),a(!1)):o&&o.status==="succeeded"?(await I(k(F,"orders"),{customer:t,items:g,total:n,paymentId:o.id,provider:"stripe",status:"paid",createdAt:V()}),m(),l("/store/success")):(r("Payment status: "+((o==null?void 0:o.status)||"unknown")),a(!1))}catch(u){console.error(u),r(u.message||"Payment failed."),a(!1)}}};return e.jsxs("form",{onSubmit:h,children:[e.jsx(w,{}),x&&e.jsxs("div",{className:"mt-4 text-red-600 bg-red-50 p-3 rounded-lg flex items-center text-sm",children:[e.jsx(C,{className:"mr-2 flex-shrink-0"}),x]}),e.jsx("button",{disabled:s||!p||!c,className:"w-full mt-6 bg-purple-600 text-white py-3 rounded-lg font-bold hover:bg-purple-700 disabled:opacity-50 transition shadow-md",children:s?"Processing...":`Pay £${n.toFixed(2)}`}),e.jsxs("div",{className:"flex items-center justify-center text-xs text-gray-400 mt-4",children:[e.jsx(P,{className:"mr-1"}),"Secure payment processing powered by Stripe"]})]})},$=()=>{const{cart:n,cartTotal:t,clearCart:g}=E(),m=y(),[l,p]=d.useState({firstName:"",lastName:"",email:"",address:"",city:"",postcode:""}),[c,x]=d.useState("");d.useEffect(()=>{n.length===0&&m("/store")},[n,m]),d.useEffect(()=>{t>0&&(async()=>{try{const i=await(await fetch("/api/create-payment-intent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:Math.round(t*100),currency:"gbp"})})).json();i.clientSecret&&x(i.clientSecret)}catch(a){console.error("Failed to init Stripe",a)}})()},[t]);const r=s=>{const{name:a,value:i}=s.target,h=a==="postcode"?i.toUpperCase():i;p(f=>({...f,[a]:h}))};return n.length===0?null:e.jsx("div",{className:"min-h-screen bg-gray-50 pt-24 pb-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-8",children:"Checkout"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[e.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center",children:[e.jsx("span",{className:"bg-purple-100 text-purple-600 w-8 h-8 rounded-full flex items-center justify-center mr-3 text-sm",children:"1"}),"Shipping Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("input",{type:"text",name:"firstName",placeholder:"First Name",value:l.firstName,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none"}),e.jsx("input",{type:"text",name:"lastName",placeholder:"Last Name",value:l.lastName,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none"}),e.jsx("input",{type:"email",name:"email",placeholder:"Email Address",value:l.email,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none md:col-span-2"}),e.jsx("input",{type:"text",name:"address",placeholder:"Address",value:l.address,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none md:col-span-2"}),e.jsx("input",{type:"text",name:"city",placeholder:"City",value:l.city,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none"}),e.jsx("input",{type:"text",name:"postcode",placeholder:"Postcode",value:l.postcode,onChange:r,className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 outline-none"})]})]}),e.jsxs("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[e.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center",children:[e.jsx("span",{className:"bg-purple-100 text-purple-600 w-8 h-8 rounded-full flex items-center justify-center mr-3 text-sm",children:"2"}),"Payment Details"]}
1),e.jsx("div",{className:"mb-4",children:c?e.jsx(j,{stripe:B,options:{clientSecret:c},children:e.jsx(L,{amount:t,formData:l,cart:n,clearCart:g,navigate:m})}):e.jsx("div",{className:"flex justify-center items-center py-8 text-gray-500",children:"Loading secure payment..."})})]})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsxs("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100 sticky top-24",children:[e.jsxs("h2",{className:"text-xl font-bold mb-6 flex items-center",children:[e.jsx(S,{className:"mr-2 text-purple-600"})," Order Summary"]}),e.jsx("div",{className:"space-y-4 max-h-96 overflow-y-auto pr-2 custom-scrollbar",children:n.map(s=>e.jsxs("div",{className:"flex space-x-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-lg overflow-hidden flex-shrink-0",children:e.jsx("img",{src:s.product.images[0],alt:s.product.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium text-gray-900 line-clamp-1",children:s.product.name}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Qty: ",s.quantity," ",s.selectedVariant&&`• Size: ${s.selectedVariant}`]})]}),e.jsxs("div",{className:"font-semibold text-gray-900",children:["£",(s.product.price*s.quantity).toFixed(2)]})]},`${s.product.id}-${s.selectedVariant}`))}),e.jsxs("div",{className:"border-t border-gray-100 mt-6 pt-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-gray-600",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["£",t.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-gray-600",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{children:"Free"})]}),e.jsxs("div",{className:"flex justify-between text-xl font-bold text-gray-900 pt-2 border-t border-gray-100 mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["£",t.toFixed(2)]})]})]})]})})]})]})})};export{$ 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.