efficient-storefront-blocks 0.76.0 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/chunks/EditorPreviewCheckout-GNQP4MQ4.js +4 -0
- package/dist/chunks/{SiteEditorProvider-AJUWZYHT.js → SiteEditorProvider-R3HXJAPW.js} +1 -1
- package/dist/chunks/chunk-BOJGJXIU.js +311 -0
- package/dist/chunks/chunk-CAULWKXR.js +1 -0
- package/dist/chunks/chunk-GDR5GGVW.js +1 -0
- package/dist/chunks/chunk-OWYNZAAY.js +1 -0
- package/dist/chunks/chunk-ZIZWJZ5T.js +1 -0
- package/dist/chunks/{fitment-data-IZYCNTET.js → fitment-data-JNQKYQIB.js} +1 -1
- package/dist/editor/components/CategorySource.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/GalleryB/fields.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/ProductGrid/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/Events/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/FooterGroup/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/FooterSocial/fields.js +1 -1
- package/dist/index.js +31 -31
- package/dist/render/app/globals.css +13 -0
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/ChatWidget.js +1 -1
- package/dist/render/components/ConsentPanel.js +1 -1
- package/dist/render/components/Events.d.ts +2 -1
- package/dist/render/components/Events.js +1 -1
- package/dist/render/components/FooterGroup.d.ts +2 -1
- package/dist/render/components/FooterGroup.js +1 -1
- package/dist/render/components/GalleryGrid.d.ts +2 -1
- package/dist/render/components/GalleryGrid.js +1 -1
- package/dist/render/components/Notice.d.ts +6 -0
- package/dist/render/components/Notice.js +1 -0
- package/dist/render/components/ProductGridSection.d.ts +2 -1
- package/dist/render/components/ProductGridSection.js +1 -1
- package/dist/render/components/SubscribePopup.js +2 -2
- package/dist/render/components/TyreFitVerdicts.d.ts +2 -1
- package/dist/render/components/TyreFitVerdicts.js +1 -1
- package/dist/render/components/TyreVehicleFitment.js +1 -1
- package/dist/render/components/WheelCardFrame.d.ts +3 -0
- package/dist/render/components/WheelCardFrame.js +1 -1
- package/dist/render/components/catalog/CatalogFilterBar.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.d.ts +4 -0
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +14 -2
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/components/product-hero/TyreHeroFitment.d.ts +2 -1
- package/dist/render/components/product-hero/TyreHeroFitment.js +1 -1
- package/dist/render/components/product-hero/VehicleQuestion.d.ts +0 -4
- package/dist/render/components/product-hero/VehicleQuestion.js +1 -1
- package/dist/render/components/product-hero/WheelHeroFitment.js +1 -1
- package/dist/render/components/useTyreFitAnswer.d.ts +1 -0
- package/dist/render/components/useTyreFitAnswer.js +1 -1
- package/dist/render/lib/api/index.d.ts +6 -3
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/api/types.d.ts +3 -0
- package/dist/render/lib/checkout/pay-first.d.ts +34 -0
- package/dist/render/lib/checkout/pay-first.js +1 -0
- package/dist/render/lib/document/blocks/commerce/GalleryB/render.js +1 -1
- package/dist/render/lib/document/blocks/commerce/ProductGrid/render.js +1 -1
- package/dist/render/lib/document/blocks/service/Events/render.js +1 -1
- package/dist/render/lib/document/blocks/service/FooterGroup/render.js +1 -1
- package/dist/render/lib/tyres/tyre-fit-copy.js +1 -1
- package/dist/render/lib/tyres/tyre-vehicle-fitment.d.ts +3 -1
- package/dist/render/lib/tyres/tyre-vehicle-fitment.js +1 -1
- package/dist/words.d.ts +0 -5
- package/dist/words.js +2 -2
- package/package.json +3 -3
- package/dist/chunks/EditorPreviewCheckout-ANI7HUYX.js +0 -4
- package/dist/chunks/chunk-3IQQNZIM.js +0 -311
- package/dist/chunks/chunk-4F5CAFXO.js +0 -1
- package/dist/chunks/chunk-5NXOTPHK.js +0 -1
- package/dist/chunks/chunk-YAYHH5GY.js +0 -1
- package/dist/chunks/chunk-YFPWVNDB.js +0 -1
- /package/dist/chunks/{chunk-3IQQNZIM.js.LEGAL.txt → chunk-BOJGJXIU.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as b}from"react/jsx-runtime";import S from"next/link";import{useEffect as D,useMemo as T,useRef as j,useState as v}from"react";import{stripeAppearance as Y}from"../../lib/checkout/stripe-appearance.js";import{Elements as B,PaymentElement as z,useElements as L,useStripe as $}from"@stripe/react-stripe-js";import{loadStripe as F}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{resolveCopyright as U}from"../../lib/content/site.js";import{ApiError as A,products as R}from"../../lib/api/index.js";import G from"efficient-web-builder/render/components/Logo";import{CheckoutStateProvider as H,useCheckout as Q}from"./checkout-state.js";import{CheckoutContact as W,CheckoutOrderSummary as Z,CheckoutPayment as J,CheckoutShippingAddress as V,CheckoutShippingMethod as X}from"./checkout-parts.js";function ee(t){return e(H,{...t,children:e(re,{})})}function te({order:t,paid:n}){const{formatMoney:i}=E();if(!t.grandTotal||!t.currency)return null;const c=a=>i(Number(a),t.currency),l=Number(t.freightCharge??0),s=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||l>0)&&r(b,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:c(t.freightCharge??"0")})]}),s>0&&r(b,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",c(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:c(t.grandTotal)})]})}function re(){const{site:t,logo:n,items:i,placing:c,email:l,me:s,addressSaveNote:a,idemKey:u,confirmation:d,setConfirmation:p,payment:f,paypalStep:x,squareStep:h,pendingConf:o,paid:N,setPaid:y,payNote:g,afterpayConfirming:q,gocardlessConfirming:k,zipConfirming:m,klarnaConfirming:P,checkoutRootRef:C,setCheckoutHeaderEl:_}=Q();return d?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:N?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[N?r(b,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," has gone through."," "]}):r(b,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," is being reviewed by our team."," "]}),s?r(b,{children:["Track it under"," ",e(S,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(b,{children:"We’ve emailed you a link to set a password and track it."})]}),e(te,{order:d,paid:N}),g&&e("p",{className:"text-sm text-fg-dim",children:g}),a&&e("p",{className:"text-sm text-fg-dim",children:a}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(S,{href:`/track?order=${encodeURIComponent(d.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(S,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):q?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):k?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):m?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):f?e(ne,{payment:f,onPaid:()=>{y(!0),p(o)},onSkip:()=>p(o)}):x&&o?e(oe,{confirmation:o,clientId:t.paypalClientId??"",idemKey:u,onPaid:()=>{y(!0),p(o)},onSkip:()=>p(o)}):h&&o?e(ce,{confirmation:o,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:u,onPaid:()=>{y(!0),p(o)},onSkip:()=>p(o)}):r("div",{ref:C,className:"bg-bg text-fg",children:[r("header",{ref:_,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(S,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(S,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(G,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,siteName:t.name})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(w=>r("span",{className:["relative flex items-center gap-2 transition-colors",w.state==="pending"?"text-fg-dim":"text-fg",w.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:w.state==="done"?"text-accent font-bold":"",children:w.n}),e("span",{children:w.label})]},w.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-[1100px]:grid-cols-1 max-[1100px]:gap-10 max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))] max-[1100px]:pt-8 max-[1100px]:pb-20",children:[r("div",{children:[e(W,{}),e(V,{}),e(X,{}),e(J,{})]}),e(Z,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:U({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ne({payment:t,onPaid:n,onSkip:i}){const{formatMoney:c}=E(),l=T(()=>F(t.publishableKey),[t.publishableKey]),s=T(()=>Y(),[]);return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:c(Number(t.amount),t.currency)})," ","by card to confirm it now."]}),e(B,{stripe:l,options:{clientSecret:t.clientSecret,appearance:s},children:e(ae,{payment:t,onPaid:n,onSkip:i})})]})]})})}function ae({payment:t,onPaid:n,onSkip:i}){const{formatMoney:c}=E(),l=$(),s=L(),[a,u]=v(!1),[d,p]=v(null);async function f(){if(!l||!s||a)return;u(!0),p(null);const x=await l.confirmPayment({elements:s,redirect:"if_required"});if(x.error){p(x.error.message??"Payment failed. Please try again."),u(!1);return}const h=x.paymentIntent?.status;if(h==="succeeded"||h==="processing"){n();return}p("Payment did not complete. Please try again."),u(!1)}return r("div",{className:"flex flex-col gap-4",children:[e(z,{}),d&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:d}),e("button",{type:"button",onClick:f,disabled:!l||!s||a,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!l||!s||a?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:a?r(b,{children:["Processing… ",e("span",{children:"·"})]}):r(b,{children:["Pay ",c(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:i,disabled:a,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})}const M="paypal-sdk-js";let I=null;function se(t,n){const i=`${t}|${n}`;if(I?.key===i)return I.promise;const c=new Promise((l,s)=>{document.getElementById(M)?.remove();const a=document.createElement("script");a.id=M;const u=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});a.src=`https://www.paypal.com/sdk/js?${u}`,a.onload=()=>{const d=window.paypal;d?l(d):s(new Error("PayPal SDK loaded without its namespace"))},a.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(a)});return I={key:i,promise:c},c}function oe({confirmation:t,clientId:n,idemKey:i,onPaid:c,onSkip:l}){const{formatMoney:s}=E(),a=j(null),[u,d]=v(!1),[p,f]=v(null),x=j(c);return x.current=c,D(()=>{let h=!1,o=null;return se(n,t.currency).then(N=>{if(!(h||!a.current))return o=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await R.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async y=>{try{if((await R.capturePaypalOrder({idempotencyKey:i,paypalOrderId:y.orderID})).status==="paid"){x.current();return}f("PayPal did not complete the payment. Please try again.")}catch(g){f(g instanceof A?g.message:"PayPal payment failed. Please try again.")}},onError:()=>{f("PayPal could not process the payment. Please try again.")}}),o.render(a.current).then(()=>{h||d(!0)})}).catch(()=>{h||f("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,o?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!u&&!p&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:a}),p&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:p}),e("button",{type:"button",onClick:l,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const O="square-web-sdk";let K=null;function ie(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const i=new Promise((c,l)=>{document.getElementById(O)?.remove();const s=document.createElement("script");s.id=O,s.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{const a=window.Square;a?c(a):l(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>l(new Error("Square SDK failed to load")),document.head.appendChild(s)});return K={key:n,promise:i},i}function ce({confirmation:t,applicationId:n,locationId:i,environment:c,idemKey:l,onPaid:s,onSkip:a}){const{formatMoney:u}=E(),d=j(null),p=j(null),f=j(null),[x,h]=v(!1),[o,N]=v(!1),[y,g]=v(null);D(()=>{let k=!1,m=null;return ie(c).then(async P=>{if(k||!d.current)return;const C=P.payments(n,i);f.current=C,m=await C.card(),await m.attach(d.current),p.current=m,k||h(!0)}).catch(()=>{k||g("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{k=!0,m?.destroy?.()}},[n,i,c]);async function q(){const k=p.current;if(!(!k||o)){N(!0),g(null);try{const m=await k.tokenize();if(m.status!=="OK"||!m.token){g(m.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let P;try{P=(await f.current?.verifyBuyer?.(m.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await R.chargeSquare({idempotencyKey:l,sourceId:m.token,...P?{verificationToken:P}:{}})).status==="paid"){s();return}g("Square did not complete the payment. Please try again.")}catch(m){g(m instanceof A?m.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:u(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!x&&!y&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),y&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:y}),e("button",{type:"button",onClick:q,disabled:!x||o,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!x||o?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:o?r(b,{children:["Processing… ",e("span",{children:"·"})]}):r(b,{children:["Pay ",u(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:a,disabled:o,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{ee as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import S from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as v}from"react";import{stripeAppearance as Q}from"../../lib/checkout/stripe-appearance.js";import{Elements as V,PaymentElement as Z,useElements as J,useStripe as X}from"@stripe/react-stripe-js";import{loadStripe as ee}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as I}from"../Notice.js";import{resolveCopyright as te}from"../../lib/content/site.js";import{ApiError as O,products as T}from"../../lib/api/index.js";import re from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as _,orderReference as ne}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ae,useCheckout as ie}from"./checkout-state.js";import{CheckoutContact as oe,CheckoutOrderSummary as ce,CheckoutPayment as se,CheckoutShippingAddress as le,CheckoutShippingMethod as de}from"./checkout-parts.js";function me(t){return e(ae,{...t,children:e(fe,{})})}function pe({order:t,paid:n}){const{formatMoney:p}=R();if(!t.grandTotal||!t.currency)return null;const u=i=>p(Number(i),t.currency),h=Number(t.freightCharge??0),s=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||h>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:u(t.freightCharge??"0")})]}),s>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",u(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:u(t.grandTotal)})]})}function ue({result:t}){const n=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",n,". Your payment is refunded to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",n," ran out before your payment arrived. Your payment is refunded to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",n," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment for checkout ",n," has gone through. We will email you the order number shortly."]})}),e(S,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function fe(){const{site:t,logo:n,items:p,placing:u,email:h,me:s,addressSaveNote:i,idemKey:f,confirmation:o,setConfirmation:m,payment:d,paypalStep:k,squareStep:g,pendingConf:c,paid:y,setPaid:b,payNote:N,afterpayConfirming:E,gocardlessConfirming:l,zipConfirming:a,klarnaConfirming:w,cardConfirming:P,checkoutResult:q,confirmCardPayment:L,cardStillProcessing:z,renewCardPayment:F,holdRenewed:H,leaveCardPayment:G,checkoutRootRef:U,setCheckoutHeaderEl:W}=ie();return o?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:y?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[y?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(S,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(pe,{order:o,paid:y}),N&&e("p",{className:"text-sm text-fg-dim",children:N}),i&&e("p",{className:"text-sm text-fg-dim",children:i}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(S,{href:`/track?order=${encodeURIComponent(o.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(S,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):q?e(ue,{result:q}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):E?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):l?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):d&&c?e(xe,{payment:d,checkout:c,holdRenewed:H,onPaid:L,onProcessing:z,onRenew:F,onBack:G}):k&&c?e(be,{confirmation:c,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{b(!0),m(c)},onSkip:()=>m(c)}):g&&c?e(ke,{confirmation:c,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{b(!0),m(c)},onSkip:()=>m(c)}):r("div",{ref:U,className:"bg-bg text-fg",children:[r("header",{ref:W,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(S,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(S,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(re,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,siteName:t.name})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(C=>r("span",{className:["relative flex items-center gap-2 transition-colors",C.state==="pending"?"text-fg-dim":"text-fg",C.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:C.state==="done"?"text-accent font-bold":"",children:C.n}),e("span",{children:C.label})]},C.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-[1100px]:grid-cols-1 max-[1100px]:gap-10 max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))] max-[1100px]:pt-8 max-[1100px]:pb-20",children:[r("div",{children:[e(oe,{}),e(le,{}),e(de,{}),e(se,{})]}),e(ce,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:te({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function xe({payment:t,checkout:n,holdRenewed:p,onPaid:u,onProcessing:h,onRenew:s,onBack:i}){const{formatMoney:f}=R(),o=e("span",{className:"text-fg",children:f(Number(t.amount),t.currency)}),m=Y(()=>ee(t.publishableKey),[t.publishableKey]),d=Y(()=>Q(),[]);return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:ne(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",o," by card to confirm it now."]}):p?r(x,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Enter your card again, then pay ",o,"."]}):r(x,{children:["Your items are held",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Pay ",o," by card to place your order."]})}),e(V,{stripe:m,options:{clientSecret:t.clientSecret,appearance:d},children:e(he,{payment:t,checkout:n,onPaid:u,onProcessing:h,onRenew:s,onBack:i})},t.clientSecret)]})]})})}function B(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const ge=5;function he({payment:t,checkout:n,onPaid:p,onProcessing:u,onRenew:h,onBack:s}){const{formatMoney:i}=R(),f=X(),o=J(),[m,d]=v(!1),[k,g]=v(null),c=j(!1);async function y(){try{return(await f.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function b(l){let a=l;for(let w=0;a==="processing"&&w<ge;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await y()??a;if(a==="succeeded"){p();return}if(a==="processing"){u();return}g("Payment did not complete. Please try again."),d(!1)}async function N(){if(!f||!o||m)return;d(!0),g(null),c.current=!0;const l=await f.confirmPayment({elements:o,redirect:"if_required"}).catch(()=>null);if(!l){const a=await y();if(a==="succeeded"||a==="processing"){await b(a);return}g(a===void 0?_:"Payment failed. Please try again."),d(!1);return}if(l.error){if(!n.orderNumber&&l.error.code==="payment_intent_unexpected_state"){const a=await y();if(a==="succeeded"||a==="processing"){await b(a);return}if(a===void 0){g(_),d(!1);return}await h(a==="canceled"),d(!1);return}g(l.error.message??"Payment failed. Please try again."),d(!1);return}await b(l.paymentIntent?.status)}async function E(){if(m)return;if(!c.current){s();return}d(!0),g(null);const l=await y();if(l==="succeeded"||l==="processing"){await b(l);return}if(d(!1),l===void 0){g(_);return}s()}return r("div",{className:"flex flex-col gap-4",children:[e(Z,{}),k&&e(I,{role:"alert",children:k}),e("button",{type:"button",onClick:N,disabled:!f||!o||m,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||!o||m?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:m?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",i(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!m&&r("button",{type:"button",onClick:E,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const M="paypal-sdk-js";let A=null;function ye(t,n){const p=`${t}|${n}`;if(A?.key===p)return A.promise;const u=new Promise((h,s)=>{document.getElementById(M)?.remove();const i=document.createElement("script");i.id=M;const f=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});i.src=`https://www.paypal.com/sdk/js?${f}`,i.onload=()=>{const o=window.paypal;o?h(o):s(new Error("PayPal SDK loaded without its namespace"))},i.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(i)});return A={key:p,promise:u},u}function be({confirmation:t,clientId:n,idemKey:p,onPaid:u,onSkip:h}){const{formatMoney:s}=R(),i=j(null),[f,o]=v(!1),[m,d]=v(null),k=j(u);return k.current=u,D(()=>{let g=!1,c=null;return ye(n,t.currency).then(y=>{if(!(g||!i.current))return c=y.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:p})).paypalOrderId,onApprove:async b=>{try{if((await T.capturePaypalOrder({idempotencyKey:p,paypalOrderId:b.orderID})).status==="paid"){k.current();return}d("PayPal did not complete the payment. Please try again.")}catch(N){d(N instanceof O?N.message:"PayPal payment failed. Please try again.")}},onError:()=>{d("PayPal could not process the payment. Please try again.")}}),c.render(i.current).then(()=>{g||o(!0)})}).catch(()=>{g||d("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,c?.close?.()}},[n,t.currency,p]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!f&&!m&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:i}),m&&e(I,{role:"alert",children:m}),e("button",{type:"button",onClick:h,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const $="square-web-sdk";let K=null;function Ne(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const p=new Promise((u,h)=>{document.getElementById($)?.remove();const s=document.createElement("script");s.id=$,s.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{const i=window.Square;i?u(i):h(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(s)});return K={key:n,promise:p},p}function ke({confirmation:t,applicationId:n,locationId:p,environment:u,idemKey:h,onPaid:s,onSkip:i}){const{formatMoney:f}=R(),o=j(null),m=j(null),d=j(null),[k,g]=v(!1),[c,y]=v(!1),[b,N]=v(null);D(()=>{let l=!1,a=null;return Ne(u).then(async w=>{if(l||!o.current)return;const P=w.payments(n,p);d.current=P,a=await P.card(),await a.attach(o.current),m.current=a,l||g(!0)}).catch(()=>{l||N("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{l=!0,a?.destroy?.()}},[n,p,u]);async function E(){const l=m.current;if(!(!l||c)){y(!0),N(null);try{const a=await l.tokenize();if(a.status!=="OK"||!a.token){N(a.errors?.[0]?.message??"Please check the card details and try again."),y(!1);return}let w;try{w=(await d.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await T.chargeSquare({idempotencyKey:h,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){s();return}N("Square did not complete the payment. Please try again.")}catch(a){N(a instanceof O?a.message:"Square payment failed. Please try again.")}y(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:f(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!k&&!b&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:o}),b&&e(I,{role:"alert",children:b}),e("button",{type:"button",onClick:E,disabled:!k||c,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!k||c?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:c?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",f(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:i,disabled:c,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{ue as PayFirstResultView,me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as E}from"react";import G from"next/image";import T from"next/link";import{lineTotal as W,useCart as K}from"../CartContext.js";import{useCurrency as X}from"../CurrencyContext.js";import{FREE_PRICE as F}from"../../lib/wheels/price-display.js";import Z from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as J}from"../../lib/cart/coupon-preview.js";import{shippingWords as Q,TAX_PENDING as V}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ee}from"../../lib/wheels/finish-defaults.js";import R from"../ThemedSelect.js";import f from"../WebFormField.js";import te from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as ne,SHIPPING_RETRY_NOTE as ae,useCheckout as k}from"./checkout-state.js";import{FIELD_INPUT_CLASS as g}from"../../lib/field-input.js";function we(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:u,me:o,checkoutSignOut:y}=k(),x=E();return a(w,{num:"N° 01",title:"Contact",children:[e(f,{label:"Email",htmlFor:x,hint:o?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:y,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:x,type:"email",value:t,onChange:d=>i(d.target.value),placeholder:"you@example.com",readOnly:o!==null,className:g+(o?" opacity-70":"")})}),a(Y,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:d=>l(d.target.value),className:g})}),e(f,{label:"Last name",children:e("input",{type:"text",value:c,onChange:d=>u(d.target.value),className:g})})]})]})}function Se(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:u,city:o,setCity:y,postcode:x,setPostcode:d,phone:b,setPhone:s,country:p,setCountry:m,subdivision:C,setSubdivision:h,subdivisions:A,destination:oe,postcodeLabel:M,subdivisionLabel:U,me:I,savedAddresses:L,selectedAddressId:_,setSelectedAddressId:P,saveAddress:O,setSaveAddress:z,saveLabel:D,setSaveLabel:H,fillFromAddress:q}=k(),B=E(),j=E();return a(w,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[I!==null&&L.length>0&&a("div",{className:"grid gap-3",children:[L.map(r=>e(S,{active:_===r.id,onClick:()=>{P(r.id),q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(S,{active:_==="new",onClick:()=>P("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:g})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>u(r.target.value),placeholder:"Apartment, unit, garage bay…",className:g})}),a(Y,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:o,onChange:r=>y(r.target.value),className:g})}),e(f,{label:M,children:e("input",{type:"text",value:x,onChange:r=>d(r.target.value),className:g})}),e(f,{label:"Country",separate:!0,htmlFor:B,children:e(R,{id:B,value:p,onChange:r=>m(r.target.value),className:g+" pr-10",style:$,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:U,separate:!0,htmlFor:j,children:A.length>0?a(R,{id:j,value:C,onChange:r=>h(r.target.value),className:g+" pr-10",style:$,children:[e("option",{value:"",children:"Select…"}),A.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:C,onChange:r=>h(r.target.value),className:g})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>s(r.target.value),className:g})}),!t&&I!==null&&_==="new"&&a(N,{children:[e(re,{checked:O,onChange:z,label:"Save this address to my account"}),O&&e(f,{label:"Address label",children:e("input",{type:"text",value:D,onChange:r=>H(r.target.value),placeholder:"Home",className:g})})]})]})}function _e(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:u,formatMoney:o,city:y,destination:x,courierUnavailable:d,retryCourier:b}=k();return e(w,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(s=>{const p=s.pickupLocation,m=p?[p.address,p.city,p.state,p.zipCode].filter(Boolean).join(", "):null;return e(S,{active:l===s.id,onClick:()=>c(s.id),title:p?`${s.name} — ${p.name}`:s.name,body:p?[m,p.openingHours,p.instructions,s.description].filter(Boolean).join(" · "):s.description||null,price:t.freeShipping||s.amount===0?F:o(s.amount,t.currency),tag:s.tag||void 0},s.id)}),d?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ae," ",e("button",{type:"button",onClick:b,className:"underline transition-colors hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function je(){const{payChoice:t,setPayChoice:i,placing:n,payment:l,payOptions:c,noPaymentMethod:u}=k();return a(w,{num:"N° 04",title:"Payment",children:[u&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:ne}),e("div",{className:"grid gap-3",children:c.map(o=>e(S,{active:t===o.key,onClick:()=>i(o.key),title:o.title,body:o.body,price:o.price,tag:o.tag},o.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Ee(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:u,placing:o,email:y,orderError:x,payment:d,noPaymentMethod:b,unpaidOrder:s,placeOrder:p}=k();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(T,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(T,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(m=>e(ie,{slug:m.slug,name:m.name,qty:m.qty,config:m.config,configSummary:le(m.config),price:W(m,n.currency)??0,currency:n.currency},m.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(Z,{customerEmail:y})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(v,{label:"Subtotal",value:c(n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(v,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),l?.deferred&&e(v,{label:`Coupon · ${l.code}`,value:J}),l?.valid&&l.effects?.gift&&e(v,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:F})}),e(v,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:F}):Q(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(v,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(v,{label:n.tax.name,value:V}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[x&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:x}),n.hasUnpricedLine&&a("p",{className:"border border-amber-300 bg-amber-50 px-3 py-2 text-[13px] text-amber-800",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:p,disabled:o||!s&&(b||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",o||!s&&(i.length===0||b||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:o?a(N,{children:["Building order… ",e("span",{children:"·"})]}):b?a(N,{children:["No online payment ",e("span",{children:"·"})]}):s?a(N,{children:["Try payment again · ",s.orderNumber,e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(N,{children:["Updating total… ",e("span",{children:"·"})]}):a(N,{children:[u==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const $={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function w({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function Y({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function S({active:t,onClick:i,title:n,body:l,price:c,tag:u}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,u&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:u})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function re({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function ie({slug:t,name:i,qty:n,config:l,configSummary:c,price:u,currency:o}){const{catalog:y}=K(),{formatMoney:x}=X(),d=y.find(h=>h.slug===t),b=d?.spokes??5,s=d?.mesh??!1,p=l.find(h=>h.gold)?.label,m=d?.finishes.find(h=>h.name===p&&h.src)??d?.finishes.find(h=>h.src),C=d?.finishes[0]?.color??ee;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative flex aspect-square items-center justify-center overflow-hidden border border-line bg-surface",children:[e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n}),m?.src?e(G,{src:m.src,alt:`${i.lead}${i.accent} — ${m.name}`,width:120,height:120,sizes:"60px",className:"relative block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(te,{spokes:b,mesh:s,className:"block w-full"})})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:x(u,o)})]})}function v({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function le(t){return t.map(i=>i.label).join(" · ")}export{we as CheckoutContact,Ee as CheckoutOrderSummary,je as CheckoutPayment,Se as CheckoutShippingAddress,_e as CheckoutShippingMethod};
|
|
1
|
+
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as E}from"react";import W from"next/image";import T from"next/link";import{lineTotal as K,useCart as X}from"../CartContext.js";import{useCurrency as Z}from"../CurrencyContext.js";import{Notice as R}from"../Notice.js";import{FREE_PRICE as F}from"../../lib/wheels/price-display.js";import J from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as Q}from"../../lib/cart/coupon-preview.js";import{orderReference as V}from"../../lib/checkout/pay-first.js";import{shippingWords as ee,TAX_PENDING as te}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ne}from"../../lib/wheels/finish-defaults.js";import $ from"../ThemedSelect.js";import f from"../WebFormField.js";import ae from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as re,SHIPPING_RETRY_NOTE as ie,useCheckout as k}from"./checkout-state.js";import{FIELD_INPUT_CLASS as g}from"../../lib/field-input.js";function Ee(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:u,me:o,checkoutSignOut:y}=k(),x=E();return a(w,{num:"N° 01",title:"Contact",children:[e(f,{label:"Email",htmlFor:x,hint:o?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:y,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:x,type:"email",value:t,onChange:d=>i(d.target.value),placeholder:"you@example.com",readOnly:o!==null,className:g+(o?" opacity-70":"")})}),a(M,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:d=>l(d.target.value),className:g})}),e(f,{label:"Last name",children:e("input",{type:"text",value:c,onChange:d=>u(d.target.value),className:g})})]})]})}function Fe(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:u,city:o,setCity:y,postcode:x,setPostcode:d,phone:b,setPhone:s,country:p,setCountry:m,subdivision:C,setSubdivision:h,subdivisions:A,destination:ce,postcodeLabel:U,subdivisionLabel:z,me:I,savedAddresses:L,selectedAddressId:_,setSelectedAddressId:P,saveAddress:O,setSaveAddress:D,saveLabel:H,setSaveLabel:q,fillFromAddress:G}=k(),B=E(),j=E();return a(w,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[I!==null&&L.length>0&&a("div",{className:"grid gap-3",children:[L.map(r=>e(S,{active:_===r.id,onClick:()=>{P(r.id),G(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(S,{active:_==="new",onClick:()=>P("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:g})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>u(r.target.value),placeholder:"Apartment, unit, garage bay…",className:g})}),a(M,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:o,onChange:r=>y(r.target.value),className:g})}),e(f,{label:U,children:e("input",{type:"text",value:x,onChange:r=>d(r.target.value),className:g})}),e(f,{label:"Country",separate:!0,htmlFor:B,children:e($,{id:B,value:p,onChange:r=>m(r.target.value),className:g+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:z,separate:!0,htmlFor:j,children:A.length>0?a($,{id:j,value:C,onChange:r=>h(r.target.value),className:g+" pr-10",style:Y,children:[e("option",{value:"",children:"Select…"}),A.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:C,onChange:r=>h(r.target.value),className:g})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>s(r.target.value),className:g})}),!t&&I!==null&&_==="new"&&a(N,{children:[e(le,{checked:O,onChange:D,label:"Save this address to my account"}),O&&e(f,{label:"Address label",children:e("input",{type:"text",value:H,onChange:r=>q(r.target.value),placeholder:"Home",className:g})})]})]})}function Ae(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:u,formatMoney:o,city:y,destination:x,courierUnavailable:d,retryCourier:b}=k();return e(w,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(s=>{const p=s.pickupLocation,m=p?[p.address,p.city,p.state,p.zipCode].filter(Boolean).join(", "):null;return e(S,{active:l===s.id,onClick:()=>c(s.id),title:p?`${s.name} — ${p.name}`:s.name,body:p?[m,p.openingHours,p.instructions,s.description].filter(Boolean).join(" · "):s.description||null,price:t.freeShipping||s.amount===0?F:o(s.amount,t.currency),tag:s.tag||void 0},s.id)}),d?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ie," ",e("button",{type:"button",onClick:b,className:"underline transition-colors hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ie(){const{payChoice:t,setPayChoice:i,placing:n,payment:l,payOptions:c,noPaymentMethod:u}=k();return a(w,{num:"N° 04",title:"Payment",children:[u&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:re}),e("div",{className:"grid gap-3",children:c.map(o=>e(S,{active:t===o.key,onClick:()=>i(o.key),title:o.title,body:o.body,price:o.price,tag:o.tag},o.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Le(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:u,placing:o,email:y,orderError:x,payment:d,noPaymentMethod:b,unpaidOrder:s,placeOrder:p}=k();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(T,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(T,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(m=>e(oe,{slug:m.slug,name:m.name,qty:m.qty,config:m.config,configSummary:se(m.config),price:K(m,n.currency)??0,currency:n.currency},m.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(J,{customerEmail:y})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(v,{label:"Subtotal",value:c(n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(v,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),l?.deferred&&e(v,{label:`Coupon · ${l.code}`,value:Q}),l?.valid&&l.effects?.gift&&e(v,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:F})}),e(v,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:F}):ee(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(v,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(v,{label:n.tax.name,value:te}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[x&&e(R,{role:"alert",children:x}),n.hasUnpricedLine&&a(R,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:p,disabled:o||!s&&(b||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",o||!s&&(i.length===0||b||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:o?a(N,{children:["Building order… ",e("span",{children:"·"})]}):b?a(N,{children:["No online payment ",e("span",{children:"·"})]}):s?a(N,{children:["Try payment again · ",V(s),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(N,{children:["Updating total… ",e("span",{children:"·"})]}):a(N,{children:[u==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const Y={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function w({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function M({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function S({active:t,onClick:i,title:n,body:l,price:c,tag:u}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,u&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:u})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function le({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function oe({slug:t,name:i,qty:n,config:l,configSummary:c,price:u,currency:o}){const{catalog:y}=X(),{formatMoney:x}=Z(),d=y.find(h=>h.slug===t),b=d?.spokes??5,s=d?.mesh??!1,p=l.find(h=>h.gold)?.label,m=d?.finishes.find(h=>h.name===p&&h.src)??d?.finishes.find(h=>h.src),C=d?.finishes[0]?.color??ne;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:m?.src?e(W,{src:m.src,alt:`${i.lead}${i.accent} — ${m.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(ae,{spokes:b,mesh:s,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:x(u,o)})]})}function v({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function se(t){return t.map(i=>i.label).join(" · ")}export{Ee as CheckoutContact,Le as CheckoutOrderSummary,Ie as CheckoutPayment,Fe as CheckoutShippingAddress,Ae as CheckoutShippingMethod};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type SiteIdentity } from "../../lib/content/site.js";
|
|
2
|
-
import type { ShopAddress, ShopMe } from "../../lib/api/index.js";
|
|
2
|
+
import type { OrderConfirmation, ShopAddress, ShopMe } from "../../lib/api/index.js";
|
|
3
3
|
import { type LandingOrder } from "../../lib/checkout/wallet-return.js";
|
|
4
|
+
import { type PayFirstResult } from "../../lib/checkout/pay-first.js";
|
|
4
5
|
type PayKey = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "bank";
|
|
5
6
|
interface PayOption {
|
|
6
7
|
key: PayKey;
|
|
@@ -13,7 +14,7 @@ export declare function buildPayOptions(site: SiteIdentity, { canParkContext, }?
|
|
|
13
14
|
canParkContext: boolean;
|
|
14
15
|
}): PayOption[];
|
|
15
16
|
export declare const NO_PAYMENT_METHOD_NOTE = "This shop does not take payment online yet. Please contact the shop to order.";
|
|
16
|
-
export declare function paymentNotStartedMessage(
|
|
17
|
+
export declare function paymentNotStartedMessage(conf: Pick<OrderConfirmation, "orderNumber" | "checkoutNumber">, err: unknown): string;
|
|
17
18
|
export declare const SHIPPING_RETRY_NOTE = "Shipping cannot be calculated right now. Please try again.";
|
|
18
19
|
export interface CheckoutProps {
|
|
19
20
|
site: SiteIdentity;
|
|
@@ -143,6 +144,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
143
144
|
squareStep: boolean;
|
|
144
145
|
pendingConf: {
|
|
145
146
|
orderNumber: string;
|
|
147
|
+
checkoutNumber: string;
|
|
148
|
+
expiresAt: string | null;
|
|
146
149
|
status: string;
|
|
147
150
|
total: string;
|
|
148
151
|
currency: string;
|
|
@@ -156,6 +159,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
156
159
|
setPaid: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
157
160
|
unpaidOrder: {
|
|
158
161
|
orderNumber: string;
|
|
162
|
+
checkoutNumber: string;
|
|
163
|
+
expiresAt: string | null;
|
|
159
164
|
status: string;
|
|
160
165
|
total: string;
|
|
161
166
|
currency: string;
|
|
@@ -170,6 +175,13 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
170
175
|
gocardlessConfirming: boolean;
|
|
171
176
|
zipConfirming: boolean;
|
|
172
177
|
klarnaConfirming: boolean;
|
|
178
|
+
cardConfirming: boolean;
|
|
179
|
+
checkoutResult: PayFirstResult | null;
|
|
180
|
+
confirmCardPayment: (answer?: OrderConfirmation, held?: OrderConfirmation | null) => Promise<void>;
|
|
181
|
+
cardStillProcessing: (held?: OrderConfirmation | null) => void;
|
|
182
|
+
renewCardPayment: (cancelled: boolean) => Promise<void>;
|
|
183
|
+
holdRenewed: boolean;
|
|
184
|
+
leaveCardPayment: () => void;
|
|
173
185
|
checkoutRootRef: import("react").RefObject<HTMLDivElement | null>;
|
|
174
186
|
setCheckoutHeaderEl: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
|
|
175
187
|
fillFromAddress: (a: ShopAddress) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`);return d===-1?[
|
|
3
|
-
${
|
|
1
|
+
"use client";import{jsx as N}from"react/jsx-runtime";import{createContext as an,useContext as sn,useEffect as p,useMemo as wt,useRef as y,useState as r}from"react";import{isOrderable as kt,useCart as un}from"../CartContext.js";import{useCurrency as ln}from"../CurrencyContext.js";import{getClickIds as dn}from"../../lib/click-ids.js";import{adConsentForOrder as pn}from"../../lib/consent/choice.js";import{trackBeginCheckout as mn,trackPurchase as fn}from"../../lib/google-tag.js";import{trackMetaPurchase as yn}from"../../lib/meta-pixel.js";import{ApiError as ye,api as X,products as m}from"../../lib/api/index.js";import{uuid as Ie}from"../../lib/uuid.js";import{orderLinesForSets as hn}from"../../lib/commerce.js";import{canPersist as gn,safeSessionStorage as k}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as wn,AFTERPAY_RETURN as kn,GOCARDLESS_CONTEXT_KEY as Te,KLARNA_CONTEXT_KEY as Ke,ZIP_CONTEXT_KEY as Cn,ZIP_RETURN as bn,runWalletReturn as Ct}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Nn}from"../../lib/checkout/match-subdivision.js";import{checkoutGone as bt,DROPPABLE_INTENT as Pn,NOT_CHECKED as Sn,PAY_FIRST_FLOW as An,paysFirst as vn,readIntentStatus as xn,settlePayFirst as En}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as Nt,couponRefusedByOrder as On}from"../../lib/cart/coupon-preview.js";function Pt(c){const d=c.indexOf(`
|
|
2
|
+
`);return d===-1?[c,""]:[c.slice(0,d),c.slice(d+1)]}function St(c,{canParkContext:d}={canParkContext:!0}){const u=c.paymentMethods,i=[];return u.includes("card")&&i.push({key:"card",title:"Card",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),u.includes("paypal")&&c.paypalClientId&&i.push({key:"paypal",title:"PayPal",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),u.includes("afterpay")&&i.push({key:"afterpay",title:"Afterpay",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),u.includes("square")&&c.squareApplicationId&&c.squareLocationId&&i.push({key:"square",title:"Card (Square)",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),u.includes("gocardless")&&d&&i.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),u.includes("zip")&&i.push({key:"zip",title:"Zip",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),u.includes("klarna")&&d&&i.push({key:"klarna",title:"Klarna",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),u.includes("bank")&&i.push({key:"bank",title:"Bank transfer",body:null,price:N("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),i}const Zn="This shop does not take payment online yet. Please contact the shop to order.";function In(c,d){if(!c.orderNumber&&bt(d))return d.message;const u=d instanceof ye?` (${d.message})`:"";return c.orderNumber?`Your order ${c.orderNumber} is saved, but the payment did not start${u}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${c.checkoutNumber}, but the payment did not start${u}. Try the payment again — you will not be charged twice.`}const Wn="Shipping cannot be calculated right now. Please try again.";function Tn({site:c,logo:d,preview:u=!1}){const{items:i,totals:P,coupon:T,refuseCoupon:vt,deliveryOptions:Re,shippingMethodId:Z,setShippingMethodId:xt,setQuoteDestination:W,courier:Et,requote:Ot,identify:_e,clearCapturedCart:K,replaceItems:Me,removeCoupon:Le}=un(),It=Re.find(e=>e.id===Z)?.pickupLocation??null,{country:$e,countries:B,activeCountry:Ye,formatMoney:Tt}=ln(),[g,he]=r(()=>St(c)[0]?.key??null),[Ue,Kt]=r(!0);p(()=>{Kt(gn(k))},[]);const[j,S]=r(!1),[F,ge]=r(""),[O,we]=r(""),[z,ke]=r(""),[Q,V]=r(""),[Ce,ee]=r(""),[R,te]=r(""),[I,ne]=r(""),[D,re]=r(""),[s,oe]=r(()=>$e||B[0]?.code||""),[A,ce]=r(""),[H,qe]=r([]),[be,Ne]=r(null),[ae,J]=r(null),Be=wt(()=>B.find(e=>e.code===s)??Ye,[B,s,Ye]),Rt=Be?.postalLabel||"Postal Code",_t=H[0]?.divisionType||"State / Province";p(()=>{if(!s){qe([]),Ne(s);return}Ne(null);let e=!1;return m.listCountrySubdivisions(s).then(t=>{e||(qe(t),Ne(s),ce(""))}),()=>{e=!0}},[s]);const Fe=Q.trim()!==""&&R.trim()!==""&&I.trim()!==""&&be===s&&(H.length===0||A!=="")?I.trim():"";p(()=>{W(s?{country:s,subdivision:A,postcode:Fe}:null)},[s,A,Fe,W]),p(()=>()=>W(null),[W]);const Mt=Et?.status==="unavailable",Lt=Ot,[se,ze]=r(null),[$t,De]=r([]),[He,Pe]=r("new"),[Je,Ge]=r(!1),[Se,Yt]=r("Home"),[Ut,Xe]=r(null),[f,Ze]=r(()=>Ie()),We=y(null),[je,w]=r(null),[qt,C]=r(null),[Qe,ie]=r(null),[Ve,Bt]=r(!1),[et,Ft]=r(!1),[v,_]=r(null),[zt,M]=r(!1),[h,L]=r(null),[Dt,b]=r(null),[Ht,Jt]=r(!1),[Gt,tt]=r(!1),[Xt,Zt]=r(!1),[Wt,nt]=r(!1),[rt,jt]=r(!1),[Qt,Ae]=r(!1),[ve,ot]=r(null),ue=y(null),xe=y(i),ct=!!(je||ve&&ve.kind!=="processing"||rt||Ve||et||Qe&&v?.orderNumber);p(()=>{ct&&(Me([]),Le())},[ct,Me,Le]);const at=y(!1);p(()=>{u||at.current||!i.some(kt)||(at.current=!0,mn({lines:i,currency:P.currency,value:P.subtotal-P.discount,coupon:T?.valid?T.code:void 0}))},[i,P,T,u]),p(()=>{_e(F,O.trim()||void 0)},[F,O,_e]);const st=y(null),[le,Vt]=r(null);p(()=>{const e=st.current;if(!le||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${le.offsetHeight}px`);t();const n=new ResizeObserver(t);return n.observe(le),()=>n.disconnect()},[le]),p(()=>{const e=n=>({setConfirming:n,land:w,markPaid:()=>M(!0),note:b,fail:C,clearCart:K}),t={search:window.location.search,storage:k,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Ct(kn,{...t,capture:m.captureAfterpayPayment,page:e(Jt)}),Ct(bn,{...t,capture:m.captureZipPayment,page:e(Zt)})},[]),p(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const n=k.getItem(Te);if(k.removeItem(Te),window.history.replaceState(null,"",window.location.pathname),!n)return;let o;try{o=JSON.parse(n)}catch{return}if(K(),t==="cancel"){b("The direct debit was not set up — our team will follow up on payment."),w(o.confirmation);return}tt(!0),m.completeGocardlessPayment({idempotencyKey:o.idempotencyKey}).then(a=>{a.status==="paid"?M(!0):a.status==="declined"?b("The direct debit was declined — our team will follow up on payment."):b("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{b("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{w(o.confirmation),tt(!1)})},[]),p(()=>{const e=new URLSearchParams(window.location.search),t=e.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const n=k.getItem(Ke);k.removeItem(Ke);const o=e.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!n)return;let a;try{a=JSON.parse(n)}catch{return}if(K(),t==="cancel"||!o){b("The Klarna payment was not completed — our team will follow up on payment."),w(a.confirmation);return}nt(!0),m.captureKlarnaPayment({idempotencyKey:a.idempotencyKey,authorizationToken:o}).then(l=>{l.status==="paid"?M(!0):l.status==="declined"?b("Klarna declined the payment — our team will follow up on payment."):b("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{b("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{w(a.confirmation),nt(!1)})},[]);function it(e){const[t,n]=Pt(e.address);V(t),ee(n),te(e.city),ne(e.zip_code),e.country&&oe(e.country),e.phone&&re(e.phone),J({country:e.country||null,state:e.state??""})}p(()=>{if(ae){if((ae.country||s)!==s){J(null);return}be===s&&(ce(Nn(s,ae.state,H)),J(null))}},[ae,s,be,H]),p(()=>{let e=!1;return(async()=>{try{const[t,n,o]=await Promise.all([X.me(),X.myProfile().catch(()=>null),X.myAddresses().catch(()=>[])]);if(e)return;ze(t);const a=o.filter(G=>G.is_active);De(a),ge(t.email);const l=(n?.contact_name??"").split(/\s+/);we(t.first_name||l[0]||""),ke(t.last_name||l.slice(1).join(" "));const gt=t.phone||n?.phone;gt&&re(gt);const Oe=a.find(G=>G.id===t.default_delivery_location)??a[0];if(Oe)Pe(Oe.id),it(Oe);else if(n){const[G,cn]=Pt(n.address??"");V(G),ee(cn),te(n.city??""),ne(n.zip_code??""),n.country&&oe(n.country),J({country:n.country||null,state:n.state??""})}}catch{}})(),()=>{e=!0}},[]);function en(){X.logout(),ze(null),De([]),Pe("new"),Ge(!1),ge(""),we(""),ke(""),V(""),ee(""),te(""),ne(""),re(""),oe($e||B[0]?.code||""),ce(""),J(null)}const $=wt(()=>St(c,{canParkContext:Ue}),[c,Ue]);p(()=>{$.some(e=>e.key===g)||he($[0]?.key??null)},[$,g]);const tn=$.length===0,de=Ce.trim()?`${Q}
|
|
3
|
+
${Ce.trim()}`:Q,x=JSON.stringify([F,O,z,D,de,R,A,I,s,i.map(e=>[e.id,e.qty]),Z,Nt(T),g,P.currency,se?.id??null]),pe=y(null),E=y(!1),Y=y(null),me=y(!1),Ee=y(x);Ee.current=x;const ut=y(j);ut.current=j;const lt=()=>E.current&&Ee.current!==pe.current,U=y(null);p(()=>{ut.current||(x!==U.current&&(U.current=null),!(!E.current||!h||h.orderNumber)&&(x===pe.current||x===U.current||fe(h)))},[x,h]);async function fe(e){if(!me.current){me.current=!0,S(!0);try{const t=Y.current?await xn(Y.current):"none";if(t==="succeeded"||t==="processing"){E.current=!1,L(null),t==="succeeded"?await q(void 0,e):pt(e);return}if(t===void 0||!Pn.has(t)){U.current=Ee.current,L(e),C(Sn);return}E.current=!1,Y.current=null,U.current=null,C(null),L(null),Ze(Ie())}finally{me.current=!1,S(!1)}}}async function nn(){if(u||j||me.current)return;if(h){if(E.current&&!h.orderNumber&&x!==pe.current){await fe(h);return}S(!0),C(null),await mt();const n=h.orderNumber?g:"card";n!==g&&he(n),await ft(h,n,!h.orderNumber);return}if(i.length===0||P.repricing||!g||!$.some(n=>n.key===g))return;const e=i.filter(kt).flatMap(n=>hn(n.components,n.qty));if(e.length===0){C("Pick a size on each wheel's product page before checking out.");return}S(!0),C(null);let t;try{const n=se?m.createOrderAuthed:m.createOrder,o=pn(),a={customer:{email:F,name:`${O} ${z}`.trim(),phone:D.trim()||void 0,address:de,city:R,state:A||void 0,zipCode:I,country:s},items:e,currency:P.currency,idempotencyKey:f,shippingMethodId:Z??void 0,couponCode:Nt(T),...o==="denied"?{}:dn(),...o?{adConsent:o}:{},...vn(g)?{checkoutFlow:An}:{}};ue.current=()=>n(a),Y.current=null,E.current=!1,U.current=null,pe.current=x,xe.current=i,t=await n(a),t.orderNumber&&(dt(t),K()),await mt()}catch(n){const o=On(n);o?(vt(o),C(`${o} Your order has not been placed. Place it again to continue without the code.`)):C(n instanceof ye?n.message:"Could not place the order. Please try again."),S(!1);return}await ft(t)}function dt(e){fn({confirmation:e,lines:xe.current,adsSendTo:c.googleAdsId&&c.googleAdsConversionLabel?`${c.googleAdsId}/${c.googleAdsConversionLabel}`:null}),yn({confirmation:e,lines:xe.current})}async function q(e,t=v){if(!t)return;const n=e?async()=>e:ue.current;if(t.orderNumber||!n){M(!0),w(t);return}K(),await En({checkoutNumber:t.checkoutNumber,resend:n,page:{setConfirming:jt,land:w,markPaid:()=>M(!0),track:dt,unplaced:ot}})}function pt(e=v){if(e){if(e.orderNumber){w(e);return}K(),ot({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function mt(){const e=JSON.stringify([Se.trim(),O,z,D.trim(),de,R,A,I,s]);if(!(!se||!Je||He!=="new"||We.current===e))try{await X.createAddress({label:Se.trim()||"Home",contact_name:`${O} ${z}`.trim(),phone:D.trim(),address:de,city:R,zip_code:I,state:A,country:s}),We.current=e,Xe("Address saved to your account.")}catch{Xe("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function ft(e,t=g,n=!1){L(null);try{if(t==="card"&&c.paymentMethods.includes("card")){const o=await m.createPaymentIntent({idempotencyKey:f});if(Y.current=o,n&<()){await fe(e);return}let a=e;if(n){const l=await ue.current?.().catch(()=>null);if(l?.orderNumber){await q(l,e);return}if(a=yt(e,l)??{...e,expiresAt:null},lt()){await fe(e);return}}_(a),Ae(!1),ie(o)}else if(t==="paypal"&&c.paymentMethods.includes("paypal"))_(e),Bt(!0);else if(t==="afterpay"&&c.paymentMethods.includes("afterpay")){const o=window.location.origin,a=await m.createAfterpayCheckout({idempotencyKey:f,confirmUrl:`${o}/checkout?afterpay=confirm`,cancelUrl:`${o}/checkout?afterpay=cancel`}),l={idempotencyKey:f,confirmation:e};k.setItem(wn,JSON.stringify(l)),window.location.assign(a.redirectCheckoutUrl);return}else if(t==="square"&&c.paymentMethods.includes("square"))_(e),Ft(!0);else if(t==="gocardless"&&c.paymentMethods.includes("gocardless")){const o=window.location.origin,a=await m.createGocardlessBillingRequest({idempotencyKey:f,confirmUrl:`${o}/checkout?gocardless=confirm`,cancelUrl:`${o}/checkout?gocardless=cancel`}),l={idempotencyKey:f,confirmation:e};k.setItem(Te,JSON.stringify(l)),window.location.assign(a.authorisationUrl);return}else if(t==="zip"&&c.paymentMethods.includes("zip")){const o=window.location.origin,a=await m.createZipCheckout({idempotencyKey:f,redirectUrl:`${o}/checkout?zip=return`}),l={idempotencyKey:f,confirmation:e};k.setItem(Cn,JSON.stringify(l)),window.location.assign(a.redirectUrl);return}else if(t==="klarna"&&c.paymentMethods.includes("klarna")){const o=window.location.origin,a=await m.createKlarnaCheckout({idempotencyKey:f,confirmUrl:`${o}/checkout?klarna=confirm`,cancelUrl:`${o}/checkout?klarna=cancel`}),l={idempotencyKey:f,confirmation:e};k.setItem(Ke,JSON.stringify(l)),window.location.assign(a.redirectUrl);return}else w(e)}catch(o){if(n&&o instanceof ye&&o.status===409){await q(void 0,e);return}ht(e,o),S(!1)}}function yt(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function ht(e,t){C(In(e,t)),!e.orderNumber&&bt(t)?(E.current=!1,Ze(Ie())):L(e)}async function rn(e){if(!v)return;const t=v;try{const n=await m.createPaymentIntent({idempotencyKey:f}),o=await ue.current?.().catch(()=>null);if(o?.orderNumber){await q(o);return}const a=yt(t,o);_(a??{...t,expiresAt:null}),Ae(e&&a!==null),Y.current=n,ie(n)}catch(n){if(n instanceof ye&&n.status===409){await q();return}ie(null),_(null),ht(t,n),S(!1)}}function on(){v&&(E.current=!0,L(v),ie(null),_(null),Ae(!1),S(!1))}return{site:c,logo:d,items:i,totals:P,coupon:T,deliveryOptions:Re,courierUnavailable:Mt,retryCourier:Lt,shippingMethodId:Z,setShippingMethodId:xt,pickupLocation:It,servedCountries:B,formatMoney:Tt,payChoice:g,setPayChoice:he,placing:j,email:F,setEmail:ge,firstName:O,setFirstName:we,lastName:z,setLastName:ke,address1:Q,setAddress1:V,address2:Ce,setAddress2:ee,city:R,setCity:te,postcode:I,setPostcode:ne,phone:D,setPhone:re,country:s,setCountry:oe,subdivision:A,setSubdivision:ce,subdivisions:H,destination:Be,postcodeLabel:Rt,subdivisionLabel:_t,me:se,savedAddresses:$t,selectedAddressId:He,setSelectedAddressId:Pe,saveAddress:Je,setSaveAddress:Ge,saveLabel:Se,setSaveLabel:Yt,addressSaveNote:Ut,idemKey:f,confirmation:je,setConfirmation:w,orderError:qt,payment:Qe,paypalStep:Ve,squareStep:et,pendingConf:v,paid:zt,setPaid:M,unpaidOrder:h,payNote:Dt,afterpayConfirming:Ht,gocardlessConfirming:Gt,zipConfirming:Xt,klarnaConfirming:Wt,cardConfirming:rt,checkoutResult:ve,confirmCardPayment:q,cardStillProcessing:pt,renewCardPayment:rn,holdRenewed:Qt,leaveCardPayment:on,checkoutRootRef:st,setCheckoutHeaderEl:Vt,fillFromAddress:it,checkoutSignOut:en,payOptions:$,noPaymentMethod:tn,placeOrder:nn}}const At=an(null);function jn({children:c,...d}){const u=Tn(d);return N(At.Provider,{value:u,children:c})}function Qn(){const c=sn(At);if(!c)throw new Error("useCheckout must be used inside CheckoutStateProvider");return c}export{jn as CheckoutStateProvider,Zn as NO_PAYMENT_METHOD_NOTE,Wn as SHIPPING_RETRY_NOTE,St as buildPayOptions,In as paymentNotStartedMessage,Qn as useCheckout};
|
|
@@ -8,10 +8,11 @@ export default function TyreHeroFitment({ slug, variants, vehicle, manualMode, s
|
|
|
8
8
|
manualMode: boolean;
|
|
9
9
|
setManualMode: (fn: (m: boolean) => boolean) => void;
|
|
10
10
|
}): import("react").JSX.Element;
|
|
11
|
-
export declare function TyreHeroVerdict({ answer, loading, car, variants, onChange, }: {
|
|
11
|
+
export declare function TyreHeroVerdict({ answer, loading, car, variants, onChange, onRetry, }: {
|
|
12
12
|
answer: TyreFitAnswer | null;
|
|
13
13
|
loading: boolean;
|
|
14
14
|
car: string;
|
|
15
15
|
variants: readonly TyreVariant[];
|
|
16
16
|
onChange: () => void;
|
|
17
|
+
onRetry?: () => void;
|
|
17
18
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as p}from"react/jsx-runtime";import g from"next/link";import{Notice as f}from"../Notice.js";import b from"./VehicleQuestion.js";import{useTyreFitAnswer as k}from"../useTyreFitAnswer.js";import{TYRE_FIT_LABEL as x,tyreFitHeadline as N}from"../../lib/tyres/tyre-fit-copy.js";import{TYRE_FIT_CHIP as y,tyreFitSizeChips as F}from"../../lib/tyres/tyre-size-fit.js";import{tyreFitQuery as v}from"../../lib/tyres/tyre-vehicle-fitment.js";function C({slug:r,variants:u,vehicle:n,manualMode:o,setManualMode:m}){const{answer:l,loading:s,retry:i}=k(r,o?null:v(n.applied?.vehicle)),a=n.appliedName;return e(b,{vehicle:n,escape:e("button",{type:"button",className:"cursor-pointer text-right text-accent hover:underline",onClick:()=>m(d=>!d),children:o?"← Find by vehicle":"Select by specs instead →"}),override:o?t(f,{tone:"quiet",children:[e("strong",{className:"font-semibold text-fg",children:"You are choosing by size."}),t("span",{className:"mt-2 block",children:["Pick the size above. We have not checked it against any car — make sure it matches the placard on your door."," ",e(g,{href:"/contact",className:"text-accent hover:underline",children:"Ask us if you are unsure →"})]})]}):null,verdict:e(z,{answer:l,loading:s,car:a,variants:u,onChange:n.clear,onRetry:i}),showChangeCar:!1,cascadeErrorNote:t(p,{children:["Vehicle data is unavailable right now. Pick your size above, or"," ",e(g,{href:"/contact",className:"text-accent hover:underline",children:"ask us to check it →"})]})})}function z({answer:r,loading:u,car:n,variants:o,onChange:m,onRetry:l}){if(u||!r)return t(f,{tone:"quiet",children:[e("strong",{className:"font-semibold text-fg",children:"Checking your car…"})," ",t("span",{children:["Reading the factory tyre sizes for your ",n,"."]})]});const s=F(r,o),i=r.status==="doesNotFit"?"You can still order any size here — check it suits your car first.":"",a=s.length===0?N(r):"",d=a&&i?`${a} ${i}`:a||i;return t(f,{tone:r.status==="fits"?"good":"quiet",children:[t("span",{className:"block",children:[r.status==="fits"?t("strong",{className:"font-semibold text-accent",children:["✓ Made in a size your ",n," takes"]}):r.status==="doesNotFit"?t("strong",{className:"font-semibold text-fg",children:["Not made in a size your ",n," takes"]}):r.failed?t("strong",{className:"font-semibold text-fg",children:["We couldn’t check this tyre against your ",n]}):t("strong",{className:"font-semibold text-fg",children:["We cannot check this tyre against your ",n]}),t("span",{className:"whitespace-nowrap",children:[" · ",e("button",{type:"button",onClick:m,"aria-label":`Change car - forget ${n} and ask again`,className:"cursor-pointer font-mono uppercase tracking-[0.16em] text-accent underline underline-offset-4 hover:text-fg",children:"Change car"})]})]}),d?e("span",{className:"mt-2 block",children:d}):null,r.failed&&l?e("button",{type:"button",onClick:l,className:"mt-2 cursor-pointer font-mono uppercase tracking-[0.16em] text-accent underline underline-offset-4 hover:text-fg",children:"Try again"}):null,s.length>0?t(p,{children:[e("span",{className:"mt-2 block",children:"Your car takes:"}),e("ul",{className:"mt-2 flex flex-wrap gap-2",children:s.map(c=>{const h=c.made?y.fits:y.doesNotFit;return e("li",{className:"border border-line px-2 py-1 font-mono text-[11px] uppercase tracking-[0.14em] text-fg-dim",style:h.color?{color:h.color,borderColor:h.color}:void 0,children:c.made?`${c.size} · ${x.fits}`:c.size},c.size)})})]}):null]})}export{z as TyreHeroVerdict,C as default};
|
|
@@ -11,7 +11,3 @@ export default function VehicleQuestion({ vehicle, escape, override, verdict, sh
|
|
|
11
11
|
export declare function HeroVehicleMemory({ vehicle }: {
|
|
12
12
|
vehicle: VehicleControl;
|
|
13
13
|
}): import("react").JSX.Element | null;
|
|
14
|
-
export declare function Box({ tone, children }: {
|
|
15
|
-
tone: "good" | "bad" | "quiet";
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as t}from"react/jsx-runtime";import
|
|
1
|
+
"use client";import{jsx as a,jsxs as t}from"react/jsx-runtime";import s from"../fitment/FitmentPickerGrid.js";function d({vehicle:e,escape:r,override:n,verdict:c,showChangeCar:i,cascadeErrorNote:l}){const o=e.appliedName!=="";return t("div",{className:"pb-2",children:[t("div",{className:"mb-3 flex items-center justify-between gap-4 font-mono text-[13px] font-semibold uppercase tracking-[0.2em] text-fg",children:[a("span",{children:"Vehicle Fitment"}),r]}),n?a("div",{className:"flex flex-col gap-3",children:n}):o?t("div",{className:"flex flex-col gap-3",children:[c,i&&a("div",{children:a("button",{type:"button",onClick:e.clear,"aria-label":`Change car - forget ${e.appliedName} and ask again`,className:"cursor-pointer font-mono text-[12px] uppercase tracking-[0.16em] text-accent underline underline-offset-4 hover:text-fg",children:"Change car"})})]}):t("div",{className:"flex flex-col gap-3",children:[a(s,{cascade:e.cascade,compact:!0}),e.cascade.cascadeError&&a("p",{className:"font-mono text-[12px] leading-relaxed tracking-[0.1em] text-fg-dim",children:l})]})]})}function f({vehicle:e}){return e.appliedName?t("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border border-accent px-3 py-2 font-mono text-[12px] tracking-[0.1em] text-fg-dim",style:{background:"color-mix(in oklab, var(--accent) 8%, transparent)"},children:[t("span",{children:["Showing fitment for your"," ",a("strong",{className:"font-semibold text-fg",children:e.appliedName})]}),a("button",{type:"button",onClick:e.clear,"aria-label":`Change car - forget ${e.appliedName} and ask again`,className:"ml-auto cursor-pointer uppercase tracking-[0.16em] text-accent underline underline-offset-4 hover:text-fg",children:"Change car"})]}):null}export{f as HeroVehicleMemory,d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n,Fragment as g}from"react/jsx-runtime";import o from"next/link";import
|
|
1
|
+
"use client";import{jsx as e,jsxs as n,Fragment as g}from"react/jsx-runtime";import o from"next/link";import{Notice as s}from"../Notice.js";import b from"./VehicleQuestion.js";import{resolvingRowsAnswered as w}from"../../lib/catalog/product-options.js";import{fitRefusal as h,pdpFitVerdict as x}from"../../lib/wheels/pdp-fit-verdict.js";import{variantIsDually as k}from"../../lib/wheels/set-mode.js";function N({selection:a,spec:r,vehicle:t,wheel:l}){const{manualMode:c,setManualMode:d}=a,m=w(a.rows,a.preOrder),u=t.appliedName!=="",f=(l?.variants??[]).some(k),i=x({wheel:l,applied:u,fit:t.fit,resolving:t.resolving});return e(b,{vehicle:t,escape:e("button",{type:"button",className:"cursor-pointer text-right text-accent hover:underline",onClick:()=>d(p=>!p),children:c?"← Find by vehicle":"Select by specs instead →"}),override:c?n(s,{tone:"quiet",children:[e("strong",{className:"font-semibold text-fg",children:"You are choosing by the numbers."}),n("span",{className:"mt-2 block",children:[r?`${f?"The set is":"All four wheels are"} ${r}. We have not checked that against any car — make sure it matches yours.`:m?"Answer the bolt pattern and the offset below. We will not check them against a car.":"Pick a finish and a size below. The bolt pattern and the offset come next, and we will not check them against a car."," ",e(o,{href:"/fitment",className:"text-accent hover:underline",children:"Talk to an engineer →"})]})]}):null,verdict:e(y,{verdict:i,car:t.appliedName}),showChangeCar:i.state!=="fits"&&i.state!=="checking",cascadeErrorNote:n(g,{children:["Vehicle data is unavailable right now. Pick your wheel by its specs instead, or"," ",e(o,{href:"/contact",className:"text-accent hover:underline",children:"ask us to check it →"})]})})}function y({verdict:a,car:r}){switch(a.state){case"checking":return n(s,{tone:"quiet",children:[e("strong",{className:"font-semibold text-fg",children:"Checking fitment…"})," ",n("span",{children:["Reading the factory wheel specs for your ",r,"."]})]});case"fits":return n(s,{tone:"good",children:[n("strong",{className:"font-semibold text-accent",children:["✓ Fits your ",r]}),e("ul",{className:"mt-2 flex flex-wrap gap-2",children:a.checks.map(t=>e("li",{className:["px-2 py-1 font-mono text-[11px] uppercase tracking-[0.14em] text-fg-dim",t.value!==null?"border border-line":"border border-dashed border-line"].join(" "),children:t.value??`${t.name} not published, not checked`},t.key))})]});case"fits-with-warning":return n(s,{tone:"good",children:[n("strong",{className:"font-semibold text-accent",children:["✓ Fits your ",r]}),e("ul",{className:"mt-2 flex flex-wrap gap-2",children:a.checks.map(t=>e("li",{className:["px-2 py-1 font-mono text-[11px] uppercase tracking-[0.14em] text-fg-dim",t.value!==null?"border border-line":"border border-dashed border-line"].join(" "),children:t.value??`${t.name} not published, not checked`},t.key))}),n("span",{className:"mt-2 block border-l-2 border-alert pl-3",children:[e("strong",{className:"font-semibold text-fg",children:"Check the offset. "}),h(a.warning)," An offset this far out is what an aftermarket wheel is for, but it changes how far the wheel sits from the guard."," ",e(o,{href:"/contact",className:"text-accent hover:underline",children:"Ask us if you are unsure →"})]})]});case"no-fit":return n(s,{tone:"bad",children:[n("strong",{className:"font-semibold",style:{color:"var(--alert)"},children:["✗ Does not fit your ",r]}),e("span",{className:"mt-2 block",children:h(a.failure)})]});case"unknown":return n(s,{tone:"quiet",children:[e("strong",{className:"font-semibold text-fg",children:a.missing==="vehicle"?`We cannot check this wheel against your ${r}`:"We cannot check this wheel"}),n("span",{className:"mt-2 block",children:[a.missing==="vehicle"?`We have no factory wheel data for the ${r}, and we will not guess at a fit.`:"We do not hold a bolt pattern for this wheel, and we will not guess at a fit."," ",e(o,{href:"/contact",className:"text-accent hover:underline",children:"Ask us before you order →"})]})]});default:return null}}export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useCallback as A,useEffect as F,useState as u}from"react";import{loadTyreVehicleFitment as T}from"../lib/tyres/tyre-vehicle-fitment.js";function E(c,t){const[d,s]=u(null),[y,r]=u(!1),[k,p]=u(0),w=A(()=>p(n=>n+1),[]),l=t?.make??"",a=t?.model??"",e=t?.year??null,i=t?.modification??"",m=t!==null;return F(()=>{if(!m||e===null){s(null),r(!1);return}let n=!0;return s(null),r(!0),T(c,{make:l,model:a,year:e,modification:i}).then(f=>{if(!n)return;const o=f.vehicle;o.make!==l||o.model!==a||o.year!==e||o.modification!==i||(s(f),r(!1))}),()=>{n=!1}},[c,l,a,e,i,m,k]),{answer:d,loading:y,retry:w}}export{E as useTyreFitAnswer};
|
|
@@ -309,6 +309,9 @@ export type CouponFreeUnit = components["schemas"]["CouponFreeUnit"];
|
|
|
309
309
|
export type BlogPostSummary = components["schemas"]["BlogPostStub"];
|
|
310
310
|
export type BlogPostDetail = components["schemas"]["BlogPost"];
|
|
311
311
|
export { PRODUCT_API_BASE } from "./origins.js";
|
|
312
|
+
export type ListReadOpts = {
|
|
313
|
+
throwOnFailure?: boolean;
|
|
314
|
+
};
|
|
312
315
|
export declare function resolveSiteHost(): Promise<string | null>;
|
|
313
316
|
export declare function resolveSiteHostSource(): Promise<{
|
|
314
317
|
host: string | null;
|
|
@@ -327,11 +330,11 @@ export declare const fitment: {
|
|
|
327
330
|
getStockFitment: (make: string, model: string, year: number, modification: string, region?: string) => Promise<StockFitment | null>;
|
|
328
331
|
};
|
|
329
332
|
export declare const products: {
|
|
330
|
-
listWheels: (process?: string | null) => Promise<WheelSummary[]>;
|
|
333
|
+
listWheels: (process?: string | null, opts?: ListReadOpts) => Promise<WheelSummary[]>;
|
|
331
334
|
listCatalog: (kinds: readonly ProductKind[], vehicle?: TyreFitVehicleQuery | null) => Promise<ProductSummary[]>;
|
|
332
335
|
getWheel: (slug: string) => Promise<Wheel>;
|
|
333
336
|
getTyre: (slug: string) => Promise<Tyre>;
|
|
334
|
-
listBundles: () => Promise<Bundle[]>;
|
|
337
|
+
listBundles: (opts?: ListReadOpts) => Promise<Bundle[]>;
|
|
335
338
|
getBundle: (slug: string) => Promise<Bundle>;
|
|
336
339
|
listGalleryBuilds: (opts?: {
|
|
337
340
|
process?: Process | null;
|
|
@@ -351,7 +354,7 @@ export declare const products: {
|
|
|
351
354
|
revalidate?: number;
|
|
352
355
|
record?: string;
|
|
353
356
|
}) => Promise<Page>;
|
|
354
|
-
listBlogPosts: (opts?: NonNullable<operations["listBlogPosts"]["parameters"]["query"]
|
|
357
|
+
listBlogPosts: (opts?: NonNullable<operations["listBlogPosts"]["parameters"]["query"]>, { throwOnFailure }?: ListReadOpts) => Promise<BlogPostSummary[]>;
|
|
355
358
|
getBlogPost: (slug: string) => Promise<BlogPostDetail>;
|
|
356
359
|
createOrder: (body: OrderRequest) => Promise<OrderConfirmation>;
|
|
357
360
|
createOrderAuthed: (body: OrderRequest) => Promise<OrderConfirmation>;
|