efficient-storefront-blocks 0.108.0 → 0.110.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 +49 -0
- package/dist/chunks/EditorPreviewCheckout-2JRQSG4O.js +4 -0
- package/dist/chunks/{SiteEditorProvider-HUBOWTZX.js → SiteEditorProvider-P4HVFXUX.js} +1 -1
- package/dist/chunks/chunk-CPAF23MT.js +1 -0
- package/dist/chunks/chunk-FRCI3FAV.js +80 -0
- package/dist/chunks/{chunk-S63IHMZT.js → chunk-GB6OHYUY.js} +1 -1
- package/dist/chunks/{chunk-QRXGHD3Z.js → chunk-MVJVIU2F.js} +1 -1
- package/dist/chunks/chunk-RFFTWKCU.js +340 -0
- package/dist/chunks/{fitment-data-SMH4TOUX.js → fitment-data-EGBXHTFW.js} +1 -1
- package/dist/contract.js +8 -2
- package/dist/editor/components/BlogSource.d.ts +1 -1
- package/dist/editor/components/BlogSource.js +1 -1
- package/dist/editor/lib/efficient-backend.js +1 -1
- package/dist/index.js +32 -32
- package/dist/links.js +1 -1
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/CartContext.d.ts +3 -0
- package/dist/render/components/CartContext.js +1 -1
- package/dist/render/components/Events.d.ts +2 -1
- package/dist/render/components/Events.js +1 -1
- package/dist/render/components/FooterLogo.js +1 -1
- package/dist/render/components/ProductHeroPanel.js +1 -1
- package/dist/render/components/cart/drawer-parts.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-parts.d.ts +11 -0
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +5 -0
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/lib/checkout/checkout-memory.d.ts +62 -0
- package/dist/render/lib/checkout/checkout-memory.js +1 -0
- package/dist/render/lib/content/event-post.d.ts +5 -0
- package/dist/render/lib/content/event-post.js +1 -0
- package/dist/render/lib/document/blocks/service/Events/render.js +1 -1
- package/dist/render/lib/wheels/price-display.d.ts +2 -0
- package/dist/render/lib/wheels/price-display.js +1 -1
- package/dist/render/lib/wheels/selected-ranges.d.ts +1 -0
- package/dist/render/lib/wheels/selected-ranges.js +1 -1
- package/dist/words.d.ts +1 -0
- package/dist/words.js +1 -1
- package/package.json +3 -3
- package/dist/chunks/EditorPreviewCheckout-R7YOGDSN.js +0 -4
- package/dist/chunks/chunk-3PIAT5RJ.js +0 -339
- package/dist/chunks/chunk-5VKKFDMK.js +0 -74
- package/dist/chunks/chunk-CS32ZWYC.js +0 -1
- /package/dist/chunks/{chunk-3PIAT5RJ.js.LEGAL.txt → chunk-RFFTWKCU.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as k,jsxs as a}from"react/jsx-runtime";import{useId as E}from"react";import X from"next/image";import Y from"next/link";import{lineTotal as Z,useCart as J}from"../CartContext.js";import{useCurrency as Q}from"../CurrencyContext.js";import{Notice as F}from"../Notice.js";import{FREE_PRICE as O}from"../../lib/wheels/price-display.js";import ee from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as te}from"../../lib/cart/coupon-preview.js";import{orderReference as ne}from"../../lib/checkout/pay-first.js";import{shippingWords as ae,TAX_PENDING as re}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ie}from"../../lib/wheels/finish-defaults.js";import D from"../ThemedSelect.js";import x from"../WebFormField.js";import le from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as oe,placedOrderLockNote as se,SHIPPING_RETRY_NOTE as ce,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as I}from"../../lib/field-input.js";function Pe(){const{email:t,setEmail:i,firstName:n,setFirstName:o,lastName:m,setLastName:h,company:s,setCompany:v,me:b,checkoutSignOut:f,orderLocked:d,unpaidOrder:g}=w(),c=E();return a(S,{num:"N° 01",title:"Contact",children:[d&&g&&e(de,{orderNumber:g.orderNumber}),e(x,{label:"Email",htmlFor:c,hint:b?a(k,{children:["Signed in ·"," ",e("button",{type:"button",onClick:f,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:c,type:"email",value:t,onChange:l=>i(l.target.value),placeholder:"you@example.com",readOnly:b!==null,disabled:d,className:I+(b||d?P:"")})}),a(U,{children:[e(x,{label:"First name",children:e("input",{type:"text",value:n,onChange:l=>o(l.target.value),disabled:d,className:N(d)})}),e(x,{label:"Last name",children:e("input",{type:"text",value:m,onChange:l=>h(l.target.value),disabled:d,className:N(d)})})]}),e(x,{label:"Company (optional)",children:e("input",{type:"text",value:s,onChange:l=>v(l.target.value),autoComplete:"organization",disabled:d,className:N(d)})})]})}function Ae(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:o,address2:m,setAddress2:h,city:s,setCity:v,postcode:b,setPostcode:f,phone:d,setPhone:g,country:c,setCountry:l,subdivision:u,setSubdivision:y,subdivisions:A,destination:he,postcodeLabel:q,subdivisionLabel:H,me:B,savedAddresses:T,selectedAddressId:_,setSelectedAddressId:R,saveAddress:$,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:V,orderLocked:p}=w(),M=E(),j=E();return a(S,{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(k,{children:[B!==null&&T.length>0&&a("div",{className:"grid gap-3",children:[T.map(r=>e(L,{active:_===r.id,disabled:p,onClick:()=>{R(r.id),V(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(L,{active:_==="new",disabled:p,onClick:()=>R("new"),title:"New address",body:null,price:null})]}),e(x,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>o(r.target.value),disabled:p,className:N(p)})}),e(x,{label:"Address line 2",children:e("input",{type:"text",value:m,onChange:r=>h(r.target.value),placeholder:"Apartment, unit, garage bay…",disabled:p,className:N(p)})}),a(U,{cols:"three",children:[e(x,{label:"City",children:e("input",{type:"text",value:s,onChange:r=>v(r.target.value),disabled:p,className:N(p)})}),e(x,{label:q,children:e("input",{type:"text",value:b,onChange:r=>f(r.target.value),disabled:p,className:N(p)})}),e(x,{label:"Country",separate:!0,htmlFor:M,children:e(D,{id:M,value:c,onChange:r=>l(r.target.value),disabled:p,className:N(p)+" pr-10",style:z,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(x,{label:H,separate:!0,htmlFor:j,children:A.length>0?a(D,{id:j,value:u,onChange:r=>y(r.target.value),disabled:p,className:N(p)+" pr-10",style:z,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:u,onChange:r=>y(r.target.value),disabled:p,className:N(p)})})]}),e(x,{label:"Phone",children:e("input",{type:"tel",value:d,onChange:r=>g(r.target.value),disabled:p,className:N(p)})}),!t&&B!==null&&_==="new"&&!p&&a(k,{children:[e(pe,{checked:$,onChange:G,label:"Save this address to my account"}),$&&e(x,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:I})})]})]})}function Be(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:o,setShippingMethodId:m,pickupLocation:h,formatMoney:s,city:v,destination:b,courierUnavailable:f,retryCourier:d,orderLocked:g}=w();return e(S,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(c=>{const l=c.pickupLocation,u=l?[l.address,l.city,l.state,l.zipCode].filter(Boolean).join(", "):null;return e(L,{active:o===c.id,disabled:g,onClick:()=>m(c.id),title:l?`${c.name} — ${l.name}`:c.name,body:l?[u,l.openingHours,l.instructions,c.description].filter(Boolean).join(" · "):c.description||null,price:t.freeShipping||c.amount===0?O:s(c.amount,t.currency),tag:c.tag||void 0},c.id)}),f?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ce," ",e("button",{type:"button",onClick:d,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 Te(){const{payChoice:t,setPayChoice:i,placing:n,payment:o,payOptions:m,noPaymentMethod:h}=w();return a(S,{num:"N° 04",title:"Payment",children:[h&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:oe}),e("div",{className:"grid gap-3",children:m.map(s=>e(L,{active:t===s.key,onClick:()=>i(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.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 Re(){const{site:t,items:i,totals:n,coupon:o,formatMoney:m,payChoice:h,placing:s,email:v,orderError:b,payment:f,noPaymentMethod:d,unpaidOrder:g,orderLocked:c,placeOrder:l}=w();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop: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(Y,{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(Y,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(u=>e(me,{slug:u.slug,name:u.name,qty:u.qty,config:u.config,configSummary:ue(u.config),price:Z(u,n.currency)??0,currency:n.currency},u.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(ee,{customerEmail:v,disabled:c})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(C,{label:"Subtotal",value:m(n.subtotal,n.currency)}),n.discount>0&&o?.valid&&e(C,{label:`Coupon · ${o.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",m(n.discount,n.currency)]})}),o?.deferred&&e(C,{label:`Coupon · ${o.code}`,value:te}),o?.valid&&o.effects?.gift&&e(C,{label:`Free gift · ${o.effects.gift.partNumber}${o.effects.gift.quantity>1?` ×${o.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:O})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:O}):ae(n.shippingStatus)??m(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(C,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:m(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:re}):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?"…":m(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[b&&e(F,{role:"alert",children:b}),n.hasUnpricedLine&&a(F,{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:l,disabled:s||!g&&(d||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",s||!g&&(i.length===0||d||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:s?a(k,{children:["Building order… ",e("span",{children:"·"})]}):d?a(k,{children:["No online payment ",e("span",{children:"·"})]}):g?a(k,{children:["Try payment again · ",ne(g),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(k,{children:["Updating total… ",e("span",{children:"·"})]}):a(k,{children:[h==="bank"?"Place order":"Continue to payment"," ·"," ",m(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const P=" cursor-not-allowed opacity-70";function N(t){return I+(t?P:"")}function de({orderNumber:t}){return e(F,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:se(t)})]})})}const z={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 S({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 U({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 L({active:t,onClick:i,title:n,body:o,price:m,tag:h,disabled:s=!1}){return a("button",{type:"button",onClick:i,"aria-pressed":t,disabled:s,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":s?"border-line":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]",s?P.trim():""].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,h&&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:h})]}),o&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:o})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:m})]})}function pe({checked:t,onChange:i,label:n,sub:o}){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,o&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:o})]})]})}function me({slug:t,name:i,qty:n,config:o,configSummary:m,price:h,currency:s}){const{catalog:v}=J(),{formatMoney:b}=Q(),f=v.find(y=>y.slug===t),d=f?.spokes??5,g=f?.mesh??!1,c=o.find(y=>y.gold)?.label,l=f?.finishes.find(y=>y.name===c&&y.src)??f?.finishes.find(y=>y.src),u=f?.finishes[0]?.color??ie;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:l?.src?e(X,{src:l.src,alt:`${i.lead}${i.accent} — ${l.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:u},children:e(le,{spokes:d,mesh:g,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:m})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:b(h,s)})]})}function C({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 ue(t){return t.map(i=>i.label).join(" · ")}export{Pe as CheckoutContact,Re as CheckoutOrderSummary,Te as CheckoutPayment,Ae as CheckoutShippingAddress,Be as CheckoutShippingMethod};
|
|
1
|
+
"use client";import{jsx as e,Fragment as v,jsxs as a}from"react/jsx-runtime";import{useId as I}from"react";import Q from"next/image";import V from"next/link";import{lineTotal as X,useCart as Z}from"../CartContext.js";import{useCurrency as J}from"../CurrencyContext.js";import{Notice as S}from"../Notice.js";import{FREE_PRICE as j}from"../../lib/wheels/price-display.js";import ee from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as te}from"../../lib/cart/coupon-preview.js";import{orderReference as ne}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as ae}from"../../lib/checkout/checkout-memory.js";import{shippingWords as re,TAX_PENDING as ie}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as le}from"../../lib/wheels/finish-defaults.js";import M from"../ThemedSelect.js";import g from"../WebFormField.js";import oe from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as se,placedOrderLockNote as ce,SHIPPING_RETRY_NOTE as de,useCheckout as _}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_TO_COME as pe,FIGURE_UPDATING as me}from"../../lib/wheels/price-display.js";function Ue(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:c,company:f,setCompany:y,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=_(),d=I();return a(E,{num:"N° 01",title:"Contact",children:[x&&o&&e(ge,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:d,hint:b?a(v,{children:["Signed in ·"," ",e("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:d,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(D,{children:[e(g,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:u})}),e(g,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>c(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>y(p.target.value),autoComplete:"organization",className:u})})]})}function $e(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:c,city:f,setCity:y,postcode:b,setPostcode:h,phone:x,setPhone:o,country:d,setCountry:p,subdivision:C,setSubdivision:m,subdivisions:w,destination:N,postcodeLabel:Y,subdivisionLabel:q,me:P,savedAddresses:A,selectedAddressId:F,setSelectedAddressId:T,saveAddress:B,setSaveAddress:z,saveLabel:G,setSaveLabel:H,fillFromAddress:W,orderLocked:K}=_(),R=I(),O=I();return a(E,{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(v,{children:[P!==null&&A.length>0&&a("div",{className:"grid gap-3",children:[A.map(r=>e(L,{active:F===r.id,onClick:()=>{T(r.id),W(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(L,{active:F==="new",onClick:()=>T("new"),title:"New address",body:null,price:null})]}),e(g,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:u})}),e(g,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>c(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(D,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>y(r.target.value),className:u})}),e(g,{label:Y,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:R,children:e(M,{id:R,value:d,onChange:r=>p(r.target.value),className:u+" pr-10",style:$,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:q,separate:!0,htmlFor:O,children:w.length>0?a(M,{id:O,value:C,onChange:r=>m(r.target.value),className:u+" pr-10",style:$,children:[e("option",{value:"",children:"Select…"}),w.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:O,type:"text",value:C,onChange:r=>m(r.target.value),className:u})})]}),e(g,{label:"Phone",children:e("input",{type:"tel",value:x,onChange:r=>o(r.target.value),className:u})}),!t&&P!==null&&F==="new"&&!K&&a(v,{children:[e(fe,{checked:B,onChange:z,label:"Save this address to my account"}),B&&e(g,{label:"Address label",children:e("input",{type:"text",value:G,onChange:r=>H(r.target.value),placeholder:"Home",className:u})})]})]})}function De(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:c,formatMoney:f,city:y,destination:b,courierUnavailable:h,retryCourier:x}=_();return e(E,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const d=o.pickupLocation,p=d?[d.address,d.city,d.state,d.zipCode].filter(Boolean).join(", "):null;return e(L,{active:l===o.id,onClick:()=>s(o.id),title:d?`${o.name} — ${d.name}`:o.name,body:d?[p,d.openingHours,d.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?j:f(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[de," ",e("button",{type:"button",onClick:x,className:"underline transition-colors enabled: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 Ye(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=_();return a(E,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:se}),e("div",{className:"grid gap-3",children:l.map(c=>e(L,{active:t===c.key,onClick:()=>i(c.key),title:c.title,body:c.body,price:c.price,tag:c.tag},c.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 qe(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:c,placing:f,email:y,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:d,restoredPrices:p,placeOrder:C}=_(),m=p==="waiting",w=p==="changed";return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop: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(U,{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(U,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(N=>e(xe,{slug:N.slug,name:N.name,qty:N.qty,config:N.config,configSummary:be(N.config),price:w||m?null:X(N,n.currency)??0,currency:n.currency},N.id))}),e(he,{locked:d,className:"border-t border-line px-6 pt-5",children:e(ee,{customerEmail:y,disabled:d})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(k,{label:"Subtotal",value:m?me:s(w?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(k,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(k,{label:`Coupon · ${l.code}`,value:te}),l?.valid&&l.effects?.gift&&e(k,{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:j})}),e(k,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:j}):re(n.shippingStatus)??s(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(k,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:s(n.tax.amount,n.currency)}):n.tax.name?e(k,{label:n.tax.name,value:ie}):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?pe:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[w&&e(S,{tone:"quiet",children:ae}),b&&e(S,{role:"alert",children:b}),n.hasUnpricedLine&&a(S,{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:C,disabled:f||!o&&(x||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",f||!o&&(i.length===0||x||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:f?a(v,{children:["Building order… ",e("span",{children:"·"})]}):x?a(v,{children:["No online payment ",e("span",{children:"·"})]}):o?a(v,{children:["Try payment again · ",ne(o),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(v,{children:["Updating total… ",e("span",{children:"·"})]}):a(v,{children:[c==="bank"?"Place order":"Continue to payment"," ·"," ",s(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const ue=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function he({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+ue,children:n})}function U({href:t,className:i="",children:n,...l}){const{placing:s}=_();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(V,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function ge({orderNumber:t}){return e(S,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:ce(t)})]})})}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 E({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 D({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 L({active:t,onClick:i,title:n,body:l,price:s,tag:c}){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 enabled: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,c&&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:c})]}),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:s})]})}function fe({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 xe({slug:t,name:i,qty:n,config:l,configSummary:s,price:c,currency:f}){const{catalog:y}=Z(),{formatMoney:b}=J(),h=y.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,d=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===d&&m.src)??h?.finishes.find(m=>m.src),C=h?.finishes[0]?.color??le;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:p?.src?e(Q,{src:p.src,alt:`${i.lead}${i.accent} — ${p.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(oe,{spokes:x,mesh:o,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:s})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:c===null?null:b(c,f)})]})}function k({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 be(t){return t.map(i=>i.label).join(" · ")}export{Ue as CheckoutContact,qe as CheckoutOrderSummary,Ye as CheckoutPayment,$e as CheckoutShippingAddress,De as CheckoutShippingMethod,he as FormLock,U as LeaveLink};
|
|
@@ -64,6 +64,9 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
64
64
|
} | null;
|
|
65
65
|
grand: number;
|
|
66
66
|
repricing: boolean;
|
|
67
|
+
quoted: boolean;
|
|
68
|
+
serverSubtotal: number | null;
|
|
69
|
+
quoteFailed: boolean;
|
|
67
70
|
currency: import("../../lib/api/index.js").Currency;
|
|
68
71
|
};
|
|
69
72
|
coupon: import("../CartContext.js").AppliedCoupon | null;
|
|
@@ -178,6 +181,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
178
181
|
couponCode?: string | null;
|
|
179
182
|
} | null;
|
|
180
183
|
orderLocked: boolean;
|
|
184
|
+
formLocked: boolean;
|
|
185
|
+
restoredPrices: "waiting" | "changed" | "same" | null;
|
|
181
186
|
payNote: string | null;
|
|
182
187
|
afterpayConfirming: boolean;
|
|
183
188
|
gocardlessConfirming: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`);return
|
|
3
|
-
${$e.trim()}`:me,Fn=lr({email:V,firstName:L,lastName:ee,company:Le.trim(),phone:te,address:xe,city:G,subdivision:_,postcode:$,country:l,lines:i.map(e=>[e.id,e.qty]),shippingMethodId:le,couponCode:Vt(D),currency:I.currency,shopperId:Pe?.id??null}),h=JSON.stringify([Fn,w]),R=f(null),De=f(null),Ke=f(!1),O=f(!1),j=f(null),Oe=f(!1),P=f(h);P.current=h;const xt=f(fe);xt.current=fe;const Kt=()=>O.current&&P.current!==R.current,B=f(null);y(()=>{xt.current||(h!==B.current&&(B.current=null),!(!O.current||!g||g.orderNumber)&&(h===R.current||h===B.current||Ee(g)))},[h,g]);async function Ee(e){if(Oe.current)return null;Oe.current=!0,S(!0);try{const t=j.current?await ir(j.current):"none";if(t==="succeeded"||t==="processing")return O.current=!1,x(null),E("card"),t==="succeeded"?await U(void 0,e):$t(e),null;if(t===void 0||!ar.has(t))return B.current=P.current,x(e),b(t==="requires_action"?cr:Xe),null;const n=await jt(oe);if(n==="committed")return O.current=!1,x(null),E("card"),await U(void 0,e),null;if(n!=="released")return B.current=P.current,x(e),b(Xe),null;O.current=!1,j.current=null,B.current=null,b(null),x(null);const a=ue();return Se(a),a}finally{Oe.current=!1,S(!1)}}async function Yn(){if(!(p||fe||Oe.current)){if(g){if((O.current?h!==R.current:ae())&&!g.orderNumber){const a=await Ee(g);a&&P.current===h&&await Ot(a);return}S(!0),b(null),Ke.current=!1,await qe();const t=z(P.current)[1],n=g.orderNumber?t:"card";if(n&&rn.has(n)&&ae()&&z(P.current)[0]!==De.current){Et(g);return}E(n),n!==w&&pe(n),await Ft(g,n,!g.orderNumber);return}await Ot(oe)}}async function Ot(e){if(i.length===0||I.repricing||!w||!Z.some(s=>s.key===w))return;const t=i.filter(Gt).flatMap(s=>Qn(s.components,s.qty));if(t.length===0){b("Pick a size on each wheel's product page before checking out.");return}S(!0),b(null);let n,a=e,r=w,u=!1;try{const s=Pe?N.createOrderAuthed:N.createOrder,k=Wn(),d={customer:{email:V,name:`${L} ${ee}`.trim(),phone:te.trim()||void 0,companyName:Le.trim()||void 0,address:xe,city:G,state:_||void 0,zipCode:$,country:l},items:t,currency:I.currency,idempotencyKey:e,shippingMethodId:le??void 0,couponCode:Vt(D),...k==="denied"?{}:Jn(),...k?{adConsent:k}:{},...sr(w)?{checkoutFlow:Zt}:{}};F.current=()=>s(d),ft(null),De.current=null,Ke.current=!1,j.current=null,O.current=!1,B.current=null,R.current=h,ce.current=i;const C=Y.current,Ut=C?.key===d.idempotencyKey&&(C.shape!==h&&(!!d.checkoutFlow||!!C.method||!!C.plainMethod)||!!d.checkoutFlow&&!!C.plainMethod);Ut&&(X.current=d.idempotencyKey);const Ht=Mt(d,s),zt=Ut||!d.checkoutFlow&&X.current===d.idempotencyKey,Dt=!Ht&&!zt&&!d.checkoutFlow&&!!C&&!C.method;Dt&&(C.plainMethod=w,C.plainLines=i,C.plainShape=h);const H=await(zt?It(d,s):s(d).then(se=>({answer:se,request:d})).catch(se=>(Ht?Tt(se,d.idempotencyKey):Dt&&Qt(se)&&(C.plainMethod=""),Bn(se,d,s))));if(!H)return;n=H.answer,a=H.request.idempotencyKey,r=H.method??r,E(r),u=ae()||r!==z(P.current)[1],H.method&&H.method!==w&&pe(H.method),n.orderNumber&&(Rt(n),q()),await qe()}catch(s){const k=pr(s);k?(cn(k),b(`${k} Your order has not been placed. Place it again to continue without the code.`)):s instanceof Ie?b(Xe):b(s instanceof Te?s.message:"Could not place the order. Please try again."),S(!1);return}if(r&&rn.has(r)&&(u||ae())){Et(n);return}await Ft(n,r,!1,a)}function Et(e){De.current=z(P.current)[0],b(`${nn(e,null)} ${Xt}`),x(e),S(!1)}function Tt(e,t){Qt(e)&&!Wt(e)&&Y.current?.key===t&&(Y.current=null)}async function Bn(e,t,n){if(We(e))return _t(t,n);if(!Wt(e))throw e;return X.current=t.idempotencyKey,It(t,n,!0)}async function It(e,t,n=!1){const a=await jt(e.idempotencyKey);if(a==="released")return P.current===h?_t(e,t):(Se(ue()),S(!1),null);if(a!=="committed")throw new Ie;const r=Y.current?.key===e.idempotencyKey?Y.current:null;if(ce.current=r?.lines??i,r?.method&&!n){X.current=null,F.current=r.send;const k=await r.send().catch(()=>{throw new Ie});return R.current=r.shape,{answer:k,request:e,method:r.method}}const u=r&&!r.method?r.send:()=>t({...e,checkoutFlow:Zt});F.current=u;const s=await u().catch(()=>null);if(!s&&r?.plainMethod)throw new Ie;return s?.orderNumber&&s.status!==ur?(X.current=null,r?.plainMethod&&(ce.current=r.plainLines),r&&(R.current=r.plainMethod?r.plainShape:r.shape),{answer:s,request:e,method:r?.plainMethod||void 0}):(S(!1),r&&(R.current=r.shape),E("card"),await Lt("",s?async()=>s:()=>Promise.reject(new Error("The order request did not answer."))),await qe(),null)}function ae(){const e=R.current;return e!==null&&z(e)[0]!==z(P.current)[0]}function E(e){e!==z(P.current)[1]&&(Ke.current=!0),ft(Ke.current||ae()?Xt:null)}async function _t(e,t){const n={...e,idempotencyKey:ue()};X.current=null,Se(n.idempotencyKey),F.current=()=>t(n),Mt(n,t);try{return{answer:await t(n),request:n}}catch(a){throw Tt(a,n.idempotencyKey),a}}function Mt(e,t){return Y.current?.key===e.idempotencyKey?!1:(Y.current={key:e.idempotencyKey,send:()=>t(e),lines:i,shape:h,method:e.checkoutFlow?"":w??"",plainMethod:"",plainLines:i,plainShape:h},!0)}function Rt(e){Zn({confirmation:e,lines:ce.current,adsSendTo:c.googleAdsId&&c.googleAdsConversionLabel?`${c.googleAdsId}/${c.googleAdsConversionLabel}`:null}),jn({confirmation:e,lines:ce.current})}async function U(e,t=M){if(!t)return;const n=e?async()=>e:F.current;if(t.orderNumber||!n){W(!0),A(t);return}await Lt(t.checkoutNumber,n)}async function Lt(e,t){q(),await dr({checkoutNumber:e,resend:t,page:{setConfirming:_n,land:A,markPaid:()=>W(!0),track:Rt,unplaced:bt}})}function $t(e=M){if(e){if(e.orderNumber){A(e);return}q(),bt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function qe(){const e=JSON.stringify([Ue.trim(),L,ee,te.trim(),xe,G,_,$,l]);if(!(!Pe||!lt||ut!=="new"||mt.current===e))try{await ie.createAddress({label:Ue.trim()||"Home",contact_name:`${L} ${ee}`.trim(),phone:te.trim(),address:xe,city:G,zip_code:$,state:_,country:l}),mt.current=e,pt("Address saved to your account.")}catch{pt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function Ft(e,t=w,n=!1,a=oe){x(null);try{if(t==="card"&&c.paymentMethods.includes("card")){const r=await N.createPaymentIntent({idempotencyKey:a});if(j.current=r,n&&Kt()){await Ee(e);return}let u=e;if(n){const s=await F.current?.().catch(()=>null);if(s?.orderNumber){E("card"),await U(s,e);return}if(u=Yt(e,s)??{...e,expiresAt:null},Kt()){await Ee(e);return}}E("card"),J(u),He(!1),Ae(r)}else if(t==="paypal"&&c.paymentMethods.includes("paypal"))J(e),bn(!0);else if(t==="afterpay"&&c.paymentMethods.includes("afterpay")){const r=window.location.origin,u=await N.createAfterpayCheckout({idempotencyKey:a,confirmUrl:`${r}/checkout?afterpay=confirm`,cancelUrl:`${r}/checkout?afterpay=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(er,JSON.stringify(s)),window.location.assign(u.redirectCheckoutUrl);return}else if(t==="square"&&c.paymentMethods.includes("square"))J(e),Pn(!0);else if(t==="gocardless"&&c.paymentMethods.includes("gocardless")){const r=window.location.origin,u=await N.createGocardlessBillingRequest({idempotencyKey:a,confirmUrl:`${r}/checkout?gocardless=confirm`,cancelUrl:`${r}/checkout?gocardless=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(Ge,JSON.stringify(s)),window.location.assign(u.authorisationUrl);return}else if(t==="zip"&&c.paymentMethods.includes("zip")){const r=window.location.origin,u=await N.createZipCheckout({idempotencyKey:a,redirectUrl:`${r}/checkout?zip=return`}),s={idempotencyKey:a,confirmation:e};v.setItem(nr,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else if(t==="klarna"&&c.paymentMethods.includes("klarna")){const r=window.location.origin,u=await N.createKlarnaCheckout({idempotencyKey:a,confirmUrl:`${r}/checkout?klarna=confirm`,cancelUrl:`${r}/checkout?klarna=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(Je,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else E(t),A(e)}catch(r){if((n||t==="card")&&r instanceof Te&&r.status===409){E(t),await U(void 0,e);return}Bt(e,r),S(!1)}}function Yt(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function Bt(e,t){b(nn(e,t)),!e.orderNumber&&We(t)?(O.current=!1,Se(ue())):x(e)}async function Un(e){if(!M)return;const t=M;try{const n=await N.createPaymentIntent({idempotencyKey:oe}),a=await F.current?.().catch(()=>null);if(a?.orderNumber){await U(a);return}const r=Yt(t,a);J(r??{...t,expiresAt:null}),He(e&&r!==null),j.current=n,Ae(n)}catch(n){if(n instanceof Te&&n.status===409){await U();return}Ae(null),J(null),Bt(t,n),S(!1)}}function Hn(){M&&(O.current=!0,x(M),Ae(null),J(null),He(!1),S(!1))}return{site:c,logo:m,items:i,totals:I,coupon:D,deliveryOptions:Ze,courierUnavailable:yn,retryCourier:hn,shippingMethodId:le,setShippingMethodId:an,pickupLocation:ln,servedCountries:Q,formatMoney:dn,payChoice:w,setPayChoice:pe,placing:fe,email:V,setEmail:_e,firstName:L,setFirstName:Me,lastName:ee,setLastName:Re,company:Le,setCompany:rt,address1:me,setAddress1:ye,address2:$e,setAddress2:he,city:G,setCity:we,postcode:$,setPostcode:ge,phone:te,setPhone:ke,country:l,setCountry:Ce,subdivision:_,setSubdivision:Ne,subdivisions:ne,destination:ct,postcodeLabel:fn,subdivisionLabel:mn,me:Pe,savedAddresses:wn,selectedAddressId:ut,setSelectedAddressId:Be,saveAddress:lt,setSaveAddress:dt,saveLabel:Ue,setSaveLabel:gn,addressSaveNote:kn,lostChangeNote:Cn,idemKey:oe,confirmation:yt,setConfirmation:A,orderError:Nn,payment:ht,paypalStep:wt,squareStep:gt,pendingConf:M,paid:Sn,setPaid:W,unpaidOrder:g,orderLocked:An,payNote:vn,afterpayConfirming:xn,gocardlessConfirming:On,zipConfirming:En,klarnaConfirming:In,cardConfirming:Nt,checkoutResult:ze,confirmCardPayment:U,cardStillProcessing:$t,renewCardPayment:Un,holdRenewed:Mn,leaveCardPayment:Hn,checkoutRootRef:At,setCheckoutHeaderEl:Rn,fillFromAddress:vt,checkoutSignOut:Ln,payOptions:Z,noPaymentMethod:$n,placeOrder:Yn}}const on=zn(null);function Mr({children:c,...m}){const p=fr(m);return T(on.Provider,{value:p,children:c})}function Rr(){const c=Dn(on);if(!c)throw new Error("useCheckout must be used inside CheckoutStateProvider");return c}export{Mr as CheckoutStateProvider,Tr as NO_PAYMENT_METHOD_NOTE,Ir as SHIPPING_RETRY_NOTE,tn as buildPayOptions,nn as paymentNotStartedMessage,_r as placedOrderLockNote,Rr as useCheckout};
|
|
1
|
+
"use client";import{jsx as x}from"react/jsx-runtime";import{createContext as gr,useContext as kr,useEffect as f,useMemo as yn,useRef as d,useState as s}from"react";import{isOrderable as hn,useCart as Cr}from"../CartContext.js";import{useCurrency as br}from"../CurrencyContext.js";import{getClickIds as Nr}from"../../lib/click-ids.js";import{adConsentForOrder as Pr}from"../../lib/consent/choice.js";import{trackBeginCheckout as Sr,trackPurchase as Ar}from"../../lib/google-tag.js";import{trackMetaPurchase as vr}from"../../lib/meta-pixel.js";import{ApiError as Ge,api as be,products as k}from"../../lib/api/index.js";import{uuid as ze}from"../../lib/uuid.js";import{orderLinesForSets as Or}from"../../lib/commerce.js";import{canPersist as Er,safeSessionStorage as X}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Kr,AFTERPAY_RETURN as Mr,GOCARDLESS_CONTEXT_KEY as dt,KLARNA_CONTEXT_KEY as pt,ZIP_CONTEXT_KEY as Tr,ZIP_RETURN as xr,runWalletReturn as wn}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Lr}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as Ir,holdsPress as Rr,parkCheckoutMemory as _r,parkForm as Fr,parkOrder as qr,parkRequest as gn,readCheckoutMemory as $r,sendableRequest as Br}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as ft,checkoutWaiting as kn,BANK_WAITING as Yr,DROPPABLE_INTENT as Ur,NOT_CHECKED as mt,LOST_CHANGE as Cn,PAY_FIRST_FLOW as De,paysFirst as Hr,readIntentStatus as Gr,releaseHeldCheckout as bn,CHECKOUT_COMMITTED as zr,goodsShapeOf as Dr,refusedForGood as Nn,settlePayFirst as Wr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as Pn,couponRefusedByOrder as Jr}from"../../lib/cart/coupon-preview.js";function Sn(o){const w=o.indexOf(`
|
|
2
|
+
`);return w===-1?[o,""]:[o.slice(0,w),o.slice(w+1)]}function An(o,{canParkContext:w}={canParkContext:!0}){const m=o.paymentMethods,a=[];return m.includes("card")&&a.push({key:"card",title:"Card",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),m.includes("paypal")&&o.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),m.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),m.includes("square")&&o.squareApplicationId&&o.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),m.includes("gocardless")&&w&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),m.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),m.includes("klarna")&&w&&a.push({key:"klarna",title:"Klarna",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),m.includes("bank")&&a.push({key:"bank",title:"Bank transfer",body:null,price:x("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}const wo="This shop does not take payment online yet. Please contact the shop to order.";class We extends Error{}function vn(o,w){if(!o.orderNumber&&ft(w))return w.message;const m=w instanceof Ge?` (${w.message})`:"";return o.orderNumber?`Your order ${o.orderNumber} is saved, but the payment did not start${m}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${o.checkoutNumber}, but the payment did not start${m}. Try the payment again — you will not be charged twice.`}const Xr=3e3,Zr=.005,On=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]);function En(){const o=Pr();return{...o==="denied"?{}:Nr(),...o?{adConsent:o}:{}}}const O=o=>JSON.parse(o),go="Shipping cannot be calculated right now. Please try again.";function ko(o){return`Your order is saved, so its contact, address, delivery and discount can't change here. To change any of them, contact the shop and quote ${o}.`}function jr({site:o,logo:w,preview:m=!1}){const{items:a,totals:C,coupon:L,refuseCoupon:Mn,deliveryOptions:yt,shippingMethodId:ce,setShippingMethodId:ht,setQuoteDestination:Ne,courier:Tn,requote:Je,identify:wt,clearCapturedCart:Z,replaceItems:Xe,removeCoupon:gt,applyCoupon:xn}=Cr(),Ln=yt.find(e=>e.id===ce)?.pickupLocation??null,{country:kt,countries:se,activeCountry:Ct,formatMoney:In}=br(),[g,Pe]=s(()=>An(o)[0]?.key??null),[bt,Rn]=s(!0);f(()=>{Rn(Er(X))},[]);const[I,Ze]=s(!1),[Y,Se]=s(""),[R,Ae]=s(""),[j,ve]=s(""),[Oe,je]=s(""),[ae,ie]=s(""),[Ee,ue]=s(""),[U,le]=s(""),[_,de]=s(""),[Q,pe]=s(""),[p,fe]=s(()=>kt||se[0]?.code||""),[E,Ke]=s(""),[me,Nt]=s([]),[Qe,Ve]=s(null),[Me,V]=s(null),Pt=yn(()=>se.find(e=>e.code===p)??Ct,[se,p,Ct]),_n=Pt?.postalLabel||"Postal Code",Fn=me[0]?.divisionType||"State / Province";f(()=>{if(!p){Nt([]),Ve(p);return}Ve(null);let e=!1;return k.listCountrySubdivisions(p).then(t=>{e||(Nt(t),Ve(p),Ke(""))}),()=>{e=!0}},[p]);const St=ae.trim()!==""&&U.trim()!==""&&_.trim()!==""&&Qe===p&&(me.length===0||E!=="")?_.trim():"";f(()=>{Ne(p?{country:p,subdivision:E,postcode:St}:null)},[p,E,St,Ne]),f(()=>()=>Ne(null),[Ne]);const qn=Tn?.status==="unavailable",$n=Je,[ye,At]=s(null),[Bn,vt]=s([]),[et,Te]=s("new"),[Ot,Et]=s(!1),[tt,Yn]=s("Home"),[Un,Kt]=s(null),[Hn,Mt]=s(null),[H,xe]=s(()=>ze()),Tt=d(null),[nt,S]=s(null),[Gn,N]=s(null),[xt,Le]=s(null),[Lt,zn]=s(!1),[It,Dn]=s(!1),[F,ee]=s(null),[Wn,te]=s(!1),[y,P]=s(null),Rt=!!y?.orderNumber,Jn=Rt||I,[Xn,K]=s(null),[Zn,jn]=s(!1),[Qn,_t]=s(!1),[Vn,er]=s(!1),[tr,Ft]=s(!1),[qt,nr]=s(!1),[rr,rt]=s(!1),[he,$t]=s(null),q=d(null),G=d(null),ot=d(!1),z=d(a),M=d(null),$=d(null),Bt=!!(nt||he&&he.kind!=="processing"||qt||Lt||It||xt&&F?.orderNumber);f(()=>{Bt&&(Xe([]),gt())},[Bt,Xe,gt]);const Yt=d(!1);f(()=>{m||Yt.current||!a.some(hn)||(Yt.current=!0,Sr({lines:a,currency:C.currency,value:C.subtotal-C.discount,coupon:L?.valid?L.code:void 0}))},[a,C,L,m]),f(()=>{wt(Y,R.trim()||void 0)},[Y,R,wt]);const Ut=d(null),[Ie,or]=s(null);f(()=>{const e=Ut.current;if(!Ie||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${Ie.offsetHeight}px`);t();const n=new ResizeObserver(t);return n.observe(Ie),()=>n.disconnect()},[Ie]),f(()=>{const e=n=>({setConfirming:n,land:S,markPaid:()=>te(!0),note:K,fail:N,clearCart:Z}),t={search:window.location.search,storage:X,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};wn(Mr,{...t,capture:k.captureAfterpayPayment,page:e(jn)}),wn(xr,{...t,capture:k.captureZipPayment,page:e(er)})},[]),f(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const n=X.getItem(dt);if(X.removeItem(dt),window.history.replaceState(null,"",window.location.pathname),!n)return;let c;try{c=JSON.parse(n)}catch{return}if(Z(),t==="cancel"){K("The direct debit was not set up — our team will follow up on payment."),S(c.confirmation);return}_t(!0),k.completeGocardlessPayment({idempotencyKey:c.idempotencyKey}).then(r=>{r.status==="paid"?te(!0):r.status==="declined"?K("The direct debit was declined — our team will follow up on payment."):K("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{K("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{S(c.confirmation),_t(!1)})},[]),f(()=>{const e=new URLSearchParams(window.location.search),t=e.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const n=X.getItem(pt);X.removeItem(pt);const c=e.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!n)return;let r;try{r=JSON.parse(n)}catch{return}if(Z(),t==="cancel"||!c){K("The Klarna payment was not completed — our team will follow up on payment."),S(r.confirmation);return}Ft(!0),k.captureKlarnaPayment({idempotencyKey:r.idempotencyKey,authorizationToken:c}).then(u=>{u.status==="paid"?te(!0):u.status==="declined"?K("Klarna declined the payment — our team will follow up on payment."):K("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{K("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{S(r.confirmation),Ft(!1)})},[]);function Ht(e){const[t,n]=Sn(e.address);ie(t),ue(n),le(e.city),de(e.zip_code),e.country&&fe(e.country),e.phone&&pe(e.phone),V({country:e.country||null,state:e.state??""})}f(()=>{if(Me){if((Me.country||p)!==p){V(null);return}Qe===p&&(Ke(Lr(p,Me.state,me)),V(null))}},[Me,p,Qe,me]),f(()=>{let e=!1;return(async()=>{try{const[t,n,c]=await Promise.all([be.me(),be.myProfile().catch(()=>null),be.myAddresses().catch(()=>[])]);if(e)return;At(t);const r=c.filter(h=>h.is_active);vt(r),Se(t.email);const u=(n?.contact_name??"").split(/\s+/);Ae(t.first_name||u[0]||""),ve(t.last_name||u.slice(1).join(" "));const i=t.phone||n?.phone;i&&pe(i);const l=r.find(h=>h.id===t.default_delivery_location)??r[0];if(l)Te(l.id),Ht(l);else if(n){const[h,He]=Sn(n.address??"");ie(h),ue(He),le(n.city??""),de(n.zip_code??""),n.country&&fe(n.country),V({country:n.country||null,state:n.state??""})}Ye.current&&jt(Ye.current,!1)}catch{}})(),()=>{e=!0}},[]);function cr(){be.logout(),we.current=!0,Ye.current=null,Be.current=null,ge(),At(null),vt([]),Te("new"),Et(!1),Se(""),Ae(""),ve(""),je(""),ie(""),ue(""),le(""),de(""),pe(""),fe(kt||se[0]?.code||""),Ke(""),V(null)}const ne=yn(()=>An(o,{canParkContext:bt}),[o,bt]);f(()=>{ne.some(e=>e.key===g)||Pe(ne[0]?.key??null)},[ne,g]);const sr=ne.length===0,Re=Ee.trim()?`${ae}
|
|
3
|
+
${Ee.trim()}`:ae,ar=Dr({email:Y,firstName:R,lastName:j,company:Oe.trim(),phone:Q,address:Re,city:U,subdivision:E,postcode:_,country:p,lines:a.map(e=>[e.id,e.qty]),shippingMethodId:ce,couponCode:Pn(L),currency:C.currency,shopperId:ye?.id??null}),b=JSON.stringify([ar,g]),A=d(null),ct=d(null),_e=d(!1),B=d(!1),re=d(null),Fe=d(!1),v=d(b);v.current=b;const Gt=d(I);Gt.current=I;const qe=d(null);f(()=>{const e=()=>{const t=qe.current;t&&(qe.current=null,P(t),Ze(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function $e(e,t,n,c){const r={idempotencyKey:t,confirmation:n};X.setItem(e,JSON.stringify(r)),window.location.assign(c),qe.current=n}async function zt(e){Ze(!0);try{await e()}finally{qe.current||Ze(!1)}}const Dt=d(!1),Wt=!!(nt||he&&he.kind!=="processing");f(()=>{Wt&&(Dt.current=!0,ge())},[Wt]);const Be=d(null),we=d(!1),st=d(null);function ge(){st.current=null,Ir()}const Ye=d(null),[oe,ir]=s(!1);function at(e){if(Dt.current||m||we.current)return;const t=M.current,n={key:e,authed:ot.current,parkedAt:st.current??=Date.now(),lastPress:t&&{key:t.key,request:gn(t.request),lines:t.lines,goods:O(t.shape)[0],plainPressed:!!t.plainMethod,plainLines:t.plainLines,plainGoods:O(t.plainShape)[0]},keptCardKey:$.current,placedGoods:A.current===null?null:O(A.current)[0],unpaidOrder:Ue.current&&qr(Ue.current),placedRequest:G.current&&gn(G.current),lines:a.length>0?a:z.current,form:Fr({email:Y,firstName:R,lastName:j,company:Oe,address1:ae,address2:Ee,city:U,postcode:_,phone:Q,country:p,subdivision:E,selectedAddressId:et,shippingMethodId:ce,couponCode:L?.valid?L.code:null})};Rr(n)?_r(n):ge()}const Ue=d(y);Ue.current=y;const Jt=d(g);Jt.current=g;function it(e){return{...Br(e),...En(),...e.payFirst?{checkoutFlow:De}:{}}}function ur(e,t){let n=e.request.payFirst?"":null,c=e.plainPressed?null:"";const r=()=>Jt.current??"";return{key:e.key,send:()=>t(it(e.request)),request:it(e.request),lines:e.lines,shape:JSON.stringify([e.goods,null]),get method(){return n??r()},set method(u){n=u},get plainMethod(){return c??r()},set plainMethod(u){c=u},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[lr,dr]=s(!1),Xt=lr?!C.quoted||C.serverSubtotal===null?"waiting":Math.abs(C.serverSubtotal-C.subtotal)<Zr?"same":"changed":null,ut=!y&&Xt==="waiting",pr=ut?{...C,repricing:!0}:C,Zt=ut&&C.quoteFailed;f(()=>{if(!Zt)return;const e=setInterval(Je,Xr);return()=>clearInterval(e)},[Zt,Je]);function jt(e,t=!0){Se(e.email),Ae(e.firstName),ve(e.lastName),je(e.company),ie(e.address1),ue(e.address2),le(e.city),de(e.postcode),pe(e.phone),e.country&&fe(e.country),V({country:e.country||null,state:e.subdivision}),Te(e.selectedAddressId),e.shippingMethodId&&ht(e.shippingMethodId),t&&(Be.current=e.couponCode)}f(()=>{let e=m?null:$r();if(e&&a.length>0&&(ge(),e=null),e){const t=e.authed?k.createOrderAuthed:k.createOrder;xe(e.key),st.current=e.parkedAt,M.current=e.lastPress&&ur(e.lastPress,t),$.current=e.keptCardKey,A.current=e.placedGoods===null?null:JSON.stringify([e.placedGoods,null]),ot.current=e.authed;const n=e.placedRequest&&it(e.placedRequest);G.current=n,q.current=n?()=>t(n):null,e.unpaidOrder&&P(e.unpaidOrder),e.lines.length>0&&(Xe(e.lines),z.current=e.lines,dr(!0)),e.form&&(Ye.current=e.form,jt(e.form))}ir(!0)},[]),f(()=>{!oe||a.length>0||Ue.current||I||(we.current=!0,ge())},[oe,a.length]),f(()=>{const e=Be.current;!oe||!e||a.length===0||(Be.current=null,xn(e,Y||void 0))},[oe,a.length]),f(()=>{!oe||I||at(H)},[oe,I,H,y]);const D=d(null);f(()=>{Gt.current||(b!==D.current&&(D.current=null),!(!B.current||!y||y.orderNumber)&&(b===A.current||b===D.current||zt(()=>Qt(y))))},[b,y]);async function Qt(e){if(Fe.current)return null;Fe.current=!0;try{const t=re.current?await Gr(re.current):"none";if(t==="succeeded"||t==="processing")return B.current=!1,P(null),T("card"),t==="succeeded"?await W(void 0,e):an(e),null;if(t===void 0||!Ur.has(t))return D.current=v.current,P(e),N(t==="requires_action"?Yr:mt),null;const n=await bn(H);if(n==="committed")return B.current=!1,P(null),T("card"),await W(void 0,e),null;if(n!=="released")return D.current=v.current,P(e),N(mt),null;B.current=!1,re.current=null,D.current=null,N(null),P(null);const c=ze();return xe(c),c}finally{Fe.current=!1}}async function fr(){m||I||Fe.current||await zt(mr)}async function mr(){if(y){if((B.current?b!==A.current:ke())&&!y.orderNumber){const c=await Qt(y);c&&v.current===b&&await Vt(c);return}N(null),_e.current=!1,await lt();const t=O(v.current)[1],n=y.orderNumber?t:"card";if(n&&On.has(n)&&ke()&&O(v.current)[0]!==ct.current){en(y);return}T(n),n!==g&&Pe(n),await un(y,n,!y.orderNumber);return}await Vt(H)}async function Vt(e){if(a.length===0||C.repricing||ut||!g||!ne.some(i=>i.key===g))return;const t=a.filter(hn).flatMap(i=>Or(i.components,i.qty));if(t.length===0){N("Pick a size on each wheel's product page before checking out.");return}N(null);let n,c=e,r=g,u=!1;try{const i=ye?k.createOrderAuthed:k.createOrder,l={customer:{email:Y,name:`${R} ${j}`.trim(),phone:Q.trim()||void 0,companyName:Oe.trim()||void 0,address:Re,city:U,state:E||void 0,zipCode:_,country:p},items:t,currency:C.currency,idempotencyKey:e,shippingMethodId:ce??void 0,couponCode:Pn(L),...En(),...Hr(g)?{checkoutFlow:De}:{}};q.current=()=>i(l),G.current=l,ot.current=!!ye,we.current=!1,Mt(null),ct.current=null,_e.current=!1,re.current=null,B.current=!1,D.current=null,A.current=b,z.current=a;const h=M.current,He=h?.key===l.idempotencyKey&&(h.shape!==b&&(!!l.checkoutFlow||!!h.method||!!h.plainMethod)||!!l.checkoutFlow&&!!h.plainMethod);He&&($.current=l.idempotencyKey);const pn=on(l,i),fn=He||!l.checkoutFlow&&$.current===l.idempotencyKey,mn=!pn&&!fn&&!l.checkoutFlow&&!!h&&!h.method;mn&&(h.plainMethod=g,h.plainLines=a,h.plainShape=b,at(l.idempotencyKey));const J=await(fn?nn(l,i):i(l).then(Ce=>({answer:Ce,request:l})).catch(Ce=>(pn?tn(Ce,l.idempotencyKey):mn&&Nn(Ce)&&(h.plainMethod=""),yr(Ce,l,i))));if(!J)return;n=J.answer,c=J.request.idempotencyKey,r=J.method??r,T(r),u=ke()||r!==O(v.current)[1],J.method&&J.method!==g&&Pe(J.method),n.orderNumber&&(cn(n),Z()),await lt()}catch(i){const l=Jr(i);l?(Mn(l),N(`${l} Your order has not been placed. Place it again to continue without the code.`)):i instanceof We?N(mt):N(i instanceof Ge?i.message:"Could not place the order. Please try again.");return}if(r&&On.has(r)&&(u||ke())){en(n);return}await un(n,r,!1,c)}function en(e){ct.current=O(v.current)[0],N(`${vn(e,null)} ${Cn}`),P(e)}function tn(e,t){Nn(e)&&!kn(e)&&M.current?.key===t&&(M.current=null)}async function yr(e,t,n){if(ft(e))return rn(t,n);if(!kn(e))throw e;return $.current=t.idempotencyKey,nn(t,n,!0)}async function nn(e,t,n=!1){const c=await bn(e.idempotencyKey);if(c==="released")return rn(e,t);if(c!=="committed")throw new We;const r=M.current?.key===e.idempotencyKey?M.current:null;if(z.current=r?.lines??a,r?.method&&!n){$.current=null,q.current=r.send,G.current=r.request;const l=await r.send().catch(()=>{throw new We});return A.current=r.shape,{answer:l,request:e,method:r.method}}const u=r&&!r.method?r.send:()=>t({...e,checkoutFlow:De});q.current=u,G.current=r&&!r.method?r.request:{...e,checkoutFlow:De};const i=await u().catch(()=>null);if(!i&&r?.plainMethod)throw new We;return i?.orderNumber&&i.status!==zr?($.current=null,r?.plainMethod&&(z.current=r.plainLines),r&&(A.current=r.plainMethod?r.plainShape:r.shape),{answer:i,request:e,method:r?.plainMethod||void 0}):(r&&(A.current=r.shape),T("card"),await sn("",i?async()=>i:()=>Promise.reject(new Error("The order request did not answer."))),await lt(),null)}function ke(){const e=A.current;return e!==null&&O(e)[0]!==O(v.current)[0]}function T(e){e!==O(v.current)[1]&&(_e.current=!0),Mt(_e.current||ke()?Cn:null)}async function rn(e,t){const n={...e,idempotencyKey:ze()};$.current=null,xe(n.idempotencyKey),q.current=()=>t(n),G.current=n,on(n,t);try{return{answer:await t(n),request:n}}catch(c){throw tn(c,n.idempotencyKey),c}}function on(e,t){return M.current?.key===e.idempotencyKey?!1:(M.current={key:e.idempotencyKey,send:()=>t(e),request:e,lines:a,shape:b,method:e.checkoutFlow?"":g??"",plainMethod:"",plainLines:a,plainShape:b},we.current=!1,at(e.idempotencyKey),!0)}function cn(e){Ar({confirmation:e,lines:z.current,adsSendTo:o.googleAdsId&&o.googleAdsConversionLabel?`${o.googleAdsId}/${o.googleAdsConversionLabel}`:null}),vr({confirmation:e,lines:z.current})}async function W(e,t=F){if(!t)return;const n=e?async()=>e:q.current;if(t.orderNumber||!n){te(!0),S(t);return}await sn(t.checkoutNumber,n)}async function sn(e,t){Z(),await Wr({checkoutNumber:e,resend:t,page:{setConfirming:nr,land:S,markPaid:()=>te(!0),track:cn,unplaced:$t}})}function an(e=F){if(e){if(e.orderNumber){S(e);return}Z(),$t({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function lt(){const e=JSON.stringify([tt.trim(),R,j,Q.trim(),Re,U,E,_,p]);if(!(!ye||!Ot||et!=="new"||Tt.current===e))try{await be.createAddress({label:tt.trim()||"Home",contact_name:`${R} ${j}`.trim(),phone:Q.trim(),address:Re,city:U,zip_code:_,state:E,country:p}),Tt.current=e,Kt("Address saved to your account.")}catch{Kt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function un(e,t=g,n=!1,c=H){P(null);try{if(t==="card"&&o.paymentMethods.includes("card")){const r=await k.createPaymentIntent({idempotencyKey:c});re.current=r;let u=e;if(n){const i=await q.current?.().catch(()=>null);if(i?.orderNumber){T("card"),await W(i,e);return}u=ln(e,i)??{...e,expiresAt:null}}T("card"),ee(u),rt(!1),Le(r)}else if(t==="paypal"&&o.paymentMethods.includes("paypal"))ee(e),zn(!0);else if(t==="afterpay"&&o.paymentMethods.includes("afterpay")){const r=window.location.origin,u=await k.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?afterpay=confirm`,cancelUrl:`${r}/checkout?afterpay=cancel`});$e(Kr,c,e,u.redirectCheckoutUrl);return}else if(t==="square"&&o.paymentMethods.includes("square"))ee(e),Dn(!0);else if(t==="gocardless"&&o.paymentMethods.includes("gocardless")){const r=window.location.origin,u=await k.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${r}/checkout?gocardless=confirm`,cancelUrl:`${r}/checkout?gocardless=cancel`});$e(dt,c,e,u.authorisationUrl);return}else if(t==="zip"&&o.paymentMethods.includes("zip")){const r=window.location.origin,u=await k.createZipCheckout({idempotencyKey:c,redirectUrl:`${r}/checkout?zip=return`});$e(Tr,c,e,u.redirectUrl);return}else if(t==="klarna"&&o.paymentMethods.includes("klarna")){const r=window.location.origin,u=await k.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?klarna=confirm`,cancelUrl:`${r}/checkout?klarna=cancel`});$e(pt,c,e,u.redirectUrl);return}else T(t),S(e)}catch(r){if((n||t==="card")&&r instanceof Ge&&r.status===409){T(t),await W(void 0,e);return}dn(e,r)}}function ln(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function dn(e,t){N(vn(e,t)),!e.orderNumber&&ft(t)?(B.current=!1,xe(ze())):P(e)}async function hr(e){if(!F)return;const t=F;try{const n=await k.createPaymentIntent({idempotencyKey:H}),c=await q.current?.().catch(()=>null);if(c?.orderNumber){await W(c);return}const r=ln(t,c);ee(r??{...t,expiresAt:null}),rt(e&&r!==null),re.current=n,Le(n)}catch(n){if(n instanceof Ge&&n.status===409){await W();return}Le(null),ee(null),dn(t,n)}}function wr(){F&&(B.current=!0,P(F),Le(null),ee(null),rt(!1))}return{site:o,logo:w,items:a,totals:pr,coupon:L,deliveryOptions:yt,courierUnavailable:qn,retryCourier:$n,shippingMethodId:ce,setShippingMethodId:ht,pickupLocation:Ln,servedCountries:se,formatMoney:In,payChoice:g,setPayChoice:Pe,placing:I,email:Y,setEmail:Se,firstName:R,setFirstName:Ae,lastName:j,setLastName:ve,company:Oe,setCompany:je,address1:ae,setAddress1:ie,address2:Ee,setAddress2:ue,city:U,setCity:le,postcode:_,setPostcode:de,phone:Q,setPhone:pe,country:p,setCountry:fe,subdivision:E,setSubdivision:Ke,subdivisions:me,destination:Pt,postcodeLabel:_n,subdivisionLabel:Fn,me:ye,savedAddresses:Bn,selectedAddressId:et,setSelectedAddressId:Te,saveAddress:Ot,setSaveAddress:Et,saveLabel:tt,setSaveLabel:Yn,addressSaveNote:Un,lostChangeNote:Hn,idemKey:H,confirmation:nt,setConfirmation:S,orderError:Gn,payment:xt,paypalStep:Lt,squareStep:It,pendingConf:F,paid:Wn,setPaid:te,unpaidOrder:y,orderLocked:Rt,formLocked:Jn,restoredPrices:Xt,payNote:Xn,afterpayConfirming:Zn,gocardlessConfirming:Qn,zipConfirming:Vn,klarnaConfirming:tr,cardConfirming:qt,checkoutResult:he,confirmCardPayment:W,cardStillProcessing:an,renewCardPayment:hr,holdRenewed:rr,leaveCardPayment:wr,checkoutRootRef:Ut,setCheckoutHeaderEl:or,fillFromAddress:Ht,checkoutSignOut:cr,payOptions:ne,noPaymentMethod:sr,placeOrder:fr}}const Kn=gr(null);function Co({children:o,...w}){const m=jr(w);return x(Kn.Provider,{value:m,children:o})}function bo(){const o=kr(Kn);if(!o)throw new Error("useCheckout must be used inside CheckoutStateProvider");return o}export{Co as CheckoutStateProvider,wo as NO_PAYMENT_METHOD_NOTE,go as SHIPPING_RETRY_NOTE,An as buildPayOptions,vn as paymentNotStartedMessage,ko as placedOrderLockNote,bo as useCheckout};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { CartLine } from "../../components/CartContext.js";
|
|
2
|
+
import type { OrderConfirmation, OrderRequest } from "../api/index.js";
|
|
3
|
+
export declare const CHECKOUT_MEMORY_KEY = "checkout-memory-context";
|
|
4
|
+
export declare const PRICES_REQUOTED = "Prices have changed since this checkout started. The total shows today's prices.";
|
|
5
|
+
export declare const CHECKOUT_MEMORY_LIFE_MS: number;
|
|
6
|
+
export declare function parkLine(line: CartLine): CartLine;
|
|
7
|
+
export interface ParkedRequest {
|
|
8
|
+
customer: OrderRequest["customer"];
|
|
9
|
+
items: OrderRequest["items"];
|
|
10
|
+
currency?: OrderRequest["currency"];
|
|
11
|
+
idempotencyKey: string;
|
|
12
|
+
shippingMethodId?: string;
|
|
13
|
+
couponCode?: string;
|
|
14
|
+
payFirst: boolean;
|
|
15
|
+
}
|
|
16
|
+
type Sendable = Omit<ParkedRequest, "payFirst">;
|
|
17
|
+
export declare function parkRequest(request: OrderRequest): ParkedRequest;
|
|
18
|
+
export declare function sendableRequest(parked: ParkedRequest): Sendable;
|
|
19
|
+
export interface ParkedPress {
|
|
20
|
+
key: string;
|
|
21
|
+
request: ParkedRequest;
|
|
22
|
+
lines: CartLine[];
|
|
23
|
+
goods: string;
|
|
24
|
+
plainPressed: boolean;
|
|
25
|
+
plainLines: CartLine[];
|
|
26
|
+
plainGoods: string;
|
|
27
|
+
}
|
|
28
|
+
interface ParkedForm {
|
|
29
|
+
email: string;
|
|
30
|
+
firstName: string;
|
|
31
|
+
lastName: string;
|
|
32
|
+
company: string;
|
|
33
|
+
address1: string;
|
|
34
|
+
address2: string;
|
|
35
|
+
city: string;
|
|
36
|
+
postcode: string;
|
|
37
|
+
phone: string;
|
|
38
|
+
country: string;
|
|
39
|
+
subdivision: string;
|
|
40
|
+
selectedAddressId: string;
|
|
41
|
+
shippingMethodId: string | null;
|
|
42
|
+
couponCode: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface CheckoutMemory {
|
|
45
|
+
key: string;
|
|
46
|
+
authed: boolean;
|
|
47
|
+
parkedAt: number;
|
|
48
|
+
lastPress: ParkedPress | null;
|
|
49
|
+
keptCardKey: string | null;
|
|
50
|
+
placedGoods: string | null;
|
|
51
|
+
unpaidOrder: OrderConfirmation | null;
|
|
52
|
+
placedRequest: ParkedRequest | null;
|
|
53
|
+
lines: CartLine[];
|
|
54
|
+
form: ParkedForm | null;
|
|
55
|
+
}
|
|
56
|
+
export declare function parkForm(form: ParkedForm): ParkedForm;
|
|
57
|
+
export declare function parkOrder(order: OrderConfirmation): OrderConfirmation;
|
|
58
|
+
export declare function holdsPress(memory: Pick<CheckoutMemory, "lastPress" | "unpaidOrder" | "keptCardKey">): boolean;
|
|
59
|
+
export declare function parkCheckoutMemory(memory: CheckoutMemory): void;
|
|
60
|
+
export declare function readCheckoutMemory(): CheckoutMemory | null;
|
|
61
|
+
export declare function clearCheckoutMemory(): void;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{safeSessionStorage as a}from"efficient-web-builder/format/lib/safe-storage";import{orderLinesForSets as l}from"../commerce.js";const i="checkout-memory-context",C="Prices have changed since this checkout started. The total shows today's prices.",c=2,y=3600*1e3;function h(e){return{id:e.id,slug:e.slug,name:{lead:e.name?.lead,accent:e.name?.accent},process:e.process,positionNo:e.positionNo,config:(e.config??[]).map(t=>({label:t.label,gold:t.gold})),finishName:e.finishName,size:e.size,qty:e.qty,href:e.href,kind:e.kind,sku:e.sku,components:e.components.map(t=>({partNumber:t.partNumber,wheels:t.wheels,prices:{...t.prices},hand:t.hand}))}}const r=e=>e.map(h);function u(e){const t=e.customer;return{customer:{email:t.email,name:t.name,phone:t.phone,companyName:t.companyName,address:t.address,city:t.city,state:t.state,zipCode:t.zipCode,country:t.country},items:e.items.flatMap(n=>l([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function O(e){return{...u(e),payFirst:!!e.checkoutFlow}}function x(e){return u(e)}function m(e){const t=n=>typeof n=="string"?n:"";return{email:t(e.email),firstName:t(e.firstName),lastName:t(e.lastName),company:t(e.company),address1:t(e.address1),address2:t(e.address2),city:t(e.city),postcode:t(e.postcode),phone:t(e.phone),country:t(e.country),subdivision:t(e.subdivision),selectedAddressId:t(e.selectedAddressId),shippingMethodId:typeof e.shippingMethodId=="string"?e.shippingMethodId:null,couponCode:typeof e.couponCode=="string"?e.couponCode:null}}function f(e){return{orderNumber:e.orderNumber,checkoutNumber:e.checkoutNumber,expiresAt:e.expiresAt,status:e.status,total:e.total,currency:e.currency,freightCharge:e.freightCharge,discountAmount:e.discountAmount,grandTotal:e.grandTotal,shippingMethod:e.shippingMethod,couponCode:e.couponCode}}function g(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function k(e){const t=e.parkedAt+y,n=e.unpaidOrder&&!e.unpaidOrder.orderNumber?e.unpaidOrder.expiresAt:null,s=n?Date.parse(n):NaN;return Number.isNaN(s)?t:Math.min(t,s)}function M(e){try{const t=e.lastPress,n={...e,lines:r(e.lines),lastPress:t&&{...t,lines:r(t.lines),plainLines:r(t.plainLines)}};a.setItem(i,JSON.stringify({v:c,...n}))}catch{}}const o=e=>!!e&&typeof e=="object"&&!Array.isArray(e),d=e=>o(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>o(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&o(e.customer)&&typeof e.payFirst=="boolean",p=e=>o(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function I(){let e;try{e=a.getItem(i)}catch{return null}if(!e)return null;try{const t=JSON.parse(e);if(t.v!==c||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(p)||typeof t.parkedAt!="number")return null;const n=t.lastPress,s={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,lastPress:o(n)&&typeof n.key=="string"&&d(n.request)&&Array.isArray(n.lines)&&n.lines.every(p)&&Array.isArray(n.plainLines)&&n.plainLines.every(p)?{...n,lines:r(n.lines),plainLines:r(n.plainLines)}:null,keptCardKey:typeof t.keptCardKey=="string"?t.keptCardKey:null,placedGoods:typeof t.placedGoods=="string"?t.placedGoods:null,unpaidOrder:t.unpaidOrder&&typeof t.unpaidOrder=="object"?f(t.unpaidOrder):null,placedRequest:d(t.placedRequest)?t.placedRequest:null,lines:r(t.lines),form:t.form&&typeof t.form=="object"?m(t.form):null};return Date.now()>=k(s)?(N(),null):g(s)?s:null}catch{return null}}function N(){try{a.removeItem(i)}catch{}}export{i as CHECKOUT_MEMORY_KEY,y as CHECKOUT_MEMORY_LIFE_MS,C as PRICES_REQUOTED,N as clearCheckoutMemory,g as holdsPress,M as parkCheckoutMemory,m as parkForm,h as parkLine,f as parkOrder,O as parkRequest,I as readCheckoutMemory,x as sendableRequest};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EventPost } from "efficient-web-builder/render/components/PostCard";
|
|
2
|
+
import type { BlogPostRow } from "efficient-web-builder/format/lib/web-backend";
|
|
3
|
+
import type { AdminBlogPost } from "../api/index.js";
|
|
4
|
+
export declare function blogPostRowOfAdmin(post: AdminBlogPost): BlogPostRow;
|
|
5
|
+
export declare function eventPostOf(row: BlogPostRow): EventPost;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{absolutizeApiUrl as r}from"efficient-web-builder/render/lib/media";import{postDateLabel as i}from"efficient-web-builder/format/lib/content/post-date";import{postPath as l}from"efficient-web-builder/format/lib/links/page-link-rules";function u(e){return{slug:e.slug,title:e.title,excerpt:e.excerpt,category:e.category,coverImage:e.cover_image?r(e.cover_image)??"":"",publishedAt:e.published_at,href:l(e.slug)}}function g(e){const t=e.category.trim();return{slug:e.slug,title:e.title,excerpt:e.excerpt,cover:e.coverImage,meta:t||void 0,dateLabel:i(e.publishedAt)||void 0}}export{u as blogPostRowOfAdmin,g as eventPostOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as f}from"react/jsx-runtime";import{phoneKey as
|
|
1
|
+
import{jsx as f}from"react/jsx-runtime";import{phoneKey as g}from"efficient-easel/draw";import h,{readFacets as x,readTags as k}from"../../../../../components/Events.js";import{declaredBlockSource as v,sourcedRows as y}from"efficient-web-builder/format/lib/content/block-sources";import{servedListOf as b,servedRowLists as E}from"../../../../content/served-lists.js";import{hidableText as S}from"efficient-easel/screen/lib/document/hidable";import{parseSectionHeadPlacement as A}from"efficient-web-builder/format/lib/sections/section-head-placement";import{phHide as l}from"efficient-web-builder/render/lib/document/blocks/scaffold";import{say as a}from"efficient-web-builder/format/lib/editor-words";import{bandPadProps as P}from"../../../../sections/band-padding.js";import{EventsMeta as C,EVENTS_PH as m}from"./meta.js";const F=()=>[{key:"sample-1",title:a("First card"),excerpt:a("A line about it appears here.")},{key:"sample-2",title:a("Second card"),excerpt:a("A line about it appears here.")},{key:"sample-3",title:a("Third card"),excerpt:a("A line about it appears here.")},{key:"sample-4",title:a("Fourth card"),excerpt:a("A line about it appears here.")}],o=(e,i,t)=>({slug:e.key||`card-${i}`,title:e.title??"",excerpt:e.excerpt??"",cover:e.cover??"",meta:e.meta||void 0,dateLabel:e.dateLabel||void 0,href:e.href||"#",...t?.facets?{facets:t.facets}:{},...t?.tags?{tags:t.tags}:{}}),H=e=>E(e,i=>({facets:x(i.facets),tags:k(i.tags)})),N={...C,render:e=>{const i=A(e.headPlacement)==="own-box",t=r=>i?void 0:r,s=l(e.linkText,m.link,e.editor),n=v(e)!==""?y(e,!!e.editor?.isEditing,F()):null,c=n&&!n.sample?H(e):null,u=n?n.sample?[]:n.rows.map((r,d)=>o(r,d,b(c,r,d))):e.posts;return f(h,{num:t(l(e.num,m.num,e.editor)),title:t(l(e.title,m.title,e.editor)),link:t(s?{text:s,href:S(e.linkHref)||"/journal"}:void 0),omitHead:i,posts:u,servedCategory:e.servedCategory,sample:n?.sample?n.rows.map((r,d)=>o(r,d)):void 0,columns:e.columns,limit:e.limit,showAll:e.showAll,layout:e.layout,featuredWidth:e.featuredWidth,listCover:e.listCover,featuredDarken:e.featuredDarken,cardImage:e.cardImage,gap:e.gap,gapPhone:e[g("gap")],nameFilter:e.nameFilter===!0,pads:P(e),editing:e.editor?.isEditing,template:e.template,ownerId:String(e.id??"")})}};export{N as EventsRender};
|
|
@@ -6,6 +6,8 @@ export declare const FROM_PREFIX = "from ";
|
|
|
6
6
|
export declare const FROM_PREFIX_START = "From ";
|
|
7
7
|
export declare const EACH_UNIT = "each";
|
|
8
8
|
export declare const FREE_PRICE = "Free";
|
|
9
|
+
export declare const FIGURE_TO_COME = "\u2026";
|
|
10
|
+
export declare const FIGURE_UPDATING = "Updating";
|
|
9
11
|
export declare function isPriced(amount: number | null | undefined): amount is number;
|
|
10
12
|
export declare function priceIn(prices: Record<string, number | null> | undefined, currency: string): number | null;
|
|
11
13
|
export declare function comparePrice(a: Record<string, number | null> | undefined, b: Record<string, number | null> | undefined, currency: string, direction: "asc" | "desc"): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatPrice as s,setPrice as P,WHEELS_PER_SET as m}from"../commerce.js";const c="Price on request",E="Request a quote",f="from ",
|
|
1
|
+
import{formatPrice as s,setPrice as P,WHEELS_PER_SET as m}from"../commerce.js";const c="Price on request",E="Request a quote",f="from ",_="From ",w="each",I="Free",h="…",U="Updating";function i(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function a(t,e){const n=t?.[e];return i(n)?n:null}function g(t,e,n,l){const r=a(t,n),o=a(e,n);return r===null&&o===null?0:r===null?1:o===null?-1:l==="asc"?r-o:o-r}function C(t,e,n,l){if(n==null&&l==null)return!0;const r=a(t,e);return!(r===null||n!=null&&r<n||l!=null&&r>l)}const T={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function x(t,e,n){if(!i(t))return T;const l=i(e)&&e>t?e:null;return{priced:!0,unit:t,was:l,onSale:l!==null,setTotal:n!=null?t*n:null}}function L(t,e,n=""){return!t.priced||t.unit==null?c:`${n}${s(t.unit,e)}`}function N(t,e){return t.was==null?null:s(t.was,e)}function F(t,e,n=1){const l=P(t,e);if(l===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};const r=t.reduce((u,p)=>u+p.wheels,0),o=Math.min(...t.map(u=>u.prices[e]));return{priced:!0,unit:o,isFrom:o*r!==l,setTotal:l*n}}const S={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function O(t,e,n,l=1){const r=x(t.prices[n],t.msrpPrices?.[n],m),o=r.setTotal==null?null:r.setTotal*l;if(!e)return{priced:r.priced,unit:r.unit,isFrom:!0,was:r.was,onSale:r.onSale,setTotal:null,fromSetTotal:o};const u=F(e.components,n,l);return u.priced?{priced:!0,unit:u.unit,isFrom:u.isFrom,was:null,onSale:!1,setTotal:u.setTotal,fromSetTotal:o}:{...S,fromSetTotal:o}}function d(t,e){return!t.priced||t.unit==null?c:`${t.isFrom?f:""}${s(t.unit,e)}`}function W(t,e){return t.was==null?null:s(t.was,e)}function $(t,e){return!t.priced||t.unit==null?E:d(t,e)}function v(t,e){const n=t.savings[e];if(n===void 0||t.components.length===0)return null;let l=0;for(const o of t.components){const u=o.prices?.[e];if(typeof u!="number")return null;l+=u*o.quantity}const r=s(l-n,e);return{was:s(l,e),amount:t.savingIsFrom?`${f}${r}`:r}}export{w as EACH_UNIT,h as FIGURE_TO_COME,U as FIGURE_UPDATING,I as FREE_PRICE,f as FROM_PREFIX,_ as FROM_PREFIX_START,E as SET_QUOTE_LABEL,c as UNPRICED_LABEL,v as bundlePrice,g as comparePrice,d as formatSelectionPrice,W as formatSelectionWasPrice,L as formatWheelPrice,N as formatWheelWasPrice,i as isPriced,a as priceIn,O as resolveSelectionPrice,F as resolveSetPrice,x as resolveWheelPrice,$ as setPriceLabel,C as withinPriceRange};
|
|
@@ -15,3 +15,4 @@ export declare function shopperAddressMarkOf(props: Readonly<Record<string, unkn
|
|
|
15
15
|
export declare function stampSelectedRanges(data: Data, query: AddressQuery, knownNames: readonly string[]): Data;
|
|
16
16
|
export declare function stripSelectedRanges(data: Data): Data;
|
|
17
17
|
export declare function pageReadsSelectedRanges(data: Data | null | undefined): boolean;
|
|
18
|
+
export declare function pageReadsRangeNames(data: Data | null | undefined): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SHOW_FOR_PROP as
|
|
1
|
+
import{SHOW_FOR_PROP as O,showForOf as A}from"efficient-web-builder/format/lib/content/box-show-for-choices";import{asPlpSortKey as S,plpFilterQuery as h,plpFiltersFromParams as k}from"./plp-filters.js";import{marksCurrentLink as L,menuLayoutOf as x}from"../content/tab-strip.js";import{ALLOY_WHEELS_LISTING_TYPE as D,FILTER_BLOCK_TYPE as F,MENU_BLOCK_TYPE as g,documentNodes as R,mapDocumentNodes as y}from"../document/document-nodes.js";import{documentShopperScopes as N,pageReachFilterOf as T}from"./shopper-first-paint.js";const u="selectedRanges",i="shopperAddress",m="addressQuery",U=[D,g];function P(r){return U.includes(r.type)?r.type===g?L(x(r.props.direction),r.props.currentPage):!0:!1}function K(r){const e=r?.[m];return typeof e=="string"?e:""}function _(r){if(typeof r=="string")return new URLSearchParams(r.replace(/^\?/,""));if(r instanceof URLSearchParams)return r;const e=new URLSearchParams;for(const[s,t]of Object.entries(r))if(typeof t=="string")e.append(s,t);else if(Array.isArray(t))for(const o of t)typeof o=="string"&&e.append(s,o);return e}function Y(r,e){const s=new Set(e),t=[];for(const o of k(_(r)).collections)s.has(o)&&!t.includes(o)&&t.push(o);return t}function M(r){const e=r?.[u];if(!e||!Array.isArray(e.selected)||!Array.isArray(e.known))return null;const s=o=>o.filter(n=>typeof n=="string"),t=s(e.known);return{selected:s(e.selected).filter(o=>t.includes(o)),known:t}}function j(r){const e=r?.[i];return!e||typeof e!="object"?null:{writes:e.writes===!0,sort:S(typeof e.sort=="string"?e.sort:void 0)}}function v(r,e,s){const t=[...new Set(s)],o={selected:Y(e,t),known:t},n=T(r),c=new Map;if(n){const p=S(typeof n.props?.openingSort=="string"?n.props.openingSort:void 0);c.set(n,{[i]:{writes:!0,sort:p}});for(const[a,E]of N(r))E===n&&c.set(a,{[i]:{writes:!1,sort:p}})}const l=h(_(e));if(l)for(const p of R(r))P(p)&&c.set(p,{...c.get(p),[m]:l});const f=c.size?y(r,(p,a)=>c.has(a)?{...p,props:{...p.props,...c.get(a)}}:p):r,d=f.root??{};return{...f,root:{...d,props:{...d.props??{},[u]:o}}}}function B(r){const e=y(r,n=>{if(!(i in n.props)&&!(m in n.props))return n;const{[i]:c,[m]:l,...f}=n.props;return{...n,props:f}}),s=e.root;if(!s?.props||!(u in s.props))return e;const{[u]:t,...o}=s.props;return{...e,root:{...s,props:o}}}function w(r){return r.type===F||A(r.props[O])!==void 0}function G(r){return r?R(r).some(e=>w(e)||P(e)):!1}function W(r){return r?R(r).some(w):!1}export{u as SELECTED_RANGES_PROP,i as SHOPPER_ADDRESS_PROP,K as addressQueryOf,W as pageReadsRangeNames,G as pageReadsSelectedRanges,Y as readSelectedRanges,M as selectedRangesOf,j as shopperAddressMarkOf,v as stampSelectedRanges,B as stripSelectedRanges};
|