PageSourceSearch

https://spotz.global/assets/app.checkout-B8HIx_GQ.js

js spotz.global collected 2026-10-09 22:05:52 UTC 10,082 bytes, 1 lines download raw bytes

1import{f as K,r as o,j as e,L as Q,M as Y,n as H,o as J,q as V,s as W}from"./index-bQZ6-MOf.js";import{u as z}from"./createServerFn-CU39I-WU.js";import{t as X}from"./index-bl41CerC.js";import{u as Z}from"./i18n-XMYVLjL7.js";import{u as ee}from"./cart-JQk-nSsC.js";import{c as te}from"./spotz-orders.functions-CxPUx415.js";import{s as se}from"./spotz-payments.functions-DvvKlLjt.js";import{r as re}from"./local-orders-Cs31RvVU.js";import{S as P}from"./store-DSN6Z409.js";import{M as ae}from"./minus-CWUlcQZK.js";import{P as oe}from"./plus-BTpNNBeh.js";import{T as ne}from"./trash-2-CSPNkB6s.js";import{C as ce}from"./credit-card-Flh8TPc1.js";import{B as le}from"./bitcoin-6dGn5VkF.js";import{S as ie}from"./shield-check-BdJhMsn6.js";import"./auth-middleware-24HItX2r.js";function ze(){const{t:r,price:a,lang:i,currency:h,setCurrency:I}=Z(),{cart:s,subtotalCents:$,tipCents:M,totalCents:b,setQty:g,setTipPct:T,setDeliveryAddress:q,clear:f}=ee(),L=K(),A=z(te),E=z(se),[y,O]=o.useState(""),[j,D]=o.useState(""),[v,B]=o.useState(""),[d,R]=o.useState(""),[n,U]=o.useState("card"),[N,_]=o.useState("btc"),[k,C]=o.useState(!1),[F,m]=o.useState("idle"),p=s.serviceMode==="reservation",w=!!s.merchantId&&(s.items.length>0||p),G=async t=>{if(t.preventDefault(),!(!s.merchantId||!w)){C(!0),m("creating");try{const{data:c}=await W.auth.getUser(),u=p&&s.reservation?new Date(`${s.reservation.date}T${de(s.reservation.time)}:00`).toISOString():"",l=await A({data:{merchantId:s.merchantId,items:s.items.map(S=>({listingId:S.listingId,qty:S.qty})),serviceMode:s.serviceMode,partySize:s.reservation?.persons,mealPeriod:s.reservation?.period,reservationTime:s.reservation?.time??"",tipPct:s.tipPct,deliveryAddress:s.serviceMode==="delivery"?s.deliveryAddress:"",displayCurrency:h,paymentMethod:n,tableCode:s.tableCode??"",scheduledAt:u,note:n==="crypto"?[d,`Crypto: ${N.toUpperCase()}`].filter(Boolean).join(" · "):d,contactName:y,contactPhone:j,contactEmail:v,language:i,customerId:c.user?.id??""}});re({id:l.id,token:l.token,merchantName:s.merchantName??"",createdAt:new Date().toISOString()}),n!=="cash"&&(m("authorizing"),await E({data:{orderId:l.id,token:l.token}})),f(),L({to:"/app/confirmed/$id",params:{id:l.id}})}catch(c){X.error(c instanceof Error?c.message:"Something went wrong")}finally{C(!1),m("idle")}}};return w?e.jsxs("form",{onSubmit:G,className:"space-y-5 pb-28",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:r("checkout.title")}),e.jsxs("div",{className:"spotz-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(P,{className:"w-4 h-4 spotz-mint"}),e.jsx("span",{className:"font-medium",children:s.merchantName}),e.jsx("span",{className:"ml-auto text-[11px] px-2 py-0.5 rounded-full bg-[color:rgba(0,200,150,0.14)] spotz-mint",children:r(`mode.${s.serviceMode}`)})]}),p&&s.reservation&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(s.reservation.date).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})," ·"," ",r(Y.find(t=>t.id===s.reservation.period).labelKey)," · ",s.reservation.time," ·"," ",s.reservation.persons," ",r("book.persons").toLowerCase()]}),s.tableCode&&e.jsxs("p",{className:"text-[11px] spotz-mint",children:[r("qr.table")," ",s.tableCode]}),s.items.length>0&&e.jsx("div",{className:"divide-y divide-[color:rgba(0,200,150,0.12)]",children:s.items.map(t=>e.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a(t.priceCents,s.currency)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>g(t.listingId,t.qty-1),className:"h-7 w-7 rounded-full border border-[color:rgba(0,200,150,0.3)] flex items-center justify-center",children:e.jsx(ae,{className:"w-3 h-3"})}),e.jsx("span",{className:"w-5 text-center text-sm",children:t.qty}),e.jsx("button",{type:"button",onClick:()=>g(t.listingId,t.qty+1),className:"h-7 w-7 rounded-full border border-[color:rgba(0,200,150,0.3)] flex items-center justify-center",children:e.jsx(oe,{className:"w-3 h-3"})})]}),e.jsx("span",{className:"w-20 text-right text-sm font-medium",children:a(t.priceCents*t.qty,s.currency)})]},t.listingId))}),s.items.length>0&&e.jsxs("button",{type:"button",onClick:f,className:"text-muted-foreground inline-flex items-center gap-1 text-xs",children:[e.jsx(ne,{className:"w-3.5 h-3.5"}
1)," ",r("cart.clear")]})]}),e.jsxs("div",{className:"spotz-card p-4 space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("checkout.selectCurrency")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(t=>e.jsxs("button",{type:"button",onClick:()=>I(t.code),className:`px-3.5 py-2 rounded-xl text-xs border ${h===t.code?"spotz-tab-active border-transparent font-semibold":"border-[color:rgba(0,200,150,0.22)] text-muted-foreground"}`,children:[t.symbol," ",t.code]},t.code))})]}),s.items.length>0&&e.jsxs("div",{className:"spotz-card p-4 space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("checkout.addTip")}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:J.map(t=>e.jsx("button",{type:"button",onClick:()=>T(t),className:`rounded-xl py-2 text-xs border ${s.tipPct===t?"spotz-tab-active border-transparent font-semibold":"border-[color:rgba(0,200,150,0.22)] text-muted-foreground"}`,children:t===0?r("checkout.noTip"):`${t}%`},t))})]}),e.jsxs("div",{className:"spotz-card p-4 space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("checkout.payment")}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{id:"card",icon:ce,label:r("checkout.card")},{id:"crypto",icon:le,label:r("checkout.crypto")},{id:"cash",icon:P,label:r("checkout.cash")}].map(({id:t,icon:c,label:u})=>e.jsxs("button",{type:"button",onClick:()=>U(t),className:`rounded-2xl border px-2 py-3 flex flex-col items-center gap-1.5 text-[11px] ${n===t?"spotz-tab-active border-transparent font-semibold":"border-[color:rgba(0,200,150,0.25)] text-muted-foreground"}`,children:[e.jsx(c,{className:"w-4 h-4"}),u]},t))}),n==="crypto"&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:V.map(t=>e.jsx("button",{type:"button",onClick:()=>_(t.id),className:`px-3 py-1.5 rounded-full text-xs border ${N===t.id?"spotz-tab-active border-transparent font-semibold":"border-[color:rgba(0,200,150,0.22)] text-muted-foreground"}`,children:t.symbol},t.id))}),e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground pt-1",children:[e.jsx(ie,{className:"w-3.5 h-3.5 spotz-mint shrink-0"}),n==="cash"?r("checkout.securedCash"):`${r("checkout.securedBy")} · ${r("checkout.testMode")}`]})]}),e.jsxs("div",{className:"spotz-card p-4 space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("checkout.details")}),e.jsx("input",{required:!0,maxLength:120,value:y,onChange:t=>O(t.target.value),placeholder:r("checkout.name"),className:"w-full rounded-xl bg-[#04120d]/60 border border-[color:rgba(0,200,150,0.22)] px-3 py-2.5 text-sm outline-none"}),e.jsx("input",{maxLength:40,value:j,onChange:t=>D(t.target.value),placeholder:r("checkout.phone"),className:"w-full rounded-xl bg-[#04120d]/60 border border-[color:rgba(0,200,150,0.22)] px-3 py-2.5 text-sm outline-none"}),e.jsx("input",{type:"email",maxLength:255,value:v,onChange:t=>B(t.target.value),placeholder:r("checkout.email"),className:"w-full rounded-xl bg-[#04120d]/60 border border-[color:rgba(0,200,150,0.22)] px-3 py-2.5 text-sm outline-none"}),s.serviceMode==="delivery"&&e.jsx("input",{required:!0,maxLength:400,value:s.deliveryAddress,onChange:t=>q(t.target.value),placeholder:r("checkout.address"),className:"w-full rounded-xl bg-[#04120d]/60 border border-[color:rgba(0,200,150,0.22)] px-3 py-2.5 text-sm outline-none"}),e.jsx("textarea",{maxLength:1e3,value:d,onChange:t=>R(t.target.value),placeholder:r("checkout.note"),rows:3,className:"w-full rounded-xl bg-[#04120d]/60 border border-[color:rgba(0,200,150,0.22)] px-3 py-2.5 text-sm outline-none"})]}),e.jsxs("div",{className:"spotz-card p-4 space-y-1.5 text-sm",children:[e.jsx(x,{label:r("checkout.amount"),value:a($,s.currency)}),e.jsx(x,{label:r("checkout.taxFees"),value:a(0,s.currency)}),e.jsx(x,{label:r("checkout.tip"),value:a(M,s.currency)}),e.jsxs("div",{className:"border-t border-[color:rgba(0,200,150,0.14)] pt-2 mt-2 flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:r("checkout.grandTotal")}),e.jsxs("span",{className:"block text-[11px] text-muted-foreground",children:[r("checkout.includingTip")," (",s.tipPct,"%)"]})]}),e.jsx("span",{className:"text-lg font-semibold spotz-mint",children:a(b,s.currency)})]})]}),e.jsx("div",{className:"fixed bottom-[72px] inset-x-0 z-30 px-5",children:e.jsx("div",{className:"mx-auto max-w-2xl",children:e.jsx("button",{type:"submit",disabled:k,className:"w-full rounded-full spotz
1-bg-mint text-[#04120d] font-semibold py-3.5 spotz-glow disabled:opacity-60",children:k?r(F==="authorizing"?"checkout.authorizing":"checkout.placing"):`${r("common.proceed")} · ${a(b,s.currency)}`})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:r("cart.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("cart.empty")}),e.jsx(Q,{to:"/app/explore",search:{v:void 0,q:void 0},className:"inline-block rounded-full spotz-bg-mint text-[#04120d] font-semibold px-5 py-2.5 text-sm",children:r("explore.title")})]})}function x({label:r,value:a}){return e.jsxs("div",{className:"flex items-center justify-between text-muted-foreground",children:[e.jsx("span",{children:r}),e.jsx("span",{className:"text-foreground",children:a})]})}function de(r){const a=/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i.exec(r.trim());if(!a)return"12:00";let i=Number(a[1])%12;return a[3].toUpperCase()==="PM"&&(i+=12),`${String(i).padStart(2,"0")}:${a[2]}`}export{ze as component};

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.