efficient-storefront-blocks 0.125.2 → 0.125.4
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 +34 -0
- package/dist/chunks/{CustomHtmlCodeWindow-VRZ524JP.js → CustomHtmlCodeWindow-KB7QEJAG.js} +1 -1
- package/dist/chunks/EditorPreviewCheckout-3ZX2DIIL.js +4 -0
- package/dist/chunks/SiteEditorProvider-TYNFV3WZ.js +1 -0
- package/dist/chunks/{chunk-4KN3VTQU.js → chunk-4M7WJPOZ.js} +6 -6
- package/dist/chunks/{chunk-PULBLZRR.js → chunk-4WRJWM6K.js} +1 -1
- package/dist/chunks/chunk-5SWY36EZ.js +1 -0
- package/dist/chunks/{chunk-FNCEZSDY.js → chunk-ACYEMD5J.js} +1 -1
- package/dist/chunks/chunk-DHKJAYUG.js +337 -0
- package/dist/chunks/chunk-HKL2EKLO.js +96 -0
- package/dist/chunks/{chunk-TVMCJUOE.js → chunk-RGLTNGJH.js} +1 -1
- package/dist/chunks/{fitment-data-C2NHZBPR.js → fitment-data-CFDAFXJB.js} +1 -1
- package/dist/chunks/{section-css-style-BECHWIDU.js → section-css-style-TKWJ7WU2.js} +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.js +66 -29
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/CartContext.d.ts +2 -0
- package/dist/render/components/CartContext.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/lib/cart/restore-lines.d.ts +13 -0
- package/dist/render/lib/cart/restore-lines.js +1 -0
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/dist/words.d.ts +1 -0
- package/dist/words.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/EditorPreviewCheckout-3TKWZ44N.js +0 -4
- package/dist/chunks/SiteEditorProvider-OBXLJM7I.js +0 -1
- package/dist/chunks/chunk-6ABZ7XWF.js +0 -96
- package/dist/chunks/chunk-HQFRQZ6J.js +0 -1
- package/dist/chunks/chunk-J6SPMJBT.js +0 -337
- /package/dist/chunks/{chunk-7UJXVH57.js → chunk-3DCSW3PN.js} +0 -0
- /package/dist/chunks/{chunk-EZ5QLDA5.js → chunk-5NGS7VFJ.js} +0 -0
- /package/dist/chunks/{chunk-FNCEZSDY.js.LEGAL.txt → chunk-ACYEMD5J.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-UV27QVUD.js → chunk-AEBQM5LZ.js} +0 -0
- /package/dist/chunks/{chunk-J6SPMJBT.js.LEGAL.txt → chunk-DHKJAYUG.js.LEGAL.txt} +0 -0
|
@@ -2,6 +2,7 @@ import { type AppliedBundle, type Bundle, type CartQuote, type CouponEffects, ty
|
|
|
2
2
|
import { type PurchaseChoice, type SetComponent } from "../lib/commerce.js";
|
|
3
3
|
import { type ShippingStatus } from "../lib/cart/shipping-status.js";
|
|
4
4
|
type CartQuoteTax = CartQuote["tax"];
|
|
5
|
+
export declare const CART_STORAGE_KEY = "storefront-cart";
|
|
5
6
|
export interface CartLine {
|
|
6
7
|
id: string;
|
|
7
8
|
slug: string;
|
|
@@ -58,6 +59,7 @@ interface CartCtx {
|
|
|
58
59
|
remove: (id: string) => void;
|
|
59
60
|
setQty: (id: string, qty: number) => void;
|
|
60
61
|
replaceItems: (lines: CartLine[]) => void;
|
|
62
|
+
restoreDropped: string[];
|
|
61
63
|
identify: (email: string, firstName?: string) => void;
|
|
62
64
|
clearCapturedCart: () => void;
|
|
63
65
|
coupon: AppliedCoupon | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as oe}from"react/jsx-runtime";import{createContext as re,useCallback as a,useContext as se,useEffect as p,useMemo as xt,useRef as g,useState as i}from"react";import{usePathname as ue}from"next/navigation";import{products as C}from"../lib/api/index.js";import{couponDeferredToCheckout as ce}from"../lib/cart/coupon-preview.js";import{snapshotCartLines as Dt}from"../lib/cart/snapshot-lines.js";import{restoreCartLines as ie}from"../lib/cart/restore-lines.js";import{safeLocalStorage as F}from"efficient-web-builder/format/lib/safe-storage";import{MAX_QTY_PER_LINE as Pt,orderLinesForSets as ae,setPrice as le}from"../lib/commerce.js";import{UNPRICED_LABEL as de}from"../lib/wheels/price-display.js";import{isValidEmail as fe}from"../lib/email-shape.js";import{trackAddToCart as me}from"../lib/google-tag.js";import{shippingStatus as pe}from"../lib/cart/shipping-status.js";import{useCurrency as he}from"./CurrencyContext.js";const ye=400,ge=400,Ce=1500,J="storefront-cart";function j(d){return(d.components?.length??0)>0}function kt(d,r){return{code:d,valid:r.valid,deferred:ce(r,r.askedAsShopper),message:r.message||void 0,effects:r.effects??void 0}}function Ut(d,r){return le(d.components,r)}function H(d,r){const u=Ut(d,r);return u===null?null:u*d.qty}function Lt(d){return d!=="tyre"}const Qt=re(null);function De({children:d,preview:r=!1}){const{currency:u,country:Y,formatMoney:wt}=he(),[z,k]=i(r),[s,q]=i([]),[G,Wt]=i([]),[K,Vt]=i([]),[X,Ft]=i(!1),Z=g(new Set),[$,Jt]=i([]),[jt,Ht]=i(!1),[f,v]=i(null),[tt,et]=i(null),[nt,ot]=i(null),[Yt,zt]=i(0),rt=a(()=>zt(t=>t+1),[]),[st,ut]=i(void 0),[N,Gt]=i(null),[l,E]=i(null),[ct,A]=i(!1),[h,it]=i(null),B=g(void 0),I=a(()=>k(!0),[]),R=a(()=>k(!1),[]),at=a(()=>k(t=>!t),[]);p(()=>{r||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&I()},[I,r]);const _=ue(),lt=g(_);p(()=>{lt.current!==_&&(lt.current=_,r||R())},[_,r,R]);const dt=a(t=>{Gt(n=>n?.country===t?.country&&n?.subdivision===t?.subdivision&&n?.postcode===t?.postcode?n:t)},[]),ft=a((t,n)=>{Ht(!0),!(!n||!Lt(t))&&Jt(e=>e.includes(n)?e:[...e,n])},[]),mt=jt||s.length>0,U=g(!0);p(()=>(U.current=!0,()=>{U.current=!1}),[]),p(()=>{if(r)return;const t=[...$,...s.filter(e=>Lt(e.kind)).map(e=>e.slug)],n=[...new Set(t)].filter(e=>e&&!Z.current.has(e));if(n.length!==0){for(const e of n)Z.current.add(e);C.listWheelsBySlug(n).then(e=>{if(!U.current||e.length===0)return;const o=new Set(e.map(c=>c.slug));Wt(c=>[...c.filter(b=>!o.has(b.slug)),...e])})}},[r,$,s]),p(()=>{if(r||!mt||X)return;let t=!0;return C.listBundles().then(n=>{t&&(Vt(n),Ft(!0))}),()=>{t=!1}},[r,mt,X]);const S=f?.deliveryOptions??[],pt=f?.courier??null;p(()=>{f&&it(t=>t&&S.some(n=>n.id===t)?t:S[0]?.id??null)},[f]);const M=a(()=>s.filter(j).flatMap(t=>ae(t.components,t.qty)),[s]),ht=a(async(t,n)=>{const e=t.trim().toUpperCase();if(!e)return;const o=M();if(o.length===0){E({code:e,valid:!1,message:"Add a wheel to the cart first."});return}A(!0),B.current=n;try{const c=await C.validateCoupon({code:e,items:o,currency:u,shippingMethodId:h??void 0,customerEmail:n});E(kt(e,c))}catch{E({code:e,valid:!1,unchecked:!0,message:"Could not check that code. Please try again."})}finally{A(!1)}},[M,u,h]),yt=a(()=>{E(null),B.current=void 0},[]),gt=a(t=>{if(!l)return;const{code:n}=l;E(e=>e&&e.code===n?{code:n,valid:!1,refused:!0,message:t}:e)},[l]);p(()=>{if(!l||l.refused)return;const t=l.code,n=o=>o!==null&&o.code===t&&!o.refused,e=setTimeout(async()=>{const o=M();if(o.length===0){E(c=>n(c)?{code:t,valid:!1,message:"Add a wheel to the cart first."}:c);return}A(!0);try{const c=await C.validateCoupon({code:t,items:o,currency:u,shippingMethodId:h??void 0,customerEmail:B.current});E(b=>n(b)?kt(t,c):b)}catch{}finally{A(!1)}},ye);return()=>clearTimeout(e)},[s,u,h]);const L=l&&!l.refused?l.code:void 0;p(()=>{if(r)return;let t=!0;const n=s,e=setTimeout(async()=>{const o=M();if(o.length===0){v(null),et(null),ut(void 0);return}try{const c=await C.quoteCart({items:o,currency:u,shippingMethodId:h??void 0,couponCode:L,customerEmail:B.current||void 0,country:N?.country||Y||void 0,subdivision:N?.country&&N.subdivision||void 0,postcode:N?.country&&N.postcode||void 0});if(!t)return;v(c),et(n),ot(null)}catch{if(!t)return;ot(n)}ut(L)},ge);return()=>{t=!1,clearTimeout(e)}},[s,u,h,L,Y,N,Yt]);const x=a(t=>{q(n=>{const e=n.findIndex(o=>o.id===t.id);return e===-1?[...n,t]:n.map((o,c)=>c===e?{...o,qty:Math.min(Pt,o.qty+t.qty)}:o)}),me(t,u)},[u]),Ct=a(t=>{q(n=>n.filter(e=>e.id!==t))},[]),Et=a((t,n)=>{const e=Math.max(1,Math.min(Pt,n));q(o=>o.map(c=>c.id===t?{...c,qty:e}:c))},[]),D=a(t=>{q(t)},[]),[St,Q]=i(!1),[bt,Kt]=i([]),Nt=g(s);Nt.current=s,p(()=>{if(r)return;let t=[];try{const e=JSON.parse(F.getItem(J)??"[]");Array.isArray(e)&&(t=e)}catch{}if(t.length===0){Q(!0);return}let n=!0;return ie(t,C).then(({lines:e,dropped:o})=>{n&&(Nt.current.length===0&&(D(e),Kt(o)),Q(!0))},e=>{n&&(process.env.NODE_ENV!=="production"&&console.warn("stored cart could not be rebuilt",e),Q(!0))}),()=>{n=!1}},[r,D]),p(()=>{if(r||!St)return;const t=s.filter(j);if(t.length===0){F.removeItem(J);return}F.setItem(J,JSON.stringify(Dt(t,()=>"")))},[s,r,St]);const[O,Xt]=i(null),It=g(null);It.current=O;const y=g(null),w=g(""),Tt=a((t,n)=>{const e=t.trim().toLowerCase();fe(e)&&Xt(o=>o&&o.email===e&&o.firstName===(n??"")?o:{email:e,firstName:n??""})},[]);p(()=>{if(r||!O)return;const t=Dt(s.filter(j),o=>H(o,u)===null?de:wt(H(o,u),u)),n={email:O.email,firstName:O.firstName,currency:u,items:t},e=JSON.stringify(n);if(e!==w.current)return y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,w.current=e,C.captureCart(n).catch(o=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart capture failed",o)})},Ce),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[s,O,u,r]);const Ot=a(()=>{y.current&&(clearTimeout(y.current),y.current=null);const t=It.current;t&&(w.current="",C.captureCart({email:t.email,firstName:t.firstName,currency:u,items:[]}).catch(n=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart clear failed",n)}))},[u]),qt=xt(()=>{const t=s.reduce((m,T)=>{const P=H(T,u);return P===null?m:m+P},0),n=s.some(m=>Ut(m,u)===null),e=s.reduce((m,T)=>m+T.qty,0),o=l?.valid?l.effects:void 0,c=o?Math.min(t,Number(o.discountAmount)):0,b=f?.bundleDiscount??0,$t=f?.appliedBundles??[],W=!!o?.freeShipping,_t=S.find(m=>m.id===h),Mt=W?0:f?.shipping??_t?.amount??0,vt=pe({quoted:f!==null,optionCount:S.length,chosenAmount:_t?.amount,couponWaivesFreight:W}),V={};for(const m of o?.freeUnits??[])V[m.partNumber]=(V[m.partNumber]??0)+m.quantity;const te=f?.tax??null,ee=f?f.grandTotal:t-c-b+Mt;return{sets:e,units:s.reduce((m,T)=>m+(T.components??[]).reduce((P,ne)=>P+ne.wheels*T.qty,0),0),subtotal:t,hasUnpricedLine:n,discount:c,bundleDiscount:b,appliedBundles:$t,shipping:Mt,freeShipping:W,shippingStatus:vt,freeUnitsByPartNumber:V,tax:te,grand:ee,repricing:!!l?.refused&&f!==null&&st===l?.code,quoted:f!==null&&tt===s,serverSubtotal:f?.subtotal??null,quoteFailed:nt===s,currency:u}},[s,u,l,S,h,f,st,tt,nt]),At=g(!0),Bt=a(t=>{At.current=t},[]),Rt=a(t=>{x(t),At.current&&I()},[x,I]),Zt=xt(()=>({isOpen:z,preview:r,open:I,close:R,toggle:at,items:s,catalog:G,bundles:K,warmCatalog:ft,add:x,addAndOpen:Rt,setAutoOpen:Bt,remove:Ct,setQty:Et,replaceItems:D,restoreDropped:bt,identify:Tt,clearCapturedCart:Ot,coupon:l,applyCoupon:ht,removeCoupon:yt,refuseCoupon:gt,couponBusy:ct,deliveryOptions:S,setQuoteDestination:dt,courier:pt,requote:rt,shippingMethodId:h,setShippingMethodId:it,totals:qt}),[z,r,I,R,at,s,G,K,ft,x,Rt,Bt,Ct,Et,D,bt,Tt,Ot,l,ht,yt,gt,ct,S,dt,pt,rt,h,qt]);return oe(Qt.Provider,{value:Zt,children:d})}function Pe(){const d=se(Qt);if(!d)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return d}export{J as CART_STORAGE_KEY,De as CartProvider,j as isOrderable,H as lineTotal,Pe as useCart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as O}from"react";import V from"next/image";import X from"next/link";import{lineTotal as Z,useCart as J}from"../CartContext.js";import{useCurrency as ee}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import te from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ne}from"../../lib/cart/coupon-preview.js";import{orderReference as ae}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as re,PRICES_UNCHECKED as ie}from"../../lib/checkout/checkout-memory.js";import{shippingWords as le,TAX_PENDING as oe}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ce}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import g from"../WebFormField.js";import se from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as de,placedOrderLockNote as pe,SHIPPING_RETRY_NOTE as me,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function $e(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:f,setCompany:v,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=w(),c=O();return a(L,{num:"N° 01",title:"Contact",children:[x&&o&&e(ge,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:c,hint:b?a(N,{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:c,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(z,{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=>d(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>v(p.target.value),autoComplete:"organization",className:u})})]})}function Me(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:f,setCity:v,postcode:b,setPostcode:h,phone:x,setPhone:o,country:c,setCountry:p,subdivision:k,setSubdivision:m,subdivisions:E,destination:F,postcodeLabel:S,subdivisionLabel:y,me:B,savedAddresses:R,selectedAddressId:P,setSelectedAddressId:D,saveAddress:$,setSaveAddress:H,saveLabel:G,setSaveLabel:W,fillFromAddress:K,orderLocked:Q}=w(),M=O(),j=O();return a(L,{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.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),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:[B!==null&&R.length>0&&a("div",{className:"grid gap-3",children:[R.map(r=>e(I,{active:P===r.id,onClick:()=>{D(r.id),K(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:P==="new",onClick:()=>D("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=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(z,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>v(r.target.value),className:u})}),e(g,{label:S,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>p(r.target.value),className:u+" pr-10",style:q,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:k,onChange:r=>m(r.target.value),className:u+" pr-10",style:q,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:k,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&&B!==null&&P==="new"&&!Q&&a(N,{children:[e(fe,{checked:$,onChange:H,label:"Save this address to my account"}),$&&e(g,{label:"Address label",children:e("input",{type:"text",value:G,onChange:r=>W(r.target.value),placeholder:"Home",className:u})})]})]})}function Ue(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:f,city:v,destination:b,courierUnavailable:h,retryCourier:x}=w();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,p=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[p,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A: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:[me," ",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}=w();return a(L,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:de}),e("div",{className:"grid gap-3",children:l.map(d=>e(I,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.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:d,placing:f,email:v,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:c,restoredPrices:p,quoteFailed:k,retryQuote:m,placeOrder:E}=w(),F=p==="waiting",S=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(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(y=>e(xe,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:be(y.config),price:S||F?null:Z(y,n.currency)??0,currency:n.currency},y.id))}),e(he,{locked:c,className:"border-t border-line px-6 pt-5",children:e(te,{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:F?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(C,{label:`Coupon · ${l.code}`,value:ne}),l?.valid&&l.effects?.gift&&e(C,{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:A})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):le(n.shippingStatus)??s(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:s(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:oe}):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?T:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[S&&e(_,{tone:"quiet",children:re}),k&&a(_,{role:"alert",children:[ie," ",e("button",{type:"button",onClick:m,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),b&&e(_,{role:"alert",children:b}),n.hasUnpricedLine&&a(_,{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:E,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(N,{children:["Building order… ",e("span",{children:"·"})]}):x?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:["Try payment again · ",ae(o),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):k?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[d==="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 Y({href:t,className:i="",children:n,...l}){const{placing:s}=w();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(X,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function ge({orderNumber:t}){return e(_,{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:pe(t)})]})})}const q={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 L({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 z({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 I({active:t,onClick:i,title:n,body:l,price:s,tag:d}){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,d&&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:d})]}),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:d,currency:f}){const{catalog:v}=J(),{formatMoney:b}=ee(),h=v.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,c=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===c&&m.src)??h?.finishes.find(m=>m.src),k=h?.finishes[0]?.color??ce;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(V,{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:k},children:e(se,{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:d===null?null:b(d,f)})]})}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 be(t){return t.map(i=>i.label).join(" · ")}export{$e as CheckoutContact,qe as CheckoutOrderSummary,Ye as CheckoutPayment,Me as CheckoutShippingAddress,Ue as CheckoutShippingMethod,he as FormLock,Y as LeaveLink};
|
|
1
|
+
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as O}from"react";import X from"next/image";import Z from"next/link";import{lineTotal as J,useCart as ee}from"../CartContext.js";import{useCurrency as te}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import ne from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ae}from"../../lib/cart/coupon-preview.js";import{orderReference as re}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as ie,PRICES_UNCHECKED as le}from"../../lib/checkout/checkout-memory.js";import{shippingWords as oe,TAX_PENDING as ce}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as se}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import g from"../WebFormField.js";import de from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as pe,placedOrderLockNote as me,SHIPPING_RETRY_NOTE as ue,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function Me(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:f,setCompany:v,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=w(),c=O();return a(L,{num:"N° 01",title:"Contact",children:[x&&o&&e(fe,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:c,hint:b?a(N,{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:c,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(H,{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=>d(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>v(p.target.value),autoComplete:"organization",className:u})})]})}function Ue(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:f,setCity:v,postcode:b,setPostcode:h,phone:x,setPhone:o,country:c,setCountry:p,subdivision:k,setSubdivision:m,subdivisions:E,destination:F,postcodeLabel:S,subdivisionLabel:y,me:B,savedAddresses:R,selectedAddressId:P,setSelectedAddressId:D,saveAddress:$,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:Q,orderLocked:V}=w(),M=O(),j=O();return a(L,{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.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),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:[B!==null&&R.length>0&&a("div",{className:"grid gap-3",children:[R.map(r=>e(I,{active:P===r.id,onClick:()=>{D(r.id),Q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:P==="new",onClick:()=>D("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=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(H,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>v(r.target.value),className:u})}),e(g,{label:S,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>p(r.target.value),className:u+" pr-10",style:q,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:k,onChange:r=>m(r.target.value),className:u+" pr-10",style:q,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:k,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&&B!==null&&P==="new"&&!V&&a(N,{children:[e(xe,{checked:$,onChange:G,label:"Save this address to my account"}),$&&e(g,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:u})})]})]})}function Ye(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:f,city:v,destination:b,courierUnavailable:h,retryCourier:x}=w();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,p=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[p,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A: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:[ue," ",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 qe(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=w();return a(L,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:pe}),e("div",{className:"grid gap-3",children:l.map(d=>e(I,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.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 He(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:f,email:v,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:c,restoredPrices:p,quoteFailed:k,retryQuote:m,placeOrder:E}=w(),F=p==="waiting",S=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(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(y=>e(be,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:ye(y.config),price:S||F?null:J(y,n.currency)??0,currency:n.currency},y.id))}),e(ge,{locked:c,className:"border-t border-line px-6 pt-5",children:e(ne,{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:F?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(C,{label:`Coupon · ${l.code}`,value:ae}),l?.valid&&l.effects?.gift&&e(C,{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:A})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):oe(n.shippingStatus)??s(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:s(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:ce}):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?T:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[S&&e(_,{tone:"quiet",children:ie}),k&&a(_,{role:"alert",children:[le," ",e("button",{type:"button",onClick:m,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),b&&e(_,{role:"alert",children:b}),n.hasUnpricedLine&&a(_,{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:E,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 max-[640px]:whitespace-nowrap max-[640px]:tracking-[0.04em]",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(N,{children:["Building order… ",e("span",{children:"·"})]}):x?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:[a("span",{children:["Try payment again",a(z,{children:[" · ",re(o)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):k?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[a("span",{children:[d==="bank"?"Place order":"Continue to payment",a(z,{children:[" · ",s(n.grand,n.currency)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const he=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ge({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+he,children:n})}function Y({href:t,className:i="",children:n,...l}){const{placing:s}=w();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(Z,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function fe({orderNumber:t}){return e(_,{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:me(t)})]})})}const q={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 L({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 H({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 I({active:t,onClick:i,title:n,body:l,price:s,tag:d}){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,d&&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:d})]}),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 xe({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 be({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:f}){const{catalog:v}=ee(),{formatMoney:b}=te(),h=v.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,c=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===c&&m.src)??h?.finishes.find(m=>m.src),k=h?.finishes[0]?.color??se;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(X,{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:k},children:e(de,{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:d===null?null:b(d,f)})]})}function z({children:t}){return e("span",{className:"max-[640px]:sr-only",children:t})}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 ye(t){return t.map(i=>i.label).join(" · ")}export{Me as CheckoutContact,He as CheckoutOrderSummary,qe as CheckoutPayment,Ue as CheckoutShippingAddress,Ye as CheckoutShippingMethod,ge as FormLock,Y as LeaveLink};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CartLine } from "../../components/CartContext.js";
|
|
2
|
+
import { type CartLineSnapshot, type Tyre, type TyreVariant, type Wheel } from "../api/index.js";
|
|
3
|
+
export interface ProductResolvers {
|
|
4
|
+
getWheel: (slug: string) => Promise<Pick<Wheel, "name" | "process" | "variants">>;
|
|
5
|
+
getTyre: (slug: string) => Promise<Pick<Tyre, "slug" | "name" | "brand"> & {
|
|
6
|
+
variants: Pick<TyreVariant, "sku" | "size" | "prices">[];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export interface RestoredCart {
|
|
10
|
+
lines: CartLine[];
|
|
11
|
+
dropped: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function restoreCartLines(items: CartLineSnapshot[], products: ProductResolvers): Promise<RestoredCart>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{tyreCartLine as h}from"../tyres/tyre-purchase.js";import{findVariant as d,setLabel as f}from"../wheels/variants.js";import{splitWheelName as y}from"../wheels/wheel-name.js";import{purchaseChoiceFromPack as m,setPackComposition as N,withSpare as b}from"../commerce.js";import{ApiError as g}from"../api/index.js";const p="alloy-wheel",w="tyre";function c(n){return n.name||n.slug||"An item from your cart"}async function D(n,s){const t=[],e=new Map;for(const o of n){if(!o.slug){t.push(c(o));continue}const a=o.kind??p,l=`${a}\0${o.slug}`,u=e.get(l);u?u.snaps.push(o):e.set(l,{kind:a,slug:o.slug,snaps:[o]})}const i=await Promise.all([...e.values()].map(o=>L(o,s))),r=[];for(const o of i)for(const a of o)a.ok?r.push(a.line):t.push(a.name);return{lines:r,dropped:t}}function k(n){if(n instanceof g&&n.status===404)return null;throw n}async function L(n,s){const t=n.snaps.map(e=>({ok:!1,name:c(e)}));if(n.kind===p){const e=await s.getWheel(n.slug).catch(k);return e?n.snaps.map(i=>$(n.slug,e,i)):t}if(n.kind===w){const e=await s.getTyre(n.slug).catch(k);return e?n.snaps.map(i=>v(e,i)):t}return t}function $(n,s,t){const e=d(s.variants,t.finish,t.size);if(!e)return{ok:!1,name:c(t)};const i=t.pack?m(t.pack):void 0,r=(i?.spares??0)>0;return{ok:!0,line:{id:`${n}|${e.finishName}|${e.size}${r?"|spare":""}|restored`,slug:n,name:y(s.name),process:s.process,positionNo:"01",config:[{label:e.size},{label:e.finishName,gold:!0},{label:i?b(f(e),i):f(e)}],finishName:e.finishName,size:e.size,components:i&&r?N(e.components,i):e.components,qty:t.qty,...r?{pack:i}:{}}}}function v(n,s){const t={ok:!1,name:c(s)};if(!s.pack||!s.sku)return t;const e=m(s.pack),i=n.variants.find(r=>r.sku===s.sku);return i?{ok:!0,line:h(n,i,e,s.qty)}:t}export{D as restoreCartLines};
|