@dropins/storefront-order-confirmation
Advanced tools
Comparing version 0.1.0-alpha24 to 0.1.0-alpha26
import{F as t,M as o,O as i,e as d,f as c,g as h,c as n,d as p,r as g,s as m,a as f,b as F}from"./chunks/customerOrder.js";import{c as u,i as O}from"./chunks/initialize.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";export{t as FetchError,o as MissingArgument,i as OrderNotFound,u as config,d as customerOrder,c as fetchGraphQl,h as getConfig,n as guestOrder,p as guestOrderByToken,O as initialize,g as removeFetchGraphQlHeader,m as setEndpoint,f as setFetchGraphQlHeader,F as setFetchGraphQlHeaders}; | ||
//# sourceMappingURL=api.js.map |
@@ -123,2 +123,1 @@ import{FetchGraphQL as m}from"@dropins/tools/fetch-graphql.js";class o extends Error{constructor(e){super(e.map(r=>r.message).join(" ")),this.name="FetchError"}}class y extends Error{constructor(e){super(`Missing argument: ${e}`)}}class a extends Error{constructor(){super("Order not found")}}const{setEndpoint:_,setFetchGraphQlHeader:O,removeFetchGraphQlHeader:f,setFetchGraphQlHeaders:b,fetchGraphQl:c,getConfig:w}=new m().getMethods(),i=` | ||
`,k=async t=>{var n,u,d;const{data:e,errors:r}=await c(p,{variables:{number:t}});if(r)throw new o(r);const s=(d=(u=(n=e==null?void 0:e.customer)==null?void 0:n.orders)==null?void 0:u.items)==null?void 0:d[0];if(!s)throw new a;return s};export{o as F,y as M,a as O,O as a,b,$ as c,v as d,k as e,c as f,w as g,f as r,_ as s}; | ||
//# sourceMappingURL=customerOrder.js.map |
import{Initializer as t}from"@dropins/tools/lib.js";const i=new t({init:async n=>{const o={...n};i.config.setConfig(o)},listeners:()=>[]}),s=i.config;export{s as c,i}; | ||
//# sourceMappingURL=initialize.js.map |
import{c as K,e as Q,d as J}from"../chunks/customerOrder.js";import{useState as X,useEffect as Y}from"@dropins/tools/preact-hooks.js";import{classes as v,getFormValues as rr}from"@dropins/tools/lib.js";import{jsx as r,jsxs as d,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{Icon as $,Button as B,Skeleton as w,SkeletonRow as u,Card as T,InLineAlert as er,Field as V,Input as W,Price as O,Divider as b,CartItem as nr,Image as tr,CartItemSkeleton as x}from"@dropins/tools/components.js";import*as _ from"@dropins/tools/preact-compat.js";import{useReducer as ar,useState as or,useCallback as A,useEffect as Z}from"@dropins/tools/preact-compat.js";import{Text as l,useText as P}from"@dropins/tools/i18n.js";import{events as ir}from"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const cr=()=>{const e=()=>window.innerWidth>=1920?"xxlarge":window.innerWidth>=1366?"xlarge":window.innerWidth>=1024?"large":window.innerWidth>=768?"medium":"small",[n,a]=X(e());return Y(()=>{let i;const o=()=>{i&&clearTimeout(i),i=setTimeout(()=>a(e()),50)};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i&&clearTimeout(i)}},[]),n};var k=(e=>(e.ADD_ORDER_REFERENCE="ADD_ORDER_REFERENCE",e.LOADING="LOADING",e.SET_DETAILS="SET_DETAILS",e.ALERT="ALERT",e.DISMISS_ALERT="DISMISS_ALERT",e))(k||{}),G=(e=>(e.ERROR="error",e.WARNING="warning",e.SUCCESS="success",e))(G||{}),R=(e=>(e.INVALID_ORDER="invalid_order",e.INVALID_SEARCH="invalid_search",e.UNKNOWN="unknown_error",e))(R||{});function dr(e,n){switch(n.type){case"LOADING":return{...e,isLoading:!0};case"SET_DETAILS":return{...e,isLoading:!1,details:n.details,alert:n.alert,isOrderFromSearchForm:n.fromSearchForm||!1};case"ALERT":return{...e,isLoading:!1,alert:n.alert};case"DISMISS_ALERT":return{...e,alert:void 0};default:return e}}const U=({children:e,className:n})=>cr()!=="small"?r("div",{className:n,children:e}):r(S,{children:e});function mr(e){const n=e==null?void 0:e.total,a=e==null?void 0:e.is_virtual;if(!n)return;const i=n==null?void 0:n.grand_total,o=n==null?void 0:n.subtotal,t=n==null?void 0:n.total_shipping,m=n==null?void 0:n.total_tax;return{total:{inclTax:{amount:(i==null?void 0:i.value)||0,currency:(i==null?void 0:i.currency)||""}},subtotal:{amount:(o==null?void 0:o.value)||0,currency:(o==null?void 0:o.currency)||"",isTaxIncl:!1},shipping:{amount:(t==null?void 0:t.value)||0,currency:(t==null?void 0:t.currency)||"",isVirtual:a},tax:{amount:(m==null?void 0:m.value)||0,currency:(m==null?void 0:m.currency)||""}}}const lr=({state:e})=>{const{isLoading:n,details:a}=e,i=mr(a);return d(S,{children:[r(Er,{isLoading:n,summary:i}),r(xr,{isLoading:n,details:a})]})},sr=({state:e})=>r(U,{className:"order-confirmation__aside",children:r(lr,{state:e})}),ur=({state:e,routeHome:n,routeSupport:a,onSignUpClick:i})=>{const{details:o,isLoading:t}=e,m=o==null?void 0:o.billing_address,c=(m==null?void 0:m.firstname)||"",f=(o==null?void 0:o.number)||"",C=(o==null?void 0:o.status)||"";return d(S,{children:[(t||!t&&(!!c&&!!f))&&r(yr,{isLoading:t,customerName:c,orderNumber:f,orderStatus:C,onSignUpClick:i}),r(Or,{isLoading:t,orderDetails:o}),r(Nr,{isLoading:t,routeHome:n,routeSupport:a})]})},fr=({state:e,routeHome:n,routeSupport:a,dismissAlert:i,onOrderSearch:o,onSignUpClick:t})=>r(U,{className:"order-confirmation__main",children:r(ur,{state:e,routeHome:n,routeSupport:a,dismissAlert:i,onOrderSearch:o,onSignUpClick:t})}),hr=({className:e,state:n,dismissAlert:a,routeHome:i,routeSupport:o,onOrderSearch:t,onSignUpClick:m})=>{const{details:c,alert:f,isLoading:C}=n,y=!!(c!=null&&c.number),s=f&&f.code===R.INVALID_ORDER,h=f&&f.code===R.INVALID_SEARCH;return!C&&!y?r("div",{className:v(["order-confirmation",e]),children:r(gr,{alert:s||h?{heading:f.message,description:"",type:f.type,onDismiss:a}:void 0,onOrderSearch:t})}):d("div",{className:v(["order-confirmation",e]),children:[r(fr,{state:n,dismissAlert:a,routeHome:i,routeSupport:o,onOrderSearch:t,onSignUpClick:m}),r(sr,{state:n})]})},pr=e=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},_.createElement("g",{clipPath:"url(#clip0_4797_15077)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.63001L10.15 3.20001L18.8 6.63001L10.15 10L1.5 6.63001Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),_.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M15.71 17.26C15.71 15.38 17.23 13.86 19.11 13.86C20.99 13.86 22.51 15.38 22.51 17.26C22.51 19.14 20.99 20.66 19.11 20.66C17.23 20.66 15.71 19.14 15.71 17.26Z",stroke:"currentColor"}),_.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M17.4805 17.49L18.5605 18.41L20.7205 16.33",stroke:"currentColor",strokeLinecap:"square",strokeLinejoin:"round"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_4797_15077"},_.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"})))),_r=e=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},_.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),yr=({isLoading:e,customerName:n,orderNumber:a,orderStatus:i,onSignUpClick:o})=>e?r(vr,{}):d("div",{className:"order-confirmation-header order-confirmation__card",children:[r($,{source:pr,size:"64",className:"order-confirmation-header__icon"}),r("h1",{className:"order-confirmation-header__title",children:n?r(l,{id:"OrderConfirmation.Header.title",fields:{name:n}}):r(l,{id:"OrderConfirmation.Header.defaultTitle"})}),a&&d("p",{className:"order-confirmation-header__order",children:[r(l,{id:"OrderConfirmation.Header.order",fields:{order:a}}),i!==void 0&&i!==""&&d("span",{className:"order-confirmation-header__status",children:[" ","(",i,")"]})]}),o&&d("div",{className:"order-confirmation-create-account",children:[r("p",{className:"order-confirmation-create-account__message",children:r(l,{id:"OrderConfirmation.Header.CreateAccount.message"})}),r(B,{"data-testid":"create-account-button",className:"order-confirmation-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:o,children:r(l,{id:"OrderConfirmation.Header.CreateAccount.button"})})]})]}),vr=()=>d(w,{"data-testid":"order-confirmation-header-skeleton",className:"order-confirmation-header",children:[r(u,{variant:"empty",size:"xlarge",fullWidth:!0}),r(u,{variant:"empty",size:"medium"}),r(u,{variant:"empty",size:"medium"}),r(u,{variant:"empty",size:"medium"}),r(u,{variant:"empty",size:"medium"}),r(u,{variant:"empty",size:"medium"}),r(u,{size:"small",fullWidth:!0}),r(u,{variant:"heading",size:"xsmall",fullWidth:!0})]}),gr=({alert:e,onOrderSearch:n})=>{const a=P({email:"OrderConfirmation.OrderSearchForm.email",postcode:"OrderConfirmation.OrderSearchForm.postcode",number:"OrderConfirmation.OrderSearchForm.orderNumber"}),i=o=>{o.preventDefault();const t=rr(o.target);n==null||n(t)};return d(T,{variant:"secondary",className:"order-confirmation-order-search-form order-confirmation__card",children:[r("h2",{className:"order-confirmation-order-search-form__title",children:r(l,{id:"OrderConfirmation.OrderSearchForm.title"})}),r("p",{children:r(l,{id:"OrderConfirmation.OrderSearchForm.description"})}),e&&r(er,{className:"order-confirmation-order-search-form__alert","data-testid":"order-confirmation-alert",icon:r($,{source:_r}),...e}),d("form",{className:"order-confirmation-order-search-form__fields",onSubmit:i,children:[d("div",{className:"order-confirmation-order-search-form__fields-columns",children:[r(V,{children:r(W,{id:"order-email",name:"email",type:"email",autocomplete:"email",placeholder:a.email,floatingLabel:a.email,required:!0,"aria-label":a.email,"aria-required":!0})}),r(V,{children:r(W,{id:"postcode",name:"postcode",type:"text",autocomplete:"postal-code",placeholder:a.postcode,floatingLabel:a.postcode,required:!1,"aria-label":a.postcode,"aria-required":!0})})]}),r(V,{children:r(W,{id:"order-number",name:"number",type:"text",placeholder:a.number,floatingLabel:a.number,required:!0,"aria-label":a.number,"aria-required":!0})}),r(B,{className:"order-confirmation-order-search-form__button",size:"medium",variant:"primary",type:"submit",children:r(l,{id:"OrderConfirmation.OrderSearchForm.button"})},"logIn")]})]})},Or=({isLoading:e,orderDetails:n})=>{var I,z,H,j,D;if(e)return r(Cr,{});const a=n&&(n==null?void 0:n.number),i=(n==null?void 0:n.email)||"",o=n&&i!=="",t=n==null?void 0:n.shipping_address,m=n&&t!==null,c=n==null?void 0:n.billing_address,f=n&&c!==null,C=n==null?void 0:n.shipping_method,y=(z=(I=n==null?void 0:n.total)==null?void 0:I.total_shipping)==null?void 0:z.value,s=(j=(H=n==null?void 0:n.total)==null?void 0:H.total_shipping)==null?void 0:j.currency,h=n&&C&&s&&y!=null,p=n==null?void 0:n.payment_methods,g=p&&p.length>0,E=g?(D=p[0])==null?void 0:D.name:"",L=n&&g&&E!=="";return d(T,{"data-testid":"order-confirmation-details",variant:"secondary",className:"order-confirmation-details order-confirmation__card",children:[r("div",{className:"order-confirmation-details__header",children:r("h2",{className:"order-confirmation-details__title",children:r(l,{id:"OrderConfirmation.Details.title"})})}),d("div",{className:"order-confirmation-details__contact",children:[(!n||o)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.contact"})}),o&&r("p",{children:i}),!a&&r(N,{rows:1,"data-testid":"order-confirmation-details-contact-skeleton"})]}),d("div",{className:"order-confirmation-details__information",children:[d("div",{className:"order-confirmation-details__shipping_address",children:[(!a||m)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.shippingAddress"})}),m&&d(S,{children:[d("p",{children:[t==null?void 0:t.firstname," ",t==null?void 0:t.lastname]}),t==null?void 0:t.street.map((F,M)=>r("p",{children:F},M)),d("p",{children:[t==null?void 0:t.city," ",t==null?void 0:t.region," ",t==null?void 0:t.postcode,", ",t==null?void 0:t.country_code]})]}),!a&&r(N,{rows:3,"data-testid":"order-confirmation-shipping-address-skeleton"})]}),d("div",{className:"order-confirmation-details__billing_address",children:[(!a||f)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.billingAddress"})}),f&&d(S,{children:[d("p",{children:[c==null?void 0:c.firstname," ",c==null?void 0:c.lastname]}),c==null?void 0:c.street.map((F,M)=>r("p",{children:F},M)),d("p",{children:[c==null?void 0:c.city," ",c==null?void 0:c.region," ",c==null?void 0:c.postcode,", ",c==null?void 0:c.country_code]})]}),!a&&r(N,{rows:3,"data-testid":"order-confirmation-billing-address-skeleton"})]}),d("div",{className:"order-confirmation-details__shipping-method",children:[(!a||h)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.shippingMethod"})}),h&&r(S,{children:y===0?r("p",{className:"order-confirmation-order-summary__price",children:r(l,{id:"OrderConfirmation.Details.freeShipping"})}):d("p",{children:[r(O,{amount:y,currency:s})," ",C]})}),!a&&r(N,{rows:1,"data-testid":"order-confirmation-details-shipping-method-skeleton"})]}),d("div",{className:"order-confirmation-details__payment-method",children:[(!a||L)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.paymentMethod"})}),L&&r("p",{children:E}),!a&&r(N,{rows:1,"data-testid":"order-confirmation-details-payment-method-skeleton"})]})]})]})},Cr=()=>r(T,{variant:"secondary",className:"order-confirmation-details",children:d(w,{"data-testid":"order-confirmation-details-skeleton",children:[r(u,{variant:"heading",size:"medium",fullWidth:!0}),r(u,{size:"medium"}),r(u,{variant:"empty",size:"medium"}),r(u,{size:"xlarge"}),r(u,{size:"xlarge"}),r(u,{size:"xlarge"}),r(u,{size:"xlarge"})]})}),Nr=({isLoading:e,className:n,routeHome:a,routeSupport:i,...o})=>e?r(Sr,{}):d("div",{className:v(["order-confirmation-footer",n]),...o,children:[(a==null?void 0:a())&&r(B,{"data-testid":"order-confirmation-footer__continue-button",className:"order-confirmation-footer__continue-button",size:"medium",variant:"primary",type:"submit",href:a==null?void 0:a(),children:r(l,{id:"OrderConfirmation.Footer.continueShopping"})},"continueShopping"),d("p",{className:"order-confirmation-footer__contact-support",children:[r(l,{id:"OrderConfirmation.Footer.help"})," ",(i==null?void 0:i())&&r("a",{href:i==null?void 0:i(),rel:"noreferrer",className:"order-confirmation-footer__contact-support-link","data-testid":"order-confirmation-footer__contact-support-link",children:r(l,{id:"OrderConfirmation.Footer.contactSupport"})})]})]}),Sr=()=>d(w,{className:"order-confirmation-footer",children:[r(u,{size:"small",fullWidth:!0}),r(u,{variant:"heading",size:"xsmall",fullWidth:!0})]}),N=({rows:e,size:n="xsmall",...a})=>r(w,{className:"static-skeleton",...a,children:Array.from(Array(e).keys()).map(i=>r(u,{variant:"heading",size:n,fullWidth:!0},i))}),Er=({className:e,isLoading:n,summary:a,variant:i="secondary"})=>{if(n)return r(kr,{});const{total:o,subtotal:t,shipping:m,tax:c}=a??{};return d(T,{className:v(["order-confirmation-order-summary",e]),variant:i,children:[r("h2",{className:"order-confirmation-order-summary__title",children:r(l,{id:"OrderConfirmation.OrderSummary.title"})}),r(b,{variant:"primary"}),t!=null?d("div",{"data-testid":"order-summary-subtotal",className:"order-confirmation-order-summary__row",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.subtotal"})}),r(O,{amount:t==null?void 0:t.amount,currency:t==null?void 0:t.currency,className:v(["order-confirmation-order-summary__price",e])})]}):r(N,{rows:1,"data-testid":"order-confirmation-order-summary-subtotal-skeleton"}),(t==null?void 0:t.isTaxIncl)&&r("div",{"data-testid":"order-summary-subtotal-incl-tax",className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--muted",children:r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.includingTaxes"})})}),m!=null?m.isVirtual?null:d("div",{"data-testid":"order-summary-shipping",className:"order-confirmation-order-summary__row",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.shipping"})}),m.amount===0?r("p",{className:"order-confirmation-order-summary__price",children:r(l,{id:"OrderConfirmation.OrderSummary.freeShipping"})}):r(O,{amount:m.amount,currency:m.currency,className:v(["order-confirmation-order-summary__price",e])})]}):r(N,{rows:1,"data-testid":"order-confirmation-order-summary-shipping-skeleton"}),c!=null&&!c.breakdown&&d("div",{"data-testid":"order-summary-tax",className:"order-confirmation-order-summary__row",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.tax"})}),r(O,{amount:c.amount,currency:c.currency,className:v(["order-confirmation-order-summary__price",e])})]}),c!=null&&c.breakdown&&d(S,{children:[r(b,{variant:"secondary"}),r("div",{className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--margin-bottom",children:r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.taxBreakdown"})})}),c.breakdown.map(f=>d("div",{"data-testid":"order-summary-tax-breakdown",className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--muted",children:[r("p",{children:f.label}),r(O,{amount:f.amount.value,currency:f.amount.currency,className:v(["order-confirmation-order-summary__price",e])})]},f.label)),d("div",{"data-testid":"order-summary-tax-breakdown-total",className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--strong order-confirmation-order-summary__row--margin-top",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.taxTotal"})}),r(O,{amount:c.amount,currency:c.currency,className:v(["order-confirmation-order-summary__price",e])})]}),r(b,{variant:"secondary"})]}),o!=null?d("div",{"data-testid":"order-summary-total-incl-tax",className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--emphasized",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.total"})}),r(O,{amount:o==null?void 0:o.inclTax.amount,currency:o==null?void 0:o.inclTax.currency,className:v(["order-confirmation-order-summary__price",e])})]}):r(N,{rows:1,"data-testid":"order-confirmation-order-summary-total-skeleton"}),(o==null?void 0:o.exclTax)!=null&&d("div",{"data-testid":"order-summary-total-excl-tax",className:"order-confirmation-order-summary__row order-confirmation-order-summary__row--muted",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.totalExclTax"})}),r(O,{amount:o.exclTax.amount,currency:o.exclTax.currency,className:v(["order-confirmation-order-summary__price",e])})]})]})},kr=()=>d(w,{"data-testid":"order-confirmation-order-summary-skeleton",className:"order-confirmation-order-summary",children:[r(u,{variant:"heading",size:"small"}),r(u,{variant:"empty",size:"small"}),r(u,{variant:"empty",size:"small"}),r(u,{variant:"empty",size:"small"}),r(u,{variant:"heading",size:"small",fullWidth:!0,lines:3})]}),wr=({className:e,item:n,taxIncluded:a=!1})=>{const i=P({Sender:"OrderConfirmation.CartSummary.GiftCard.sender",Recipient:"OrderConfirmation.CartSummary.GiftCard.recipient"});let o=n.regularPrice,t=n.total;a&&(o=n.priceInclTax,t=n.totalInclTax);const m={..."configurableOptions"in n?n.configurableOptions:{},..."senderName"in n&&n.senderName?{[i.Sender]:n.senderName}:{},..."senderEmail"in n&&n.senderEmail?{[i.Sender]:n.senderEmail}:{},..."recipientName"in n&&n.recipientName?{[i.Recipient]:n.recipientName}:{},..."recipientEmail"in n&&n.recipientEmail?{[i.Recipient]:n.recipientEmail}:{}};return r("div",{className:v(["order-confirmation-cart-summary-item",e]),children:r(nr,{"data-testid":"cart-summary-item",taxIncluded:a,title:r("div",{"data-testid":"product-name",children:n.name}),sku:r("div",{children:n.sku}),quantity:n.quantity,image:r(tr,{src:n.image.src,alt:n.image.alt,loading:"lazy",width:"80",height:"80",params:{width:80}}),configurations:m,price:r(O,{amount:n.regularPrice.value,currency:o.currency,weight:"normal"}),total:d(S,{children:[r(O,{amount:n.regularPrice.value*n.quantity,currency:o.currency,variant:n.discounted?"strikethrough":"default"}),n.discounted&&r(O,{amount:t.value,currency:t.currency,sale:!0})]})},n.uid)})};function Lr(e){return{uid:e.id,quantity:e.quantity_ordered,sku:e.product.sku,name:e.product.name,image:{src:e.product.thumbnail.url,alt:e.product.thumbnail.label},price:{value:e.product_sale_price.value,currency:e.product_sale_price.currency},priceInclTax:{value:e.product_sale_price.value,currency:e.product_sale_price.currency},total:{value:e.product_sale_price.value*e.quantity_ordered,currency:e.product_sale_price.currency},totalInclTax:{value:e.product_sale_price.value*e.quantity_ordered,currency:e.product_sale_price.currency},discount:{value:0,currency:e.product_sale_price.currency},regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency},discounted:e.product.price_range.maximum_price.regular_price.value*e.quantity_ordered!==e.product_sale_price.value*e.quantity_ordered,configurableOptions:Ir(e),senderName:e.__typename==="GiftCardOrderItem"?e.gift_card.sender_name:void 0,senderEmail:e.__typename==="GiftCardOrderItem"?e.gift_card.sender_email:void 0,recipientEmail:e.__typename==="GiftCardOrderItem"?e.gift_card.recipient_email:void 0,recipientName:e.__typename==="GiftCardOrderItem"?e.gift_card.recipient_name:void 0}}function Ir(e){if(!("selected_options"in e))return;const n={};for(const a of e.selected_options)n[a.label]=a.value;return n}const xr=({isLoading:e,details:n})=>{if(e)return r(Rr,{});const a=!1,i=n.items,o=i.length;return r("div",{className:"order-confirmation-cart-summary",children:d(T,{variant:"secondary",children:[r("div",{className:"order-confirmation-cart-summary__heading",children:d("h2",{className:"order-confirmation-cart-summary__title",children:[r(l,{id:"OrderConfirmation.CartSummary.title"})," (",o,")"]})}),r(b,{className:"order-confirmation-cart-summary__divider-top",variant:"primary"}),r("div",{className:"order-confirmation-cart-summary__items",children:i==null?void 0:i.map(t=>{const m=Lr(t);return r(wr,{item:m,taxIncluded:a},m==null?void 0:m.uid)})})]})})},Rr=()=>d(w,{"data-testid":"cart-summary-skeleton",className:"order-confirmation-cart-summary",style:{gridTemplateColumns:"1fr"},children:[r(u,{variant:"heading",fullWidth:!0,size:"medium"}),r(x,{}),r(x,{}),r(x,{}),r(x,{}),r(x,{})]});function q(e){return{region:{region_id:e!=null&&e.region_id?Number(e==null?void 0:e.region_id):null,region:e==null?void 0:e.region},city:e==null?void 0:e.city,company:e==null?void 0:e.company,country_code:e==null?void 0:e.country_code,firstname:e==null?void 0:e.firstname,lastname:e==null?void 0:e.lastname,middlename:e==null?void 0:e.middlename,postcode:e==null?void 0:e.postcode,street:e==null?void 0:e.street,telephone:e==null?void 0:e.telephone}}function Tr(e){const[n,a]=ar(dr,{isLoading:!1,orderRef:e,details:null,isOrderFromSearchForm:!1}),[i,o]=or(),t=P({invalidOrder:"OrderConfirmation.Errors.invalidOrder",invalidSearch:"OrderConfirmation.Errors.invalidSearch",pageNotFound:"OrderConfirmation.Errors.pageNotFound",unknown:"OrderConfirmation.Errors.unknown"}),m=A(s=>{switch(s){case"Invalid order":case"Order not found":case"We couldn't locate an order with the information provided.":return{type:G.WARNING,code:R.INVALID_ORDER,message:t.invalidOrder};case"Invalid search":return{type:G.WARNING,code:R.INVALID_SEARCH,message:t.invalidSearch}}},[t.invalidOrder,t.invalidSearch]),c=()=>{a({type:k.DISMISS_ALERT})},f=function(s){C(s)};Z(()=>{const s=ir.on("authenticated",h=>{o(h)},{eager:!0});return()=>{s==null||s.off()}},[]);const C=A(s=>{K(s).then(h=>{const g=!!(h!=null&&h.number)?void 0:m("Invalid search");a({type:k.SET_DETAILS,fromSearchForm:!0,alert:g,details:h})}).catch(()=>{const h=m("Invalid search");a({type:k.SET_DETAILS,details:null,alert:h})})},[m]),y=A(s=>{(i?Q:J)(s).then(p=>{const E=!!(p!=null&&p.number)?void 0:m("Invalid order");a({type:k.SET_DETAILS,details:p,alert:E})}).catch(p=>{const g=m(p.message);if(!g){console.error(p);return}a({type:k.ALERT,alert:g})})},[i,m]);return Z(()=>{!n.orderRef||i===void 0||(a({type:k.LOADING}),y(n.orderRef))},[i,y,n.orderRef]),{state:n,authenticated:i,handleOrderSearch:f,dismissAlert:c}}const Br=({orderRef:e,routeHome:n,routeSupport:a,onSignUpClick:i})=>{const{state:o,authenticated:t,handleOrderSearch:m,dismissAlert:c}=Tr(e);if(t===void 0)return null;const C=i&&!t&&!o.isOrderFromSearchForm?()=>{var g,E,L;const y=(g=o.details)==null?void 0:g.shipping_address,s=(E=o.details)==null?void 0:E.billing_address,h=[{code:"firstname",defaultValue:(s==null?void 0:s.firstname)||""},{code:"lastname",defaultValue:(s==null?void 0:s.lastname)||""},{code:"email",defaultValue:((L=o.details)==null?void 0:L.email)||""}];let p;if(y){const I={...q(y),default_shipping:!0};p=[{...q(s),default_billing:!0},I]}else p=[{...q(s),default_billing:!0,default_shipping:!0}];i({inputsDefaultValueSet:h,addressesData:p})}:void 0;return r(hr,{state:o,dismissAlert:c,onOrderSearch:m,routeHome:n,routeSupport:a,onSignUpClick:C})};export{Br as OrderConfirmation,Br as default}; | ||
//# sourceMappingURL=OrderConfirmation.js.map |
@@ -1,1 +0,1 @@ | ||
{"name": "@dropins/storefront-order-confirmation", "version": "0.1.0-alpha24", "dependencies": { "@dropins/tools": "0.24.1" } } | ||
{"name": "@dropins/storefront-order-confirmation", "version": "0.1.0-alpha26", "@dropins/elsie": "~0.26.0"} |
(function(e,a){try{if(typeof document<"u"){const r=document.createElement("style"),n=a.styleId;for(const o in a.attributes)r.setAttribute(o,a.attributes[o]);r.setAttribute("data-dropin",n),r.appendChild(document.createTextNode(e));const t=document.querySelector('style[data-dropin="sdk"]');if(t)t.after(r);else{const o=document.querySelector('link[rel="stylesheet"], style');o?o.before(r):document.head.append(r)}}}catch(r){console.error("dropin-styles (injectCodeFunction)",r)}})('.order-confirmation{display:grid;align-items:start;grid-template-columns:repeat(var(--grid-4-columns),1fr);grid-template-areas:"main aside";grid-column-gap:var(--grid-4-gutters);margin-bottom:var(--spacing-xbig)}.order-confirmation__main{display:grid;grid-row-gap:var(--spacing-xbig);grid-area:main;grid-column:1 / span 7}.order-confirmation__aside{display:grid;grid-row-gap:var(--spacing-xbig);grid-area:aside;grid-column:9 / span 4}.order-confirmation a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}.order-confirmation-header,.order-confirmation-footer,.order-confirmation-message,.order-confirmation-order-search-form,.order-confirmation-order-form,.order-confirmation-status,.order-confirmation-details{grid-column:1 / span 7}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation{grid-template-columns:repeat(var(--grid-1-columns),1fr);grid-column-gap:var(--grid-1-gutters);grid-template-areas:"header" "details" "orderSummary" "cartSummary" "footer"}.order-confirmation>div{grid-column:1 / span 4}.order-confirmation-details{margin-bottom:var(--spacing-xbig)}.order-confirmation-order-summary{margin-bottom:var(--spacing-xbig);grid-area:orderSummary}.order-confirmation-cart-summary{margin-bottom:var(--spacing-xbig);grid-area:cartSummary}}.order-confirmation-header{text-align:center;padding:var(--spacing-xxbig)}.order-confirmation-header__icon{margin-bottom:var(--spacing-small)}.order-confirmation-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);margin:0}.order-confirmation-header__title:first-letter{text-transform:uppercase}.order-confirmation-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-confirmation-header .success-icon{color:var(--color-positive-500)}.order-confirmation-create-account{gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-confirmation-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-confirmation-create-account__button{margin:0 auto;text-align:center;display:inline-block}.order-confirmation-order-search-form .dropin-card__content{gap:var(--spacing-small)}.order-confirmation-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-confirmation-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-confirmation-order-search-form form{display:grid;grid-template-rows:1fr}.order-confirmation-order-search-form__fields-columns{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium);margin-bottom:var(--spacing-medium)}.order-confirmation-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}.order-confirmation-message p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-confirmation-message__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-confirmation-details__header{display:grid;grid-auto-rows:max-content}.order-confirmation-details__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-confirmation-details h3{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.order-confirmation-details p{margin:var(--spacing-xsmall) 0 0 0;color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}a.order-confirmation__login-link{font:var(--type-body-2-strong-font);margin-left:var(--spacing-xxsmall)}.order-confirmation-details__shipping-method span{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.order-confirmation-details__information{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.order-confirmation-details__information>div:empty{visibility:hidden;display:none}.order-confirmation-details .static-skeleton{gap:var(--spacing-xsmall)}@media only screen and (min-width:320px) and (max-width: 768px){.order-confirmation-details__information{grid-template-columns:1fr}}.order-confirmation-footer{gap:var(--spacing-small);text-align:center}.order-confirmation-footer .order-confirmation-footer__continue-button{margin:0 auto;text-align:center;display:inline-block}.order-confirmation-footer__contact-support{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.order-confirmation-footer__contact-support a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);color:var(--color-brand-500);cursor:pointer}.static-skeleton .dropin-skeleton--row__content{animation:0;background:var(--color-neutral-300);border-radius:var(--shape-border-radius-1)}.order-confirmation-order-summary .dropin-card__content{gap:var(--spacing-xsmall)}.order-confirmation-order-summary__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0}.order-confirmation-order-summary .dropin-divider--primary{margin:0 0 var(--spacing-medium) 0!important}.order-confirmation-order-summary .dropin-divider--secondary{margin:var(--spacing-xsmall) 0 var(--spacing-xsmall) 0!important}.order-confirmation-order-summary__breakdown{margin:var(--spacing-big) 0 var(--spacing-medium) 0}.order-confirmation-order-summary__breakdown .dropin-divider:last-child{margin-bottom:0}.order-confirmation-order-summary__row{display:flex;justify-content:space-between;color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-confirmation-order-summary__row--margin-top{margin-top:var(--spacing-xsmall)}.order-confirmation-order-summary__row--margin-bottom{margin-bottom:var(--spacing-xsmall)}.order-confirmation-order-summary__row .order-confirmation-order-summary__price{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-confirmation-order-summary__row p{margin:0}.order-confirmation-order-summary__row--strong{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.order-confirmation-order-summary__row--strong .order-confirmation-order-summary__price{color:var(--color-neutral-800);font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.order-confirmation-order-summary__row--emphasized{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing);margin-top:var(--spacing-small)}.order-confirmation-order-summary__row--emphasized .order-confirmation-order-summary__price{color:var(--color-neutral-800);font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.order-confirmation-order-summary__row--muted{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:calc(-1 * var(--spacing-xxsmall))}.order-confirmation-order-summary__row--muted .order-confirmation-order-summary__price{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-confirmation-order-summary .dropin-skeleton:last-child{margin-top:var(--spacing-big)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-order-summary{border-top:var(--shape-border-width-2) solid var(--color-neutral-400);border-bottom:var(--shape-border-width-2) solid var(--color-neutral-400)}.order-confirmation-skeleton .order-confirmation-order-summary{border:0 none}}.order-confirmation-cart-summary .dropin-card__content{gap:var(--spacing-xsmall)}.order-confirmation-cart-summary__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content}.order-confirmation-cart-summary__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0}.order-confirmation-cart-summary__edit{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);align-self:flex-end;justify-self:flex-end;margin:0;cursor:pointer}.order-confirmation-cart-summary__edit a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.order-confirmation-cart-summary .order-confirmation-cart-summary__divider-top{margin:0 0 var(--spacing-medium) 0}.order-confirmation-cart-summary .order-confirmation-cart-summary__divider-bottom{margin:var(--spacing-medium) 0 var(--spacing-small) 0}.order-confirmation-cart-summary__items{display:grid;gap:var(--spacing-medium)}.order-confirmation-cart-summary__action{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);color:var(--color-brand-500);background:none;margin:0 auto;border:0;text-align:center;white-space:nowrap;text-decoration:none;cursor:pointer;width:auto}.order-confirmation-cart-summary__action:hover{text-decoration:underline;text-underline-offset:var(--spacing-xxsmall);background-color:transparent;color:var(--color-brand-700)}.dropin-accordion{background-color:var(--color-neutral-200)}.dropin-accordion .dropin-divider:first-child{margin-top:0}.dropin-accordion .dropin-divider:last-child{margin-bottom:0}.dropin-accordion-section{padding:0 var(--spacing-medium)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-cart-summary .dropin-accordion-section__content-container{gap:0}.order-confirmation-cart-summary-item{margin-bottom:var(--spacing-medium)}.dropin-accordion-section__content-container .order-confirmation-cart-summary-item:last-of-type{margin-bottom:0}}.order-confirmation-cart-summary-item .dropin-cart-item__title{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-confirmation-cart-summary-item .dropin-cart-item__price{margin:var(--spacing-xxsmall) 0}.order-confirmation-cart-summary-item .dropin-price--sale{color:#bf4545}.dropin-cart-item__total{align-items:flex-end}',{styleId:"order-confirmation"}); | ||
import{deepmerge as l,Render as p}from"@dropins/tools/lib.js";import{useState as u,useEffect as c}from"@dropins/tools/preact-hooks.js";import{UIProvider as m}from"@dropins/tools/components.js";import{events as f}from"@dropins/tools/event-bus.js";import{c as g}from"./chunks/initialize.js";import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";const h={Header:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}},OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",postcode:"Zip Code",orderNumber:"Order Number"},OrderSummary:{title:"Order summary",total:"Total",totalExclTax:"Total excluding taxes",subtotal:"Subtotal",tax:"Tax",taxTotal:"Tax total",taxBreakdown:"Taxes",includingTaxes:"Including taxes",shipping:"Shipping",freeShipping:"Free shipping"},Message:{title:"Your order is confirmed",description:"We have successfully processed your order and will be soon prepared for shipping. <br /> You will also receive an email with details and we will let you know when your order has shipped."},Details:{title:"Order details",contact:"Contact details",shippingAddress:"Shipping address",billingAddress:"Billing address",shippingMethod:"Shipping method",freeShipping:"Free shipping",paymentMethod:"Payment method"},Footer:{continueShopping:"Continue shopping",help:"Need help?",contactSupport:"Contact us"},CartSummary:{title:"Your order",GiftCard:{sender:"Sender",recipient:"Recipient"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details.",unknown:"Something went wrong. Please try again."}},y={OrderConfirmation:h},S={default:y},w=({children:n})=>{var o;const[e,a]=u(),d=(o=g.getConfig())==null?void 0:o.langDefinitions;c(()=>{const r=f.on("locale",t=>{t!==e&&a(t)},{eager:!0});return()=>{r==null||r.off()}},[e]);const s=l(S,d??{});return i(m,{lang:e,langDefinitions:s,children:n})},k=new p(i(w,{}));export{k as render}; | ||
//# sourceMappingURL=render.js.map |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
1051932
74
20534
1
- Removed@dropins/tools@0.24.1
- Removed@dropins/tools@0.24.1(transitive)