@dropins/storefront-order-confirmation
Advanced tools
Comparing version 0.1.0-alpha26 to 0.1.0-alpha27
@@ -49,2 +49,10 @@ export declare const customerOrder: (number: string) => Promise<{ | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -64,2 +72,10 @@ shipping_address?: { | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -66,0 +82,0 @@ items?: ({ |
@@ -1,3 +0,3 @@ | ||
export declare const GUEST_ORDER_FRAGMENT = "\n fragment guestOrderData on CustomerOrder {\n number\n status\n email\n shipping_method\n is_virtual\n payment_methods {\n name\n type\n }\n total {\n subtotal {\n currency\n value\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n grand_total {\n currency\n value\n }\n }\n billing_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n }\n shipping_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n }\n items {\n __typename\n id\n quantity_ordered\n product_sale_price {\n value\n currency\n }\n product {\n name\n sku\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n selected_options {\n label\n value\n }\n\n ... on GiftCardOrderItem {\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n }\n }\n"; | ||
export declare const GUEST_ORDER_FRAGMENT = "\n fragment guestOrderData on CustomerOrder {\n number\n status\n email\n shipping_method\n is_virtual\n payment_methods {\n name\n type\n }\n total {\n subtotal {\n currency\n value\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n grand_total {\n currency\n value\n }\n }\n billing_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n custom_attributesV2 {\n code\n ... on AttributeValue {\n value\n }\n }\n }\n shipping_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n custom_attributesV2 {\n code\n ... on AttributeValue {\n value\n }\n }\n }\n items {\n __typename\n id\n quantity_ordered\n product_sale_price {\n value\n currency\n }\n product {\n name\n sku\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n selected_options {\n label\n value\n }\n\n ... on GiftCardOrderItem {\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n }\n }\n"; | ||
export declare const guestOrderQuery: string; | ||
//# sourceMappingURL=guestOrder.graphql.d.ts.map |
@@ -54,2 +54,10 @@ export type GuestOrderInput = { | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -69,2 +77,10 @@ shipping_address?: { | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -71,0 +87,0 @@ items?: ({ |
@@ -49,2 +49,10 @@ export declare const guestOrderByToken: (token: string) => Promise<{ | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -64,2 +72,10 @@ shipping_address?: { | ||
company?: string | null | undefined; | ||
custom_attributesV2: ({ | ||
__typename?: "AttributeSelectedOptions" | undefined; | ||
code: string; | ||
} | { | ||
__typename?: "AttributeValue" | undefined; | ||
value: string; | ||
code: string; | ||
} | null)[]; | ||
} | null | undefined; | ||
@@ -66,0 +82,0 @@ items?: ({ |
@@ -1,2 +0,2 @@ | ||
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=` | ||
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 h extends Error{constructor(e){super(`Missing argument: ${e}`)}}class a extends Error{constructor(){super("Order not found")}}const{setEndpoint:y,setFetchGraphQlHeader:O,removeFetchGraphQlHeader:b,setFetchGraphQlHeaders:f,fetchGraphQl:u,getConfig:w}=new m().getMethods(),c=` | ||
fragment guestOrderData on CustomerOrder { | ||
@@ -42,2 +42,8 @@ number | ||
company | ||
custom_attributesV2 { | ||
code | ||
... on AttributeValue { | ||
value | ||
} | ||
} | ||
} | ||
@@ -56,2 +62,8 @@ shipping_address { | ||
company | ||
custom_attributesV2 { | ||
code | ||
... on AttributeValue { | ||
value | ||
} | ||
} | ||
} | ||
@@ -104,4 +116,4 @@ items { | ||
} | ||
${i} | ||
`,$=async t=>{const{data:e,errors:r}=await c(l,{variables:{...t}});if(r)throw new o(r);const s=e==null?void 0:e.guestOrder;if(!s)throw new a;return s},g=` | ||
${c} | ||
`,v=async t=>{const{data:e,errors:r}=await u(l,{variables:{...t}});if(r)throw new o(r);const s=e==null?void 0:e.guestOrder;if(!s)throw new a;return s},g=` | ||
query guestOrderByToken($token: String!) { | ||
@@ -112,4 +124,4 @@ guestOrderByToken(input: {token: $token}) { | ||
} | ||
${i} | ||
`,v=async t=>{const{data:e,errors:r}=await c(g,{variables:{token:t}});if(r)throw new o(r);const s=e==null?void 0:e.guestOrderByToken;if(!!!s)throw new a;return s},p=` | ||
${c} | ||
`,$=async t=>{const{data:e,errors:r}=await u(g,{variables:{token:t}});if(r)throw new o(r);const s=e==null?void 0:e.guestOrderByToken;if(!!!s)throw new a;return s},p=` | ||
query customerOrder($number: String!) { | ||
@@ -125,3 +137,3 @@ customer { | ||
} | ||
${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}; | ||
${c} | ||
`,k=async t=>{var n,i,d;const{data:e,errors:r}=await u(p,{variables:{number:t}});if(r)throw new o(r);const s=(d=(i=(n=e==null?void 0:e.customer)==null?void 0:n.orders)==null?void 0:i.items)==null?void 0:d[0];if(!s)throw new a;return s};export{o as F,h as M,a as O,O as a,f as b,v as c,$ as d,k as e,u as f,w as g,b as r,y as s}; |
@@ -1,1 +0,1 @@ | ||
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}; | ||
import{c as Q,e as J,d as X}from"../chunks/customerOrder.js";import{useState as Y,useEffect as rr}from"@dropins/tools/preact-hooks.js";import{classes as v,getFormValues as er}from"@dropins/tools/lib.js";import{jsx as r,jsxs as m,Fragment as E}from"@dropins/tools/preact-jsx-runtime.js";import{Icon as U,Button as P,Skeleton as L,SkeletonRow as u,Card as T,InLineAlert as nr,Field as M,Input as W,Price as O,Divider as z,CartItem as tr,Image as ar,CartItemSkeleton as b}from"@dropins/tools/components.js";import*as _ from"@dropins/tools/preact-compat.js";import{useReducer as or,useState as ir,useCallback as q,useEffect as $}from"@dropins/tools/preact-compat.js";import{Text as l,useText as H}from"@dropins/tools/i18n.js";import{events as cr}from"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const mr=()=>{const e=()=>window.innerWidth>=1920?"xxlarge":window.innerWidth>=1366?"xlarge":window.innerWidth>=1024?"large":window.innerWidth>=768?"medium":"small",[n,a]=Y(e());return rr(()=>{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 w=(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))(w||{}),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 K=({children:e,className:n})=>mr()!=="small"?r("div",{className:n,children:e}):r(E,{children:e});function lr(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,d=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:(d==null?void 0:d.value)||0,currency:(d==null?void 0:d.currency)||""}}}const sr=({state:e})=>{const{isLoading:n,details:a}=e,i=lr(a);return m(E,{children:[r(kr,{isLoading:n,summary:i}),r(br,{isLoading:n,details:a})]})},ur=({state:e})=>r(K,{className:"order-confirmation__aside",children:r(sr,{state:e})}),fr=({state:e,routeHome:n,routeSupport:a,onSignUpClick:i})=>{const{details:o,isLoading:t}=e,d=o==null?void 0:o.billing_address,c=(d==null?void 0:d.firstname)||"",f=(o==null?void 0:o.number)||"",C=(o==null?void 0:o.status)||"";return m(E,{children:[(t||!t&&(!!c&&!!f))&&r(vr,{isLoading:t,customerName:c,orderNumber:f,orderStatus:C,onSignUpClick:i}),r(Cr,{isLoading:t,orderDetails:o}),r(Sr,{isLoading:t,routeHome:n,routeSupport:a})]})},hr=({state:e,routeHome:n,routeSupport:a,dismissAlert:i,onOrderSearch:o,onSignUpClick:t})=>r(K,{className:"order-confirmation__main",children:r(fr,{state:e,routeHome:n,routeSupport:a,dismissAlert:i,onOrderSearch:o,onSignUpClick:t})}),pr=({className:e,state:n,dismissAlert:a,routeHome:i,routeSupport:o,onOrderSearch:t,onSignUpClick:d})=>{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(Or,{alert:s||h?{heading:f.message,description:"",type:f.type,onDismiss:a}:void 0,onOrderSearch:t})}):m("div",{className:v(["order-confirmation",e]),children:[r(hr,{state:n,dismissAlert:a,routeHome:i,routeSupport:o,onOrderSearch:t,onSignUpClick:d}),r(ur,{state:n})]})},_r=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)"})))),yr=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"})),vr=({isLoading:e,customerName:n,orderNumber:a,orderStatus:i,onSignUpClick:o})=>e?r(gr,{}):m("div",{className:"order-confirmation-header order-confirmation__card",children:[r(U,{source:_r,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&&m("p",{className:"order-confirmation-header__order",children:[r(l,{id:"OrderConfirmation.Header.order",fields:{order:a}}),i!==void 0&&i!==""&&m("span",{className:"order-confirmation-header__status",children:[" ","(",i,")"]})]}),o&&m("div",{className:"order-confirmation-create-account",children:[r("p",{className:"order-confirmation-create-account__message",children:r(l,{id:"OrderConfirmation.Header.CreateAccount.message"})}),r(P,{"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"})})]})]}),gr=()=>m(L,{"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})]}),Or=({alert:e,onOrderSearch:n})=>{const a=H({email:"OrderConfirmation.OrderSearchForm.email",postcode:"OrderConfirmation.OrderSearchForm.postcode",number:"OrderConfirmation.OrderSearchForm.orderNumber"}),i=o=>{o.preventDefault();const t=er(o.target);n==null||n(t)};return m(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(nr,{className:"order-confirmation-order-search-form__alert","data-testid":"order-confirmation-alert",icon:r(U,{source:yr}),...e}),m("form",{className:"order-confirmation-order-search-form__fields",onSubmit:i,children:[m("div",{className:"order-confirmation-order-search-form__fields-columns",children:[r(M,{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(M,{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(M,{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(P,{className:"order-confirmation-order-search-form__button",size:"medium",variant:"primary",type:"submit",children:r(l,{id:"OrderConfirmation.OrderSearchForm.button"})},"logIn")]})]})};function B(e){return e!==null&&e.value!==void 0}function A(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,custom_attributesV2:e==null?void 0:e.custom_attributesV2.filter(B).map(n=>({attribute_code:n.code,value:n.value}))}}const Cr=({isLoading:e,orderDetails:n})=>{var x,F,j,D,Z;if(e)return r(Nr,{});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,d=n&&t!==null,c=n==null?void 0:n.billing_address,f=n&&c!==null,C=n==null?void 0:n.shipping_method,y=(F=(x=n==null?void 0:n.total)==null?void 0:x.total_shipping)==null?void 0:F.value,s=(D=(j=n==null?void 0:n.total)==null?void 0:j.total_shipping)==null?void 0:D.currency,h=n&&C&&s&&y!=null,p=n==null?void 0:n.payment_methods,g=p&&p.length>0,k=g?(Z=p[0])==null?void 0:Z.name:"",I=n&&g&&k!=="";return m(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"})})}),m("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(S,{rows:1,"data-testid":"order-confirmation-details-contact-skeleton"})]}),m("div",{className:"order-confirmation-details__information",children:[m("div",{className:"order-confirmation-details__shipping_address",children:[(!a||d)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.shippingAddress"})}),d&&m(E,{children:[m("p",{children:[t==null?void 0:t.firstname," ",t==null?void 0:t.lastname]}),t==null?void 0:t.street.map((N,V)=>r("p",{children:N},V)),m("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]}),t==null?void 0:t.custom_attributesV2.filter(B).map(N=>r("p",{children:N.value},N.code))]}),!a&&r(S,{rows:3,"data-testid":"order-confirmation-shipping-address-skeleton"})]}),m("div",{className:"order-confirmation-details__billing_address",children:[(!a||f)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.billingAddress"})}),f&&m(E,{children:[m("p",{children:[c==null?void 0:c.firstname," ",c==null?void 0:c.lastname]}),c==null?void 0:c.street.map((N,V)=>r("p",{children:N},V)),m("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]}),c==null?void 0:c.custom_attributesV2.filter(B).map(N=>r("p",{children:N.value},N.code))]}),!a&&r(S,{rows:3,"data-testid":"order-confirmation-billing-address-skeleton"})]}),m("div",{className:"order-confirmation-details__shipping-method",children:[(!a||h)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.shippingMethod"})}),h&&r(E,{children:y===0?r("p",{className:"order-confirmation-order-summary__price",children:r(l,{id:"OrderConfirmation.Details.freeShipping"})}):m("p",{children:[r(O,{amount:y,currency:s})," ",C]})}),!a&&r(S,{rows:1,"data-testid":"order-confirmation-details-shipping-method-skeleton"})]}),m("div",{className:"order-confirmation-details__payment-method",children:[(!a||I)&&r("h3",{children:r(l,{id:"OrderConfirmation.Details.paymentMethod"})}),I&&r("p",{children:k}),!a&&r(S,{rows:1,"data-testid":"order-confirmation-details-payment-method-skeleton"})]})]})]})},Nr=()=>r(T,{variant:"secondary",className:"order-confirmation-details",children:m(L,{"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"})]})}),Sr=({isLoading:e,className:n,routeHome:a,routeSupport:i,...o})=>e?r(Er,{}):m("div",{className:v(["order-confirmation-footer",n]),...o,children:[(a==null?void 0:a())&&r(P,{"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"),m("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"})})]})]}),Er=()=>m(L,{className:"order-confirmation-footer",children:[r(u,{size:"small",fullWidth:!0}),r(u,{variant:"heading",size:"xsmall",fullWidth:!0})]}),S=({rows:e,size:n="xsmall",...a})=>r(L,{className:"static-skeleton",...a,children:Array.from(Array(e).keys()).map(i=>r(u,{variant:"heading",size:n,fullWidth:!0},i))}),kr=({className:e,isLoading:n,summary:a,variant:i="secondary"})=>{if(n)return r(wr,{});const{total:o,subtotal:t,shipping:d,tax:c}=a??{};return m(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(z,{variant:"primary"}),t!=null?m("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(S,{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"})})}),d!=null?d.isVirtual?null:m("div",{"data-testid":"order-summary-shipping",className:"order-confirmation-order-summary__row",children:[r("p",{children:r(l,{id:"OrderConfirmation.OrderSummary.shipping"})}),d.amount===0?r("p",{className:"order-confirmation-order-summary__price",children:r(l,{id:"OrderConfirmation.OrderSummary.freeShipping"})}):r(O,{amount:d.amount,currency:d.currency,className:v(["order-confirmation-order-summary__price",e])})]}):r(S,{rows:1,"data-testid":"order-confirmation-order-summary-shipping-skeleton"}),c!=null&&!c.breakdown&&m("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&&m(E,{children:[r(z,{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=>m("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)),m("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(z,{variant:"secondary"})]}),o!=null?m("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(S,{rows:1,"data-testid":"order-confirmation-order-summary-total-skeleton"}),(o==null?void 0:o.exclTax)!=null&&m("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])})]})]})},wr=()=>m(L,{"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})]}),Lr=({className:e,item:n,taxIncluded:a=!1})=>{const i=H({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 d={..."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(tr,{"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(ar,{src:n.image.src,alt:n.image.alt,loading:"lazy",width:"80",height:"80",params:{width:80}}),configurations:d,price:r(O,{amount:n.regularPrice.value,currency:o.currency,weight:"normal"}),total:m(E,{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 Ir(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:xr(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 xr(e){if(!("selected_options"in e))return;const n={};for(const a of e.selected_options)n[a.label]=a.value;return n}const br=({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:m(T,{variant:"secondary",children:[r("div",{className:"order-confirmation-cart-summary__heading",children:m("h2",{className:"order-confirmation-cart-summary__title",children:[r(l,{id:"OrderConfirmation.CartSummary.title"})," (",o,")"]})}),r(z,{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 d=Ir(t);return r(Lr,{item:d,taxIncluded:a},d==null?void 0:d.uid)})})]})})},Rr=()=>m(L,{"data-testid":"cart-summary-skeleton",className:"order-confirmation-cart-summary",style:{gridTemplateColumns:"1fr"},children:[r(u,{variant:"heading",fullWidth:!0,size:"medium"}),r(b,{}),r(b,{}),r(b,{}),r(b,{}),r(b,{})]});function Tr(e){const[n,a]=or(dr,{isLoading:!1,orderRef:e,details:null,isOrderFromSearchForm:!1}),[i,o]=ir(),t=H({invalidOrder:"OrderConfirmation.Errors.invalidOrder",invalidSearch:"OrderConfirmation.Errors.invalidSearch",pageNotFound:"OrderConfirmation.Errors.pageNotFound",unknown:"OrderConfirmation.Errors.unknown"}),d=q(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:w.DISMISS_ALERT})},f=function(s){C(s)};$(()=>{const s=cr.on("authenticated",h=>{o(h)},{eager:!0});return()=>{s==null||s.off()}},[]);const C=q(s=>{Q(s).then(h=>{const g=!!(h!=null&&h.number)?void 0:d("Invalid search");a({type:w.SET_DETAILS,fromSearchForm:!0,alert:g,details:h})}).catch(()=>{const h=d("Invalid search");a({type:w.SET_DETAILS,details:null,alert:h})})},[d]),y=q(s=>{(i?J:X)(s).then(p=>{const k=!!(p!=null&&p.number)?void 0:d("Invalid order");a({type:w.SET_DETAILS,details:p,alert:k})}).catch(p=>{const g=d(p.message);if(!g){console.error(p);return}a({type:w.ALERT,alert:g})})},[i,d]);return $(()=>{!n.orderRef||i===void 0||(a({type:w.LOADING}),y(n.orderRef))},[i,y,n.orderRef]),{state:n,authenticated:i,handleOrderSearch:f,dismissAlert:c}}const Pr=({orderRef:e,routeHome:n,routeSupport:a,onSignUpClick:i})=>{const{state:o,authenticated:t,handleOrderSearch:d,dismissAlert:c}=Tr(e);if(t===void 0)return null;const C=i&&!t&&!o.isOrderFromSearchForm?()=>{var g,k,I;const y=(g=o.details)==null?void 0:g.shipping_address,s=(k=o.details)==null?void 0:k.billing_address,h=[{code:"firstname",defaultValue:(s==null?void 0:s.firstname)||""},{code:"lastname",defaultValue:(s==null?void 0:s.lastname)||""},{code:"email",defaultValue:((I=o.details)==null?void 0:I.email)||""}];let p;if(y){const x={...A(y),default_shipping:!0};p=[{...A(s),default_billing:!0},x]}else p=[{...A(s),default_billing:!0,default_shipping:!0}];i({inputsDefaultValueSet:h,addressesData:p})}:void 0;return r(pr,{state:o,dismissAlert:c,onOrderSearch:d,routeHome:n,routeSupport:a,onSignUpClick:C})};export{Pr as OrderConfirmation,Pr as default}; |
@@ -5,3 +5,4 @@ import { CustomerAddressInput } from '../../__generated__/types'; | ||
export type OrderDetailsAddress = OrderDetails['shipping_address'] | OrderDetails['billing_address']; | ||
export declare function isValidCustomAttribute(attr: NonNullable<OrderDetailsAddress>['custom_attributesV2'][number]): boolean; | ||
export declare function transformCustomerAddress(address: OrderDetailsAddress): CustomerAddressInput; | ||
//# sourceMappingURL=transform-customer-address.d.ts.map |
@@ -1,1 +0,1 @@ | ||
{"name": "@dropins/storefront-order-confirmation", "version": "0.1.0-alpha26", "@dropins/elsie": "~0.26.0"} | ||
{"name": "@dropins/storefront-order-confirmation", "version": "0.1.0-alpha27", "@dropins/elsie": "~0.26.0"} |
Sorry, the diff of this file is too big to display
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
1058145
20682
0