From 61aa58b36e2aa0941d4734a9eae55ca7f2128ea5 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Fri, 13 Dec 2024 02:07:58 +0200 Subject: [PATCH] updated order --- scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js | 2 +- .../__dropins__/storefront-order/containers/OrderCostSummary.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js b/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js index 97f5fb2f5..527a5d6d2 100644 --- a/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js +++ b/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as v,jsxs as S,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{Price as P,Image as T,CartItem as g,Icon as u,Incrementer as o}from"@dropins/tools/components.js";import{useCallback as G}from"@dropins/tools/preact-hooks.js";import{classes as J}from"@dropins/tools/lib.js";import{O as r}from"./OrderLoaders.js";import*as M from"@dropins/tools/preact-compat.js";const c=k=>M.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...k},M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),se=({placeholderImage:k="",loading:X,product:e,itemType:Y,taxConfig:D,translations:h,disabledIncrementer:i,onQuantity:E,showConfigurableOptions:V,routeProductDetails:w})=>{var q,x,O,W,$,z,B,F,K,R,U;const{taxExcluded:f,taxIncluded:L}=D,t=G((m,H,b)=>v(P,{amount:m,currency:H,weight:"normal",...b}),[]),Z=G(m=>{var b,A;const H=(b=m==null?void 0:m.product)!=null&&b.thumbnail.url.length?(A=m==null?void 0:m.product)==null?void 0:A.thumbnail.url:k;return v(T,{src:H,alt:m==null?void 0:m.productName,loading:"lazy",width:"90",height:"120"})},[k]);if(!e)return v(r,{});let N={};const Q=Y==="cancelled",C=(x=(q=e==null?void 0:e.product)==null?void 0:q.stockStatus)==null?void 0:x.includes("IN_STOCK"),l=e==null?void 0:e.giftCard,a=(O=e==null?void 0:e.itemPrices)==null?void 0:O.priceIncludingTax,s=(W=e==null?void 0:e.itemPrices)==null?void 0:W.originalPrice,n=($=e==null?void 0:e.itemPrices)==null?void 0:$.price,I=e.totalQuantity>1?{quantity:e.totalQuantity}:{},y=e.discounted&&((z=e.price)==null?void 0:z.value)!==(s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),j={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.senderEmail?{[h.sender]:l==null?void 0:l.senderEmail}:{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.recipientEmail?{[h.recipient]:l==null?void 0:l.recipientEmail}:{},...l!=null&&l.message?{[h.message]:l==null?void 0:l.message}:{},...e!=null&&e.downloadableLinks?{[`${(B=e==null?void 0:e.downloadableLinks)==null?void 0:B.count} ${h.downloadableCount}`]:(F=e==null?void 0:e.downloadableLinks)==null?void 0:F.result}:{}};if(L&&f){const m=y?s==null?void 0:s.value:(a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity);N={taxExcluded:!0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t(m,s==null?void 0:s.currency,{variant:e.discounted&&(a==null?void 0:a.value)!==m?"strikethrough":"default"}),e.discounted&&(a==null?void 0:a.value)!==m?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*e.totalQuantity,n==null?void 0:n.currency)}}else if(!L&&f)N={taxExcluded:void 0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t((s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{variant:y?"strikethrough":"default"}),y?t((K=e.price)==null?void 0:K.value,(R=e.price)==null?void 0:R.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),n==null?void 0:n.currency)};else if(L&&!f){const m=y?s.value:a.value*e.totalQuantity;N={taxExcluded:void 0,taxIncluded:!0,price:t(a==null?void 0:a.value,a==null?void 0:a.currency),total:S(_,{children:[t(m,a==null?void 0:a.currency,{variant:y?"strikethrough":"default",weight:"bold"}),y?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]})}}return v(g,{loading:X,alert:Q&&C?S("span",{children:[v(u,{source:c}),h.outOfStock]}):v(_,{}),configurations:(V==null?void 0:V(j))??j,title:w?v("a",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),href:w(e),children:e==null?void 0:e.productName}):v("div",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),children:e==null?void 0:e.productName}),sku:v("div",{children:(U=e==null?void 0:e.product)==null?void 0:U.sku}),...I,image:w?v("a",{href:w(e),children:Z(e)}):Z(e),...N,footer:E&&!i?v(o,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:m=>E==null?void 0:E(Number(m)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0})};export{se as C,c as S}; +import{jsx as v,jsxs as S,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{Price as P,Image as T,CartItem as g,Icon as u,Incrementer as o}from"@dropins/tools/components.js";import{useCallback as G}from"@dropins/tools/preact-hooks.js";import{classes as J}from"@dropins/tools/lib.js";import{O as r}from"./OrderLoaders.js";import*as M from"@dropins/tools/preact-compat.js";const c=k=>M.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...k},M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),se=({placeholderImage:k="",loading:X,product:e,itemType:Y,taxConfig:D,translations:h,disabledIncrementer:i,onQuantity:E,showConfigurableOptions:V,routeProductDetails:w})=>{var q,x,O,W,$,z,B,F,K,R,U;console.log("CartSummaryItem",e);const{taxExcluded:f,taxIncluded:L}=D,t=G((m,H,b)=>v(P,{amount:m,currency:H,weight:"normal",...b}),[]),Z=G(m=>{var b,A;const H=(b=m==null?void 0:m.product)!=null&&b.thumbnail.url.length?(A=m==null?void 0:m.product)==null?void 0:A.thumbnail.url:k;return v(T,{src:H,alt:m==null?void 0:m.productName,loading:"lazy",width:"90",height:"120"})},[k]);if(!e)return v(r,{});let N={};const Q=Y==="cancelled",C=(x=(q=e==null?void 0:e.product)==null?void 0:q.stockStatus)==null?void 0:x.includes("IN_STOCK"),l=e==null?void 0:e.giftCard,a=(O=e==null?void 0:e.itemPrices)==null?void 0:O.priceIncludingTax,s=(W=e==null?void 0:e.itemPrices)==null?void 0:W.originalPrice,n=($=e==null?void 0:e.itemPrices)==null?void 0:$.price,I=e.totalQuantity>1?{quantity:e.totalQuantity}:{},y=e.discounted&&((z=e.price)==null?void 0:z.value)!==(s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),j={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.senderEmail?{[h.sender]:l==null?void 0:l.senderEmail}:{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.recipientEmail?{[h.recipient]:l==null?void 0:l.recipientEmail}:{},...l!=null&&l.message?{[h.message]:l==null?void 0:l.message}:{},...e!=null&&e.downloadableLinks?{[`${(B=e==null?void 0:e.downloadableLinks)==null?void 0:B.count} ${h.downloadableCount}`]:(F=e==null?void 0:e.downloadableLinks)==null?void 0:F.result}:{}};if(L&&f){const m=y?s==null?void 0:s.value:(a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity);N={taxExcluded:!0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t(m,s==null?void 0:s.currency,{variant:e.discounted&&(a==null?void 0:a.value)!==m?"strikethrough":"default"}),e.discounted&&(a==null?void 0:a.value)!==m?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*e.totalQuantity,n==null?void 0:n.currency)}}else if(!L&&f)N={taxExcluded:void 0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t((s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{variant:y?"strikethrough":"default"}),y?t((K=e.price)==null?void 0:K.value,(R=e.price)==null?void 0:R.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),n==null?void 0:n.currency)};else if(L&&!f){const m=y?s.value:a.value*e.totalQuantity;N={taxExcluded:void 0,taxIncluded:!0,price:t(a==null?void 0:a.value,a==null?void 0:a.currency),total:S(_,{children:[t(m,a==null?void 0:a.currency,{variant:y?"strikethrough":"default",weight:"bold"}),y?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]})}}return v(g,{loading:X,alert:Q&&C?S("span",{children:[v(u,{source:c}),h.outOfStock]}):v(_,{}),configurations:(V==null?void 0:V(j))??j,title:w?v("a",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),href:w(e),children:e==null?void 0:e.productName}):v("div",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),children:e==null?void 0:e.productName}),sku:v("div",{children:(U=e==null?void 0:e.product)==null?void 0:U.sku}),...I,image:w?v("a",{href:w(e),children:Z(e)}):Z(e),...N,footer:E&&!i?v(o,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:m=>E==null?void 0:E(Number(m)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0})};export{se as C,c as S}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js index 18e66d9b0..2e10a21ca 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as c,jsxs as i,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Z}from"@dropins/tools/lib.js";import{useState as g,useEffect as V}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as b}from"@dropins/tools/event-bus.js";import{s as S}from"../chunks/setTaxStatus.js";import{Price as d,Icon as E,Accordion as f,AccordionSection as D,Card as I,Header as k}from"@dropins/tools/components.js";import{u as z}from"../chunks/useGetStoreConfig.js";import"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{O as A}from"../chunks/OrderLoaders.js";import{useText as B}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const $=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),P=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M22 6.25H22.75C22.75 5.83579 22.4142 5.5 22 5.5V6.25ZM22 9.27L22.2514 9.97663C22.5503 9.87029 22.75 9.58731 22.75 9.27H22ZM20.26 12.92L19.5534 13.1714L19.5539 13.1728L20.26 12.92ZM22 14.66H22.75C22.75 14.3433 22.551 14.0607 22.2528 13.9539L22 14.66ZM22 17.68V18.43C22.4142 18.43 22.75 18.0942 22.75 17.68H22ZM2 17.68H1.25C1.25 18.0942 1.58579 18.43 2 18.43V17.68ZM2 14.66L1.74865 13.9534C1.44969 14.0597 1.25 14.3427 1.25 14.66H2ZM3.74 11.01L4.44663 10.7586L4.44611 10.7572L3.74 11.01ZM2 9.27H1.25C1.25 9.58675 1.44899 9.86934 1.7472 9.97611L2 9.27ZM2 6.25V5.5C1.58579 5.5 1.25 5.83579 1.25 6.25H2ZM21.25 6.25V9.27H22.75V6.25H21.25ZM21.7486 8.56337C19.8706 9.23141 18.8838 11.2889 19.5534 13.1714L20.9666 12.6686C20.5762 11.5711 21.1494 10.3686 22.2514 9.97663L21.7486 8.56337ZM19.5539 13.1728C19.9195 14.1941 20.7259 15.0005 21.7472 15.3661L22.2528 13.9539C21.6541 13.7395 21.1805 13.2659 20.9661 12.6672L19.5539 13.1728ZM21.25 14.66V17.68H22.75V14.66H21.25ZM22 16.93H2V18.43H22V16.93ZM2.75 17.68V14.66H1.25V17.68H2.75ZM2.25135 15.3666C4.12941 14.6986 5.11623 12.6411 4.44663 10.7586L3.03337 11.2614C3.42377 12.3589 2.85059 13.5614 1.74865 13.9534L2.25135 15.3666ZM4.44611 10.7572C4.08045 9.73588 3.27412 8.92955 2.2528 8.56389L1.7472 9.97611C2.34588 10.1905 2.81955 10.6641 3.03389 11.2628L4.44611 10.7572ZM2.75 9.27V6.25H1.25V9.27H2.75ZM2 7H22V5.5H2V7ZM7.31 6.74V18.17H8.81V6.74H7.31ZM17.0997 8.39967L11.0397 14.4597L12.1003 15.5203L18.1603 9.46033L17.0997 8.39967ZM12.57 9.67C12.57 9.87231 12.4159 10 12.27 10V11.5C13.2839 11.5 14.07 10.6606 14.07 9.67H12.57ZM12.27 10C12.1241 10 11.97 9.87231 11.97 9.67H10.47C10.47 10.6606 11.2561 11.5 12.27 11.5V10ZM11.97 9.67C11.97 9.46769 12.1241 9.34 12.27 9.34V7.84C11.2561 7.84 10.47 8.67938 10.47 9.67H11.97ZM12.27 9.34C12.4159 9.34 12.57 9.46769 12.57 9.67H14.07C14.07 8.67938 13.2839 7.84 12.27 7.84V9.34ZM17.22 14.32C17.22 14.5223 17.0659 14.65 16.92 14.65V16.15C17.9339 16.15 18.72 15.3106 18.72 14.32H17.22ZM16.92 14.65C16.7741 14.65 16.62 14.5223 16.62 14.32H15.12C15.12 15.3106 15.9061 16.15 16.92 16.15V14.65ZM16.62 14.32C16.62 14.1177 16.7741 13.99 16.92 13.99V12.49C15.9061 12.49 15.12 13.3294 15.12 14.32H16.62ZM16.92 13.99C17.0659 13.99 17.22 14.1177 17.22 14.32H18.72C18.72 13.3294 17.9339 12.49 16.92 12.49V13.99Z",fill:"#3D3D3D"})),W=({orderData:s,config:e})=>{const[t,n]=g(!0),[u,r]=g(s),[l,m]=g(null);return V(()=>{if(e){const{shoppingCartDisplayPrice:o,shoppingOrdersDisplayShipping:a,shoppingOrdersDisplaySubtotal:h,...y}=e;m(p=>({...p,...y,shoppingCartDisplayPrice:S(o),shoppingOrdersDisplayShipping:S(a),shoppingOrdersDisplaySubtotal:S(h)})),n(!1)}},[e]),V(()=>{const o=b.on("order/data",a=>{r(a)},{eager:!0});return()=>{o==null||o.off()}},[]),{loading:t,storeConfig:l,order:u}},mt=({withHeader:s,orderData:e,children:t,className:n,...u})=>{const r=z(),{loading:l,storeConfig:m,order:o}=W({orderData:e,config:r}),a=B({subtotal:"Order.OrderCostSummary.subtotal.title",shipping:"Order.OrderCostSummary.shipping.title",freeShipping:"Order.OrderCostSummary.shipping.freeShipping",tax:"Order.OrderCostSummary.tax.title",incl:"Order.OrderCostSummary.tax.incl",excl:"Order.OrderCostSummary.tax.excl",discount:"Order.OrderCostSummary.discount.title",discountSubtitle:"Order.OrderCostSummary.discount.subtitle",total:"Order.OrderCostSummary.total.title",accordionTitle:"Order.OrderCostSummary.tax.accordionTitle",accordionTotalTax:"Order.OrderCostSummary.tax.accordionTotalTax",totalExcludingTaxes:"Order.OrderCostSummary.tax.totalExcludingTaxes",headerText:"Order.OrderCostSummary.headerText"});return c("div",{...u,className:Z(["order-cost-summary",n]),children:c(K,{order:o,withHeader:s,loading:l,storeConfig:m,translations:a})})},q=({translations:s,order:e,subtotalInclTax:t,subtotalExclTax:n,shoppingOrdersDisplaySubtotal:u})=>{var h,y,p,x;const r=u.taxIncluded,l=u.taxExcluded,m=r&&!l?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(h=e==null?void 0:e.subtotalInclTax)==null?void 0:h.currency,amount:t})]}),c("div",{className:"order-cost-summary-content__description--subheader",children:c("span",{children:s.incl})})]}):null,o=l&&!r?i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(y=e==null?void 0:e.subtotalExclTax)==null?void 0:y.currency,amount:n})]}):null,a=l&&r?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(p=e==null?void 0:e.subtotalInclTax)==null?void 0:p.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[c(d,{currency:(x=e==null?void 0:e.subtotalExclTax)==null?void 0:x.currency,amount:n,size:"small",weight:"bold"})," ",c("span",{children:s.excl})]})]}):null;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[m,o,a]})},F=({translations:s,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var u,r,l,m;return t!=null&&t.isVirtual?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.shipping}),(u=t==null?void 0:t.totalShipping)!=null&&u.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:s.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?i(v,{children:[c(d,{weight:"normal",currency:(l=t==null?void 0:t.totalShipping)==null?void 0:l.currency,amount:(m=t==null?void 0:t.totalShipping)==null?void 0:m.value,size:"small"}),i("span",{children:[" ",s.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:s.incl}):null]})]})},U=({translations:s,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,l,m,o;const u=(r=e==null?void 0:e.discounts)==null?void 0:r.every(a=>a.amount.value===0);return!((l=e==null?void 0:e.discounts)!=null&&l.length)&&(u||!t||t<1)||(m=e==null?void 0:e.discounts)!=null&&m.length&&u?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.discount}),c("span",{children:(o=e==null?void 0:e.discounts)==null?void 0:o.map(({amount:a},h)=>{const p=((a==null?void 0:a.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:a==null?void 0:a.currency,amount:-p},`${a==null?void 0:a.value}${h}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(E,{source:P,size:"16"}),c("span",{children:s.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},G=({order:s})=>{var e;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(e=s==null?void 0:s.coupons)==null?void 0:e.map((t,n)=>c("div",{className:"order-cost-summary-content__description--header",children:c("span",{children:t.code})},`${t==null?void 0:t.code}${n}`))})},R=({translations:s,renderTaxAccordion:e,totalAccordionTaxValue:t,order:n})=>{var l,m,o;const[u,r]=g(!1);return e?c(f,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:$,iconClose:j,children:i(D,{onStateChange:r,title:s.accordionTitle,secondaryText:c(v,{children:u?null:c(d,{weight:"normal",amount:t,currency:(m=n==null?void 0:n.totalTax)==null?void 0:m.currency})}),renderContentWhenClosed:!1,children:[(o=n==null?void 0:n.taxes)==null?void 0:o.map((a,h)=>{var y,p,x;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:a==null?void 0:a.title}),c("p",{children:c(d,{weight:"normal",amount:(y=a==null?void 0:a.amount)==null?void 0:y.value,currency:(p=a==null?void 0:a.amount)==null?void 0:p.currency})})]},`${(x=a==null?void 0:a.amount)==null?void 0:x.value}${h}`)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:s.accordionTotalTax}),c("p",{children:c(d,{weight:"normal",amount:t,currency:n.totalTax.currency,size:"medium"})})]})]})}):c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--tax",children:i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.tax}),c(d,{currency:(l=n==null?void 0:n.totalTax)==null?void 0:l.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},J=({translations:s,shoppingOrdersDisplaySubtotal:e,order:t})=>{var n,u,r,l;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--total",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.total}),c(d,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(u=t==null?void 0:t.grandTotal)==null?void 0:u.value,weight:"bold",size:"medium"})]}),e.taxExcluded&&e.taxIncluded?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:s.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.currency,amount:((l=t==null?void 0:t.grandTotal)==null?void 0:l.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},K=({translations:s,loading:e,storeConfig:t,order:n,withHeader:u=!0})=>{var p,x,w,O,T,L,M;if(e||!n)return c(A,{});const r=((p=n==null?void 0:n.totalGiftcard)==null?void 0:p.value)??0,l=((x=n.totalGiftcard)==null?void 0:x.currency)??"",m=((w=n.subtotalInclTax)==null?void 0:w.value)??0,o=((O=n.subtotalExclTax)==null?void 0:O.value)??0,a=((T=n.totalShipping)==null?void 0:T.value)??0,h=!!((L=n==null?void 0:n.taxes)!=null&&L.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),y=h?(M=n==null?void 0:n.taxes)==null?void 0:M.reduce((N,C)=>{var H;return+((H=C==null?void 0:C.amount)==null?void 0:H.value)+N},0):0;return i(I,{variant:"secondary",className:Z(["order-cost-summary-content"]),children:[u?c(k,{title:s.headerText}):null,i("div",{className:"order-cost-summary-content__wrapper",children:[c(q,{translations:s,order:n,subtotalInclTax:m,subtotalExclTax:o,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(F,{translations:s,order:n,totalShipping:a,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(U,{translations:s,order:n,totalGiftcardValue:r,totalGiftcardCurrency:l}),c(G,{order:n}),c(R,{order:n,translations:s,renderTaxAccordion:h,totalAccordionTaxValue:y}),c(J,{translations:s,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})};export{mt as OrderCostSummary,mt as default}; +import{jsx as c,jsxs as i,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Z}from"@dropins/tools/lib.js";import{useState as g,useEffect as V}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as b}from"@dropins/tools/event-bus.js";import{s as S}from"../chunks/setTaxStatus.js";import{Price as d,Icon as E,Accordion as f,AccordionSection as D,Card as I,Header as k}from"@dropins/tools/components.js";import{u as z}from"../chunks/useGetStoreConfig.js";import"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{O as A}from"../chunks/OrderLoaders.js";import{useText as B}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const $=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),P=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M22 6.25H22.75C22.75 5.83579 22.4142 5.5 22 5.5V6.25ZM22 9.27L22.2514 9.97663C22.5503 9.87029 22.75 9.58731 22.75 9.27H22ZM20.26 12.92L19.5534 13.1714L19.5539 13.1728L20.26 12.92ZM22 14.66H22.75C22.75 14.3433 22.551 14.0607 22.2528 13.9539L22 14.66ZM22 17.68V18.43C22.4142 18.43 22.75 18.0942 22.75 17.68H22ZM2 17.68H1.25C1.25 18.0942 1.58579 18.43 2 18.43V17.68ZM2 14.66L1.74865 13.9534C1.44969 14.0597 1.25 14.3427 1.25 14.66H2ZM3.74 11.01L4.44663 10.7586L4.44611 10.7572L3.74 11.01ZM2 9.27H1.25C1.25 9.58675 1.44899 9.86934 1.7472 9.97611L2 9.27ZM2 6.25V5.5C1.58579 5.5 1.25 5.83579 1.25 6.25H2ZM21.25 6.25V9.27H22.75V6.25H21.25ZM21.7486 8.56337C19.8706 9.23141 18.8838 11.2889 19.5534 13.1714L20.9666 12.6686C20.5762 11.5711 21.1494 10.3686 22.2514 9.97663L21.7486 8.56337ZM19.5539 13.1728C19.9195 14.1941 20.7259 15.0005 21.7472 15.3661L22.2528 13.9539C21.6541 13.7395 21.1805 13.2659 20.9661 12.6672L19.5539 13.1728ZM21.25 14.66V17.68H22.75V14.66H21.25ZM22 16.93H2V18.43H22V16.93ZM2.75 17.68V14.66H1.25V17.68H2.75ZM2.25135 15.3666C4.12941 14.6986 5.11623 12.6411 4.44663 10.7586L3.03337 11.2614C3.42377 12.3589 2.85059 13.5614 1.74865 13.9534L2.25135 15.3666ZM4.44611 10.7572C4.08045 9.73588 3.27412 8.92955 2.2528 8.56389L1.7472 9.97611C2.34588 10.1905 2.81955 10.6641 3.03389 11.2628L4.44611 10.7572ZM2.75 9.27V6.25H1.25V9.27H2.75ZM2 7H22V5.5H2V7ZM7.31 6.74V18.17H8.81V6.74H7.31ZM17.0997 8.39967L11.0397 14.4597L12.1003 15.5203L18.1603 9.46033L17.0997 8.39967ZM12.57 9.67C12.57 9.87231 12.4159 10 12.27 10V11.5C13.2839 11.5 14.07 10.6606 14.07 9.67H12.57ZM12.27 10C12.1241 10 11.97 9.87231 11.97 9.67H10.47C10.47 10.6606 11.2561 11.5 12.27 11.5V10ZM11.97 9.67C11.97 9.46769 12.1241 9.34 12.27 9.34V7.84C11.2561 7.84 10.47 8.67938 10.47 9.67H11.97ZM12.27 9.34C12.4159 9.34 12.57 9.46769 12.57 9.67H14.07C14.07 8.67938 13.2839 7.84 12.27 7.84V9.34ZM17.22 14.32C17.22 14.5223 17.0659 14.65 16.92 14.65V16.15C17.9339 16.15 18.72 15.3106 18.72 14.32H17.22ZM16.92 14.65C16.7741 14.65 16.62 14.5223 16.62 14.32H15.12C15.12 15.3106 15.9061 16.15 16.92 16.15V14.65ZM16.62 14.32C16.62 14.1177 16.7741 13.99 16.92 13.99V12.49C15.9061 12.49 15.12 13.3294 15.12 14.32H16.62ZM16.92 13.99C17.0659 13.99 17.22 14.1177 17.22 14.32H18.72C18.72 13.3294 17.9339 12.49 16.92 12.49V13.99Z",fill:"#3D3D3D"})),W=({orderData:s,config:e})=>{const[t,n]=g(!0),[u,r]=g(s),[l,m]=g(null);return V(()=>{if(e){const{shoppingCartDisplayPrice:o,shoppingOrdersDisplayShipping:a,shoppingOrdersDisplaySubtotal:h,...y}=e;m(p=>({...p,...y,shoppingCartDisplayPrice:S(o),shoppingOrdersDisplayShipping:S(a),shoppingOrdersDisplaySubtotal:S(h)})),n(!1)}},[e]),V(()=>{const o=b.on("order/data",a=>{r(a)},{eager:!0});return()=>{o==null||o.off()}},[]),{loading:t,storeConfig:l,order:u}},mt=({withHeader:s,orderData:e,children:t,className:n,...u})=>{const r=z(),{loading:l,storeConfig:m,order:o}=W({orderData:e,config:r}),a=B({subtotal:"Order.OrderCostSummary.subtotal.title",shipping:"Order.OrderCostSummary.shipping.title",freeShipping:"Order.OrderCostSummary.shipping.freeShipping",tax:"Order.OrderCostSummary.tax.title",incl:"Order.OrderCostSummary.tax.incl",excl:"Order.OrderCostSummary.tax.excl",discount:"Order.OrderCostSummary.discount.title",discountSubtitle:"Order.OrderCostSummary.discount.subtitle",total:"Order.OrderCostSummary.total.title",accordionTitle:"Order.OrderCostSummary.tax.accordionTitle",accordionTotalTax:"Order.OrderCostSummary.tax.accordionTotalTax",totalExcludingTaxes:"Order.OrderCostSummary.tax.totalExcludingTaxes",headerText:"Order.OrderCostSummary.headerText"});return c("div",{...u,className:Z(["order-cost-summary",n]),children:c(K,{order:o,withHeader:s,loading:l,storeConfig:m,translations:a})})},q=({translations:s,order:e,subtotalInclTax:t,subtotalExclTax:n,shoppingOrdersDisplaySubtotal:u})=>{var h,y,p,x;const r=u.taxIncluded,l=u.taxExcluded,m=r&&!l?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(h=e==null?void 0:e.subtotalInclTax)==null?void 0:h.currency,amount:t})]}),c("div",{className:"order-cost-summary-content__description--subheader",children:c("span",{children:s.incl})})]}):null,o=l&&!r?i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(y=e==null?void 0:e.subtotalExclTax)==null?void 0:y.currency,amount:n})]}):null,a=l&&r?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(p=e==null?void 0:e.subtotalInclTax)==null?void 0:p.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[c(d,{currency:(x=e==null?void 0:e.subtotalExclTax)==null?void 0:x.currency,amount:n,size:"small",weight:"bold"})," ",c("span",{children:s.excl})]})]}):null;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[m,o,a]})},F=({translations:s,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var u,r,l,m;return t!=null&&t.isVirtual?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.shipping}),(u=t==null?void 0:t.totalShipping)!=null&&u.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:s.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?i(v,{children:[c(d,{weight:"normal",currency:(l=t==null?void 0:t.totalShipping)==null?void 0:l.currency,amount:(m=t==null?void 0:t.totalShipping)==null?void 0:m.value,size:"small"}),i("span",{children:[" ",s.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:s.incl}):null]})]})},U=({translations:s,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,l,m,o;const u=(r=e==null?void 0:e.discounts)==null?void 0:r.every(a=>a.amount.value===0);return!((l=e==null?void 0:e.discounts)!=null&&l.length)&&(u||!t||t<1)||(m=e==null?void 0:e.discounts)!=null&&m.length&&u?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.discount}),c("span",{children:(o=e==null?void 0:e.discounts)==null?void 0:o.map(({amount:a},h)=>{const p=((a==null?void 0:a.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:a==null?void 0:a.currency,amount:-p},`${a==null?void 0:a.value}${h}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(E,{source:P,size:"16"}),c("span",{children:s.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},G=({order:s})=>{var e;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(e=s==null?void 0:s.coupons)==null?void 0:e.map((t,n)=>c("div",{className:"order-cost-summary-content__description--header",children:c("span",{children:t.code})},`${t==null?void 0:t.code}${n}`))})},R=({translations:s,renderTaxAccordion:e,totalAccordionTaxValue:t,order:n})=>{var l,m,o;const[u,r]=g(!1);return e?c(f,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:$,iconClose:j,children:i(D,{onStateChange:r,title:s.accordionTitle,secondaryText:c(v,{children:u?null:c(d,{weight:"normal",amount:t,currency:(m=n==null?void 0:n.totalTax)==null?void 0:m.currency})}),renderContentWhenClosed:!1,children:[(o=n==null?void 0:n.taxes)==null?void 0:o.map((a,h)=>{var y,p,x;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:a==null?void 0:a.title}),c("p",{children:c(d,{weight:"normal",amount:(y=a==null?void 0:a.amount)==null?void 0:y.value,currency:(p=a==null?void 0:a.amount)==null?void 0:p.currency})})]},`${(x=a==null?void 0:a.amount)==null?void 0:x.value}${h}`)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:s.accordionTotalTax}),c("p",{children:c(d,{weight:"normal",amount:t,currency:n.totalTax.currency,size:"medium"})})]})]})}):c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--tax",children:i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.tax}),c(d,{currency:(l=n==null?void 0:n.totalTax)==null?void 0:l.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},J=({translations:s,shoppingOrdersDisplaySubtotal:e,order:t})=>{var n,u,r,l;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--total",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.total}),c(d,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(u=t==null?void 0:t.grandTotal)==null?void 0:u.value,weight:"bold",size:"medium"})]}),e.taxExcluded&&e.taxIncluded?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:s.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.currency,amount:((l=t==null?void 0:t.grandTotal)==null?void 0:l.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},K=({translations:s,loading:e,storeConfig:t,order:n,withHeader:u=!0})=>{var p,x,O,w,T,L,M;if(e||!n)return c(A,{});console.log("OrderCostSummaryContent",n);const r=((p=n==null?void 0:n.totalGiftcard)==null?void 0:p.value)??0,l=((x=n.totalGiftcard)==null?void 0:x.currency)??"",m=((O=n.subtotalInclTax)==null?void 0:O.value)??0,o=((w=n.subtotalExclTax)==null?void 0:w.value)??0,a=((T=n.totalShipping)==null?void 0:T.value)??0,h=!!((L=n==null?void 0:n.taxes)!=null&&L.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),y=h?(M=n==null?void 0:n.taxes)==null?void 0:M.reduce((N,C)=>{var H;return+((H=C==null?void 0:C.amount)==null?void 0:H.value)+N},0):0;return i(I,{variant:"secondary",className:Z(["order-cost-summary-content"]),children:[u?c(k,{title:s.headerText}):null,i("div",{className:"order-cost-summary-content__wrapper",children:[c(q,{translations:s,order:n,subtotalInclTax:m,subtotalExclTax:o,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(F,{translations:s,order:n,totalShipping:a,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(U,{translations:s,order:n,totalGiftcardValue:r,totalGiftcardCurrency:l}),c(G,{order:n}),c(R,{order:n,translations:s,renderTaxAccordion:h,totalAccordionTaxValue:y}),c(J,{translations:s,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})};export{mt as OrderCostSummary,mt as default};