From a8629824f9dd33c0d2c479879aeddd997cc8017f Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 26 Dec 2024 12:41:55 +0100 Subject: [PATCH] Manually drop order build with transform and order products list refactoring --- .../__dropins__/storefront-order/LICENSE.md | 127 ------------------ .../confirmCancelOrder.d.ts | 18 +-- .../confirmGuestReturn.d.ts | 19 +-- .../api/helpers/initializeOrderDetails.d.ts | 4 +- .../api/initialize/initialize.d.ts | 6 +- .../chunks/CartSummaryItem.js | 2 +- .../chunks/ReturnsListContent.js | 2 +- .../storefront-order/chunks/getStoreConfig.js | 2 +- .../storefront-order/chunks/initialize.js | 22 +-- .../storefront-order/chunks/network-error.js | 2 +- .../chunks/requestGuestReturn.js | 2 +- .../chunks/transform-attributes-form.js | 2 +- .../chunks/useGetStoreConfig.js | 2 +- .../storefront-order/configs/mock.config.d.ts | 3 +- .../containers/CreateReturn.js | 2 +- .../containers/CustomerDetails.js | 2 +- .../containers/OrderCostSummary.js | 2 +- .../containers/OrderHeader.js | 2 +- .../containers/OrderProductList.js | 2 +- .../containers/OrderSearch.js | 2 +- .../containers/OrderStatus.js | 2 +- .../data/models/order-details.d.ts | 26 +++- .../data/models/store-config.d.ts | 2 +- .../transforms/transform-order-details.d.ts | 4 +- .../hooks/containers/useOrderSearch.d.ts | 1 + .../lib/categorizeProducts.d.ts | 22 ++- .../types/api/getOrderDetails.types.d.ts | 8 +- .../types/createReturn.types.d.ts | 4 +- .../types/orderCostSummary.types.d.ts | 4 +- 29 files changed, 96 insertions(+), 202 deletions(-) delete mode 100644 scripts/__dropins__/storefront-order/LICENSE.md diff --git a/scripts/__dropins__/storefront-order/LICENSE.md b/scripts/__dropins__/storefront-order/LICENSE.md deleted file mode 100644 index f1ee7eb99b..0000000000 --- a/scripts/__dropins__/storefront-order/LICENSE.md +++ /dev/null @@ -1,127 +0,0 @@ -Last Updated: 28 October 2024 - -ADOBE COMMERCE DROP-IN LICENSE AGREEMENT - -applicable to Adobe Commerce Customers - -**Effective Date:** first date you download or use the Drop-in - -NOTICE TO USER: The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in. - -Your access to and use of the Drop-in is governed by the Adobe Enterprise Licensing Terms previously agreed to by you and Adobe or an authorized Adobe Reseller in a separate agreement. If you have not previously agreed to licensing terms then your installation and use of the Drop-in is subject to the current applicable Adobe Enterprise Licensing Terms available at . You agree that this agreement will have the same effect as any written negotiated agreement signed by you. - -By downloading, installing or making use of any portion of the Drop-in, you accept and agree to be bound by all the terms and conditions of this agreement including all terms incorporated herein by reference. - -This agreement is enforceable against any person or entity that installs and uses the Drop-in and any person or entity (e.g., system integrator, consultant or contractor) that installs or uses the drop-in on another person's or entity's behalf (e.g., Adobe Customer). - -Notice to U.S. Government End Users: Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States. - -**ADOBE COMMERCE DROP-IN LICENSE AGREEMENT** - -applicable to Developers - -**Effective Date:** first date you download or use the Drop-in - -The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in. - -**AGREED TERMS AND CONDITIONS** - -1. **DEFINITIONS**. - - 1.1 “**Adobe**” means collectively, Adobe Inc., a company incorporated in Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose, California USA 95110-2704, U.S.A. (“**Adobe US**”) and Adobe Systems Software Ireland, company incorporated in Ireland, having a place of business 4-6 Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland (“**Adobe Ireland**”).__ - - 1.2 “**Adobe Product(s)**” means software applications, programs and other technologies not included in or with the Drop-in which are or may be made available by Adobe for licensing to the general public. This agreement does not govern use of Adobe Products. See the end user license agreement accompanying an Adobe Product for terms governing its use. - - 1.3 “**Developer Product(s)**” means any software application(s), program(s) and other teconolog(y/ies) you develop with use of the Drop-in to function or interoperate with Adobe Products. - - 1.4 “**Intellectual Property Rights**” means copyright, moral rights, trademark, trade dress, patent, trade secret, unfair competition, and any other intellectual and proprietary rights. - - 1.5 “**Adobe Commerce Drop-in**” or “Drop-in” means all items comprising the application and all associated materials licensed to you by Adobe as part of the Drop-in, including all Drop-in system files, tools, programs and utilities, as well as any plug-ins or other application programming interfaces, header or JAR files (“**API**”), sample images, sounds, or similar assets (“**Content** **Files**”), software code samples, runtimes and libraries, including any portion(s) that is modified by you, or merged or incorporated with your Developer Products (“**Sample Code**”), and any related documentation, technical specifications, notes and explanatory materials, as well any modifications, updates, upgrades, or copies of, any of the foregoing items, that may be made available by Adobe, whether online or recorded on media, or manually downloaded by you. - -2. **LICENSES GRANTED TO YOU**. - - 2.1 **Drop-in**. Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to install and use the Drop-in solely for your internal design, development and testing of your Developer Products, subject further to the requirements and limitations below. - - 2.2 **API.** Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to use the API only as provided in or by the applicable specification and to distribute the API solely in, with, and on the same media as, your Developer Products. For clarification, you may not modify the API. - - 2.3 **Content Files**. You may not use, modify, reproduce or distribute any of the Content Files. For the avoidance of doubt, the Content Files are included as examples only. You acquire no rights to the Content Files. - - 2.4 **Sample Code.** Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to use, modify, merge, and redistribute (in object code form only) all or any portions of the Sample Code solely as part of, and as necessary to properly implement, the Drop-in in your Developer Products. All and any portion of the Sample Code that is modified or merged by you in your Developer Products is subject to the terms of this agreement. - -3. **SCOPE OF LICENSE; LIMITATIONS AND RESTRICTIONS** - - 3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than the Adobe-approved platform. - - 3.2 Third-Party Software. The Drop-ins may contain third-party software, subject to additional terms and conditions, available at ; and - - 3.3 You may not modify, port, adapt, creative derivate works, redistribute, or translate any portion of this Drop-in; or add or delete any Drop-in program files that would in any way result in modifying the functionality or appearance of any element of the Adobe Products. - - 3.4 You may not reverse engineer, decompile, disassemble, or otherwise attempt to discover the source code of, any portion of the Drop-in, except and only to the extent that applicable laws of the jurisdiction where you are located grant you the right to decompile the Drop-in in order to obtain information necessary to render the Drop-in interoperable with other software; in which case you must first request the information from Adobe in writing and Adobe may, in its discretion, either provide such information to you or impose reasonable conditions, including reasonable fees, on your use of the Drop-in to ensure that Adobe’s and its licensors’ Intellectual Proprietary Rights in the Drop-in are protected. - - 3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell, resale, sublicense, assign or transfer all, or any component parts of the Drop-in, or any of your rights in the Drop-in, nor authorize any portion of the Drop-in to be copied onto another’s device, computer or platform, including on a service bureau basis to other providers (i.e., volume printing, banking, payroll service providers, etc) who provide you free or fee-based business services. - -4. **VIRAL OPEN SOURCE SOFTWARE AND SERVICES** - - You are not license to (and you agree that you will not) merge, integrate or use the Drop-in with any Viral Open Source Software or Viral Service, or otherwise take any action that could require disclosure, distribution, or licensing of all or any part of the Drop-in in source code form for any purpose whatsoever. For purposes of this Section, “**Viral Open Source Software**” means software licensed under the GNU General Public License, the GNU Affero General Public License (AGPL), the GNU Lesser General Public License (LGPL), or any other license terms that would require, or condition your use, modification, or distribution of such licensed software on the disclosure, distribution, or licensing of any other software in source code form, for the purpose of making derivative works, or at no charge, and “**Viral Service**” means any service that contains any viruses, Trojan horses, worms, time bombs, cancelbots or other computer programming routines that are intended to damage, detrimentally interfere with, surreptitiously intercept, expropriate or deprive owners’ possession of any system, data or personal information, or that in any way violates any law, statute, ordinance, regulation or rights (including any law, regulations or rights respecting intellectual property, computer spyware, privacy, export control, unfair competition, antidiscrimination or false advertising), or otherwise interferes with the operability of Adobe Products or third-party programs or software. - -5. **NON-BLOCKING OF ADOBE DEVELOPMENT** - - You acknowledge that Adobe is currently developing or may develop technologies and Adobe Products in the future that have, or may have, design or functionality similar to Developer Products that you may develop based on the license granted to you in this agreement. Nothing in this agreement will impair, limit or curtail Adobe’s right to continue with its development, maintenance or distribution of Adobe Products. You agree that you will not assert in any way any patent owned by you arising out of or in connection with your use of the Drop-in, or any Drop-in modifications made by you, against Adobe, its customers, subsidiaries or affiliates, or any of their customers, direct or indirect, agents and contractors for the manufacture, use, import, license, offer for sale, or sale of any Adobe Products. - -6. **OWNERSHIP; INTELLECTUAL PROPERTY RIGHTS** - - 6.1 The items contained in the Drop-in are the Intellectual Property of Adobe and its licensors and are protected by United States copyright and patent law, international treaty provisions and applicable laws of the country in which it is being used. Adobe and its licensors reserve all rights not expressly granted to you under this agreement, and retain all right, title, and interest in the Drop-in, including all Intellectual Property Rights. - - 6.2 The Drop-in, or any of its component parts, may be supplied to you with certain accompanying proprietary notices, including patent, copyright and trademark notices. You agree to protect all copyright and other ownership interests of Adobe and its licensors in the Drop-in supplied to you under this agreement; to preserve exactly (and not remove or alter) all proprietary notices displayed in or on the Drop-in; to reproduce the same proprietary notices in all copies you make of any portion of the Drop-in. - - 6.3 You agree to include in your Developer Products Adobe’s copyright notices, wherever such notices are customarily posted, in substantially the following form: _Portions of software used to develop this product copyrighted by Adobe and its licensors. All Rights Reserved_. - - 6.4 Nothing in this agreement gives you a right to use the name, logo or trademarks of Adobe or its licensors to market your Developer Products. - -7. **CONFIDENTIAL INFORMATION** - - With respect to the API, and any portion, included in the Drop-in (for purposes of this Section, “**Adobe Confidential Information**”), you will treat the Adobe Confidential Information, and exercise the same degree of care to protect it, as you afford to your own confidential information. Your obligations under this Section will terminate when you can document that (a) the Adobe Confidential Information was in the public domain at or subsequent to the time Adobe communicated or provided it to you with no fault of your own; (b) your employees or agents developed independently without reference to any Adobe Confidential Information Adobe communicated or provided to you; or (c) your communication of Adobe Confidential Information was in response to a valid order by a court or other governmental body, was otherwise required by law, or was necessary to establish the rights of a party under this agreement. - -8. **TERM; TERMINATION** - - This agreement will commence on the Effective Date and will continue unless terminated. Adobe may terminate this agreement immediately upon notice to you, and without judicial intervention, if you fail to comply with any term of its terms. You may terminate this agreement at any time by discontinuing all your use(s) of the Drop-in and you agree to destroying or removing all full and partial copies of the Drop-in from your computer. If requested by Adobe, you must demonstrate proof of your compliance with the terms of this Section. In the event of termination, the terms of this agreement that, by their nature, are meant to survive termination, including all terms relating to viral open source software and services, ownership, confidential information, indemnity obligations and procedures, disclaimers of warranty, limitations on and exclusions of remedies and damages, dispute resolution, and waiver, will survive termination of this agreement. - -9. **DISCLAIMER OF WARRANTY; LIMITATION OF LIABILITY** - - You expressly understand and agree that, to the maximum extent permitted by applicable law: - - 9.1 **Use OF THE DROP-IN is entirely at your own risk. The Drop-in is provided by Adobe “AS-IS” and with all faults. Adobe and its licensors are not liable to you or anyone else for any special, incidental, indirect, consequential, or punitive damages whatsoever (even if Adobe has been advised of the possibility of such damages), including (a) damages resulting from loss of use, data, or profits, whether or not foreseeable, (b) damages based on any theory of liability, including breach of contract or warranty, negligence or other tortious action, or (c) damages arising from any other claim arising out of or in connection with your use of the Drop-in.** - - 9.2 **Adobe’s total liability in any matter arising out of or related to these terms is limited to US $100. This limitation will apply even if Adobe has been advised of the possibility of such damages and regardless of any failure of the essential purpose of any limited remedy.** - -10. **INDEMNIFICATION** - - To the maximum extent permitted by law, you agree to indemnify Adobe, its subsidiaries, affiliates, officers, agents, employees, partners, licensors, or suppliers from any claim or demand, including reasonable attorneys’ fees, that arise from the use and distribution of your Developer Products that contain or are based upon any portion of the Drop-in, or from your violation of the terms of this agreement. - -11. **DISPUTE RESOLUTION** - - 11.1 **Choice of Law.** If you are a resident of North America (or if your organization is headquartered in North America), your relationship is with Adobe Systems Incorporated, a United States company, and the Drop-in is governed by the law of California, U.S.A. If you reside outside of North America, your relationship is with Adobe Systems Software Ireland Limited, and the Drop-in is governed by the law of Ireland. - - 11.2 **Venue.** You agree that any claim or dispute you may have against Adobe must be resolved by a court located in Santa Clara County, California, United States of America. You agree to submit to the personal jurisdiction of the courts located in Santa Clara County, California, United States of America when the laws of California apply, and the courts of Dublin, Ireland, when the laws of Ireland applies, for the purpose of litigating such claims or disputes. The parties specifically disclaim the U.N. Convention on Contracts for the International Sale of Goods. - - 11.3 **Injunctive Relief.** Notwithstanding the foregoing, in the event of your or others’ unauthorized access to or use of the Drop-in in violation of this Agreement, you agree that Adobe is entitled to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction. - -12. **EXPORT RULES** - - The Drop-in and your use of the Drop-in are subject to U.S. and international laws, restrictions, and regulations that may govern the import, export, and use of the Drop-in. You agree to comply with all such laws, restrictions, and regulations. - -13. **NOTICE TO U.S. GOVERNMENT END USERS** - - Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States. - -14. **GENERAL PROVISIONS** - - 14.1 **Severability.** If it turns out that a particular term is not enforceable, the unenforceability of that term will not affect any other terms. - - 14.2 **Modification; Waiver.** No provision of this agreement will be deemed to have been modified or waived by any act or acquiescence on the part of Adobe, its agents, or employees, but only by any instrument in writing, signed by an authorized officer of Adobe. - - 14.3 **English Version.** The English language version of this agreement will be the version used when interpreting or construing its terms. - - 14.4 **Entire Agreement.** This Agreement is the entire agreement, superseding any prior written or oral agreements, between you and Adobe relating to the Drop-in. - -Adobe Commerce Drop-in License Agreement_en_US-20241028_v1 diff --git a/scripts/__dropins__/storefront-order/api/confirmCancelOrder/confirmCancelOrder.d.ts b/scripts/__dropins__/storefront-order/api/confirmCancelOrder/confirmCancelOrder.d.ts index d9e243dd3c..0228b612dd 100644 --- a/scripts/__dropins__/storefront-order/api/confirmCancelOrder/confirmCancelOrder.d.ts +++ b/scripts/__dropins__/storefront-order/api/confirmCancelOrder/confirmCancelOrder.d.ts @@ -1,16 +1,4 @@ -/******************************************************************** - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const confirmCancelOrder: (orderId: string, confirmationKey: string) => Promise; +import { OrderDataModel } from '../../data/models'; + +export declare const confirmCancelOrder: (orderId: string, confirmationKey: string) => Promise; //# sourceMappingURL=confirmCancelOrder.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts index 91a6069529..7a02106015 100644 --- a/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts +++ b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts @@ -1,17 +1,4 @@ -/******************************************************************** - * ADOBE CONFIDENTIAL - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const confirmGuestReturn: (orderId: string, confirmationKey: string) => Promise; +import { OrderDataModel } from '../../data/models'; + +export declare const confirmGuestReturn: (orderId: string, confirmationKey: string) => Promise; //# sourceMappingURL=confirmGuestReturn.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/helpers/initializeOrderDetails.d.ts b/scripts/__dropins__/storefront-order/api/helpers/initializeOrderDetails.d.ts index 46bd510494..332b8b3fab 100644 --- a/scripts/__dropins__/storefront-order/api/helpers/initializeOrderDetails.d.ts +++ b/scripts/__dropins__/storefront-order/api/helpers/initializeOrderDetails.d.ts @@ -1,4 +1,4 @@ -import { OrderDataModel } from '../../data/models'; +import { ConfigProps } from '../initialize'; -export declare const initializeOrderDetails: (config: Record | undefined) => Promise; +export declare const initializeOrderDetails: (config: ConfigProps) => Promise; //# sourceMappingURL=initializeOrderDetails.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts index c5ac724da0..79486207c5 100644 --- a/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts @@ -2,15 +2,17 @@ import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib'; import { Lang } from '@dropins/tools/types/elsie/src/i18n'; import { CustomerOrdersReturnModel, OrderDataModel, RequestReturnModel } from '../../data/models'; -type ConfigProps = { +export type ConfigProps = { langDefinitions?: Lang; models?: { OrderDataModel?: Model; CustomerOrdersReturnModel?: Model; RequestReturnModel?: Model; }; + orderRef?: string; + returnRef?: string; + orderData?: OrderDataModel | null; }; export declare const initialize: Initializer; export declare const config: import('@dropins/tools/types/elsie/src/lib').Config; -export {}; //# sourceMappingURL=initialize.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js b/scripts/__dropins__/storefront-order/chunks/CartSummaryItem.js index 97f5fb2f5a..534605d7ac 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 i,jsxs as S,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{Price as g,Image as C,CartItem as T,Icon as o,Incrementer as r}from"@dropins/tools/components.js";import{useCallback as K}from"@dropins/tools/preact-hooks.js";import{classes as R}from"@dropins/tools/lib.js";import{O as c}from"./OrderLoaders.js";import*as L from"@dropins/tools/preact-compat.js";const u=E=>L.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...E},L.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"}),L.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"})),ne=({placeholderImage:E="",loading:U,product:e,itemType:A,taxConfig:G,translations:k,disabledIncrementer:I,onQuantity:b,showConfigurableOptions:x,routeProductDetails:N})=>{var Z,j,q,D,P,W,$,z,B,F;const{taxExcluded:O,taxIncluded:V}=G,m=K((s,v,h)=>i(g,{amount:s,currency:v,weight:"normal",...h}),[]),H=K(s=>{var h,y;const v=(h=s==null?void 0:s.product)!=null&&h.thumbnail.url.length?(y=s==null?void 0:s.product)==null?void 0:y.thumbnail.url:E;return i(C,{src:v,alt:s==null?void 0:s.productName,loading:"lazy",width:"90",height:"120"})},[E]);if(!e)return i(c,{});let Q={};const f=A==="cancelled",J=(j=(Z=e==null?void 0:e.product)==null?void 0:Z.stockStatus)==null?void 0:j.includes("IN_STOCK"),l=e==null?void 0:e.giftCard,a=(q=e==null?void 0:e.itemPrices)==null?void 0:q.priceIncludingTax,n=(D=e==null?void 0:e.itemPrices)==null?void 0:D.originalPrice,t=(P=e==null?void 0:e.itemPrices)==null?void 0:P.price,X=e.totalQuantity>1?{quantity:e.totalQuantity}:{},w=e.discounted,M={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...l!=null&&l.senderName?{[k.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.senderEmail?{[k.sender]:l==null?void 0:l.senderEmail}:{},...l!=null&&l.senderName?{[k.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.recipientEmail?{[k.recipient]:l==null?void 0:l.recipientEmail}:{},...l!=null&&l.message?{[k.message]:l==null?void 0:l.message}:{},...e!=null&&e.downloadableLinks?{[`${(W=e==null?void 0:e.downloadableLinks)==null?void 0:W.count} ${k.downloadableCount}`]:($=e==null?void 0:e.downloadableLinks)==null?void 0:$.result}:{}};if(V&&O){const s=m(n==null?void 0:n.value,n==null?void 0:n.currency),v=w?(n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity):(a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity),h=m(v,n==null?void 0:n.currency,{variant:e.discounted?"strikethrough":"default",weight:"bold"}),y=m((a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{sale:!0,weight:"bold"}),Y=m((t==null?void 0:t.value)*e.totalQuantity,t==null?void 0:t.currency,{weight:"bold"});Q={taxExcluded:!0,taxIncluded:void 0,price:s,total:S(_,{children:[h,e.discounted?y:null]}),totalExcludingTax:Y}}else if(!V&&O){const s=m(n==null?void 0:n.value,n==null?void 0:n.currency),v=m((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{variant:w?"strikethrough":"default",weight:"bold"}),h=m(((z=e.price)==null?void 0:z.value)*(e==null?void 0:e.totalQuantity),(B=e.price)==null?void 0:B.currency,{sale:!0,weight:"bold"}),y=m((t==null?void 0:t.value)*(e==null?void 0:e.totalQuantity),t==null?void 0:t.currency,{weight:"bold"});Q={taxExcluded:void 0,taxIncluded:void 0,price:s,total:S(_,{children:[v,w?h:null]}),totalExcludingTax:y}}else if(V&&!O){const s=w?n.value*e.totalQuantity:a.value*e.totalQuantity,v=m(w?n.value:a.value,a==null?void 0:a.currency),h=m(s,a==null?void 0:a.currency,{variant:w?"strikethrough":"default",weight:"bold"}),y=m((a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{sale:!0,weight:"bold"});Q={taxExcluded:void 0,taxIncluded:!0,price:v,total:S(_,{children:[h,w?y:null]})}}return i(T,{loading:U,alert:f&&J?S("span",{children:[i(o,{source:u}),k.outOfStock]}):i(_,{}),configurations:(x==null?void 0:x(M))??M,title:N?i("a",{"data-testid":"product-name",className:R(["cart-summary-item__title",["cart-summary-item__title--strikethrough",f]]),href:N(e),children:e==null?void 0:e.productName}):i("div",{"data-testid":"product-name",className:R(["cart-summary-item__title",["cart-summary-item__title--strikethrough",f]]),children:e==null?void 0:e.productName}),sku:i("div",{children:(F=e==null?void 0:e.product)==null?void 0:F.sku}),...X,image:N?i("a",{href:N(e),children:H(e)}):H(e),...Q,footer:b&&!I?i(r,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:s=>b==null?void 0:b(Number(s)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0})};export{ne as C,u as S}; diff --git a/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js index dd9c2eeb08..64b628a21d 100644 --- a/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js +++ b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as c,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as V}from"@dropins/tools/preact-hooks.js";import{classes as R,Slot as Q}from"@dropins/tools/lib.js";import{IllustratedMessage as n1,Icon as S,Card as U,ContentGrid as a1,Image as c1,Header as J,Pagination as L1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as i1}from"@dropins/tools/preact-compat.js";import"./ShippingStatusCard.js";import{f as T}from"./returnOrdersHelper.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{C as W}from"./OrderLoaders.js";import{c as s1}from"./capitalizeFirst.js";import{Text as X}from"@dropins/tools/i18n.js";const Y=L=>l.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...L},l.createElement("g",{id:"Large"},l.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),l.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},l.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),d1=L=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...L},l.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"#D6D6D6"})),K=({typeList:L,isEmpty:C,minifiedView:g,message:M})=>{const t=i1(()=>{switch(L){case"orders":return{icon:d1,text:r("p",{children:M}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[L,M]);return!C||!L||!t.text?null:r(n1,{className:R(["order-empty-list",t.className,g?"order-empty-list--minified":""]),message:t.text,icon:r(S,{source:t.icon}),"data-testid":"emptyList"})},I={size:"32",stroke:"2"},v1=({placeholderImage:L,minifiedViewKey:C,withReturnNumber:g=!1,withOrderNumber:M=!1,slots:t,pageInfo:i,withReturnsListButton:A=!0,isMobile:$=!1,returnsInMinifiedView:D=1,translations:a={},orderReturns:s=[],minifiedView:h=!1,withHeader:f=!0,withThumbnails:B=!0,selectedPage:k=1,handleSetSelectPage:z,routeReturnDetails:d,routeOrderDetails:v,routeTracking:b,routeReturnsList:x,routeProductDetails:m,loading:y})=>{const F=h?D:s.length,j=m!=null&&m()?"a":"span",H=V(()=>s.slice(0,F).map((e,t1)=>{var G,q;const w=((e==null?void 0:e.items)??[]).reduce((n,u)=>(u.requestQuantity??0)+n,0);return r(U,{variant:"secondary",className:"order-returns-list-content__cards-list",children:c("div",{className:"order-returns-list-content__cards-grid",children:[c("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:T(e.returnStatus)?r(X,{id:`Order.Returns.${C}.returnsList.returnStatus.${T(e.returnStatus)}`}):r("span",{children:s1(e.returnStatus)})}),g?c("p",{children:[a.returnNumber," ",r("a",{href:(d==null?void 0:d({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,M?c("p",{children:[a.orderNumber," ",r("a",{href:(v==null?void 0:v({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(G=e==null?void 0:e.tracking)==null?void 0:G.map((n,u)=>{var _,p;const Z={title:"",number:(n==null?void 0:n.trackingNumber)??"",carrier:((_=n==null?void 0:n.carrier)==null?void 0:_.label)??""},E=b==null?void 0:b(Z),o=`${Z.number}_${u}`;return c("p",{children:[`${a.carrier} `,`${(p=Z.carrier)==null?void 0:p.toLocaleUpperCase()} | `,E?r("a",{href:E,target:"_blank",rel:"noreferrer","data-testid":`${o}_link`,children:n.trackingNumber}):r("span",{"data-testid":`${o}_span`,children:n.trackingNumber})]},o)}),t!=null&&t.ReturnItemsDetails?r(Q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:t==null?void 0:t.ReturnItemsDetails,context:{items:e.items}}):null,!(t!=null&&t.ReturnItemsDetails)&&e.items.length?c("p",{children:[w," ",r(X,{id:`Order.Returns.${C}.returnsList.itemText`,plural:w,fields:{count:w}})]}):null]}),B?r(a1,{maxColumns:$?3:9,emptyGridContent:r(N,{}),className:R(["order-returns-list-content__images",["order-returns-list-content__images-3",$]]),children:(q=e==null?void 0:e.items)==null?void 0:q.map((n,u)=>{var _,p,O,P;const Z=(_=n.thumbnail)==null?void 0:_.label,E=(O=(p=n.thumbnail)==null?void 0:p.url)!=null&&O.length?(P=n.thumbnail)==null?void 0:P.url:L,o=`key_${u}_${n.uid}`;return r(j,{"data-testid":o,href:(m==null?void 0:m(n))??"#",children:r(c1,{alt:Z,src:E,width:85,height:114})},o)})}):null,t!=null&&t.DetailsActionParams?r(Q,{className:"order-returns-list-content__actions","data-testid":"detailsActionParams",name:"DetailsActionParams",slot:t==null?void 0:t.DetailsActionParams,context:{returnOrderItem:e}}):r("a",{href:(d==null?void 0:d({returnNumber:e.returnNumber,token:e.token,orderNumber:e.orderNumber}))??"#",className:"order-returns-list-content__actions",children:r(S,{source:Y,...I})})]})},t1)}),[s,F,C,g,a,M,t,B,$,L,j,b,m,d,v]),r1=V(()=>c(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,y?r(W,{withCard:!1}):c(N,{children:[H,r(K,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),A?r("a",{className:"order-returns-list-content__actions",href:(x==null?void 0:x())??"#",children:r(U,{variant:"secondary",className:"order-returns-list-content__card",children:c("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:a.viewAllOrdersButton}),r(S,{source:Y,...I})]})})}):null]})]}),[x,A,f,a,H,h,s.length,y]),e1=V(()=>c(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,y?r(W,{withCard:!1}):c(N,{children:[r(K,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),H,(i==null?void 0:i.totalPages)>1?r(L1,{totalPages:i==null?void 0:i.totalPages,currentPage:k,onChange:z}):null]})]}),[H,h,s,a,i==null?void 0:i.totalPages,k,z,y,f]);return r("div",{className:"order-returns-list-content",children:h?r1:e1})};export{v1 as R}; +import{jsx as r,jsxs as c,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as V}from"@dropins/tools/preact-hooks.js";import{classes as R,Slot as Q}from"@dropins/tools/lib.js";import{IllustratedMessage as n1,Icon as S,Card as U,ContentGrid as a1,Image as c1,Header as J,Pagination as L1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as i1}from"@dropins/tools/preact-compat.js";import"./ShippingStatusCard.js";import{f as T}from"./returnOrdersHelper.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{C as W}from"./OrderLoaders.js";import{c as s1}from"./capitalizeFirst.js";import{Text as X}from"@dropins/tools/i18n.js";const Y=L=>l.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...L},l.createElement("g",{id:"Large"},l.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),l.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},l.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),d1=L=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...L},l.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"#D6D6D6"})),K=({typeList:L,isEmpty:C,minifiedView:g,message:M})=>{const t=i1(()=>{switch(L){case"orders":return{icon:d1,text:r("p",{children:M}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[L,M]);return!C||!L||!t.text?null:r(n1,{className:R(["order-empty-list",t.className,g?"order-empty-list--minified":""]),message:t.text,icon:r(S,{source:t.icon}),"data-testid":"emptyList"})},I={size:"32",stroke:"2"},v1=({placeholderImage:L,minifiedViewKey:C,withReturnNumber:g=!1,withOrderNumber:M=!1,slots:t,pageInfo:i,withReturnsListButton:A=!0,isMobile:$=!1,returnsInMinifiedView:D=1,translations:a={},orderReturns:s=[],minifiedView:h=!1,withHeader:f=!0,withThumbnails:B=!0,selectedPage:k=1,handleSetSelectPage:z,routeReturnDetails:d,routeOrderDetails:v,routeTracking:b,routeReturnsList:x,routeProductDetails:m,loading:y})=>{const F=h?D:s.length,j=m!=null&&m()?"a":"span",H=V(()=>s.slice(0,F).map((e,t1)=>{var G,q;const w=((e==null?void 0:e.items)??[]).reduce((n,u)=>(u.requestQuantity??0)+n,0);return r(U,{variant:"secondary",className:"order-returns-list-content__cards-list",children:c("div",{className:"order-returns-list-content__cards-grid",children:[c("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:T(e.returnStatus)?r(X,{id:`Order.Returns.${C}.returnsList.returnStatus.${T(e.returnStatus)}`}):r("span",{children:s1(e.returnStatus)})}),g?c("p",{children:[a.returnNumber," ",r("a",{href:(d==null?void 0:d({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,M?c("p",{children:[a.orderNumber," ",r("a",{href:(v==null?void 0:v({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(G=e==null?void 0:e.tracking)==null?void 0:G.map((n,u)=>{var _,p;const Z={title:"",number:(n==null?void 0:n.trackingNumber)??"",carrier:((_=n==null?void 0:n.carrier)==null?void 0:_.label)??""},E=b==null?void 0:b(Z),o=`${Z.number}_${u}`;return c("p",{children:[`${a.carrier} `,`${(p=Z.carrier)==null?void 0:p.toLocaleUpperCase()} | `,E?r("a",{href:E,target:"_blank",rel:"noreferrer","data-testid":`${o}_link`,children:n.trackingNumber}):r("span",{"data-testid":`${o}_span`,children:n.trackingNumber})]},o)}),t!=null&&t.ReturnItemsDetails?r(Q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:t==null?void 0:t.ReturnItemsDetails,context:{items:e.items}}):null,!(t!=null&&t.ReturnItemsDetails)&&e.items.length?c("p",{children:[w," ",r(X,{id:`Order.Returns.${C}.returnsList.itemText`,plural:w,fields:{count:w}})]}):null]}),B?r(a1,{maxColumns:$?3:9,emptyGridContent:r(N,{}),className:R(["order-returns-list-content__images",["order-returns-list-content__images-3",$]]),children:(q=e==null?void 0:e.items)==null?void 0:q.map((n,u)=>{var _,p,O,P;const Z=(_=n.thumbnail)==null?void 0:_.label,E=(O=(p=n.thumbnail)==null?void 0:p.url)!=null&&O.length?(P=n.thumbnail)==null?void 0:P.url:L,o=`key_${u}_${n.uid}`;return r(j,{"data-testid":o,href:(m==null?void 0:m(n))??"#",children:r(c1,{alt:Z,src:E??"",width:85,height:114})},o)})}):null,t!=null&&t.DetailsActionParams?r(Q,{className:"order-returns-list-content__actions","data-testid":"detailsActionParams",name:"DetailsActionParams",slot:t==null?void 0:t.DetailsActionParams,context:{returnOrderItem:e}}):r("a",{href:(d==null?void 0:d({returnNumber:e.returnNumber,token:e.token,orderNumber:e.orderNumber}))??"#",className:"order-returns-list-content__actions",children:r(S,{source:Y,...I})})]})},t1)}),[s,F,C,g,a,M,t,B,$,L,j,b,m,d,v]),r1=V(()=>c(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,y?r(W,{withCard:!1}):c(N,{children:[H,r(K,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),A?r("a",{className:"order-returns-list-content__actions",href:(x==null?void 0:x())??"#",children:r(U,{variant:"secondary",className:"order-returns-list-content__card",children:c("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:a.viewAllOrdersButton}),r(S,{source:Y,...I})]})})}):null]})]}),[x,A,f,a,H,h,s.length,y]),e1=V(()=>c(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,y?r(W,{withCard:!1}):c(N,{children:[r(K,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),H,(i==null?void 0:i.totalPages)>1?r(L1,{totalPages:i==null?void 0:i.totalPages,currentPage:k,onChange:z}):null]})]}),[H,h,s,a,i==null?void 0:i.totalPages,k,z,y,f]);return r("div",{className:"order-returns-list-content",children:h?r1:e1})};export{v1 as R}; diff --git a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js index a164a243a7..a26051bc09 100644 --- a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{f as s,h as i}from"./fetch-graphql.js";function o(e){return e?{baseMediaUrl:e.base_media_url,orderCancellationEnabled:e.order_cancellation_enabled,orderCancellationReasons:e.order_cancellation_reasons,shoppingCartDisplayPrice:e.orders_invoices_credit_memos_display_price,shoppingOrdersDisplaySubtotal:e.orders_invoices_credit_memos_display_subtotal,shoppingOrdersDisplayShipping:e.orders_invoices_credit_memos_display_shipping_amount,shoppingOrdersDisplayGrandTotal:e.orders_invoices_credit_memos_display_grandtotal,shoppingOrdersDisplayFullSummary:e.orders_invoices_credit_memos_display_full_summary,shoppingOrdersDisplayZeroTax:e.orders_invoices_credit_memos_display_zero_tax}:null}const _=` +import{f as s,h as i}from"./fetch-graphql.js";function o(e){return e?{baseMediaUrl:e.base_media_url,orderCancellationEnabled:e.order_cancellation_enabled,orderCancellationReasons:e.order_cancellation_reasons,shoppingOrderDisplayPrice:e.orders_invoices_credit_memos_display_price,shoppingOrdersDisplaySubtotal:e.orders_invoices_credit_memos_display_subtotal,shoppingOrdersDisplayShipping:e.orders_invoices_credit_memos_display_shipping_amount,shoppingOrdersDisplayGrandTotal:e.orders_invoices_credit_memos_display_grandtotal,shoppingOrdersDisplayFullSummary:e.orders_invoices_credit_memos_display_full_summary,shoppingOrdersDisplayZeroTax:e.orders_invoices_credit_memos_display_zero_tax}:null}const _=` query STORE_CONFIG_QUERY { storeConfig { order_cancellation_enabled diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js index c0cf6c4ba5..29acc53caf 100644 --- a/scripts/__dropins__/storefront-order/chunks/initialize.js +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{merge as Q,Initializer as na}from"@dropins/tools/lib.js";import{events as v}from"@dropins/tools/event-bus.js";import{a as ta,h as x}from"./network-error.js";import{PRODUCT_DETAILS_FRAGMENT as K,PRICE_DETAILS_FRAGMENT as j,GIFT_CARD_DETAILS_FRAGMENT as H,ORDER_ITEM_DETAILS_FRAGMENT as J,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as V,ORDER_SUMMARY_FRAGMENT as W,ADDRESS_FRAGMENT as X,RETURNS_FRAGMENT as Z}from"../fragments.js";import{f as m,h as _a}from"./fetch-graphql.js";const ua=a=>a||0,ia=a=>{var n,t,_;return{...a,canonicalUrl:(a==null?void 0:a.canonical_url)||"",urlKey:(a==null?void 0:a.url_key)||"",id:(a==null?void 0:a.uid)||"",name:(a==null?void 0:a.name)||"",sku:(a==null?void 0:a.sku)||"",image:((n=a==null?void 0:a.image)==null?void 0:n.url)||"",productType:(a==null?void 0:a.__typename)||"",thumbnail:{label:((t=a==null?void 0:a.thumbnail)==null?void 0:t.label)||"",url:((_=a==null?void 0:a.thumbnail)==null?void 0:_.url)||""}}},sa=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},la=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(i=>i.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},ea=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,ca=a=>({quantityCanceled:(a==null?void 0:a.quantity_canceled)??0,quantityInvoiced:(a==null?void 0:a.quantity_invoiced)??0,quantityOrdered:(a==null?void 0:a.quantity_ordered)??0,quantityRefunded:(a==null?void 0:a.quantity_refunded)??0,quantityReturned:(a==null?void 0:a.quantity_returned)??0,quantityShipped:(a==null?void 0:a.quantity_shipped)??0,quantityReturnRequested:(a==null?void 0:a.quantity_return_requested)??0}),I=a=>a==null?void 0:a.filter(n=>n.__typename).map(n=>{var T,c,R,O,N,b,h,g,r,D,u,A,y,p,G,f,F,S,C,q,d,k,B,$,U,w,o,P,z,Y;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:i,quantityRefunded:s,quantityReturned:l,quantityShipped:e,quantityReturnRequested:E}=ca(n);return{type:n==null?void 0:n.__typename,eligibleForReturn:n==null?void 0:n.eligible_for_return,productSku:n==null?void 0:n.product_sku,productName:n.product_name,productUrlKey:n.product_url_key,quantityCanceled:t,quantityInvoiced:_,quantityOrdered:i,quantityRefunded:s,quantityReturned:l,quantityShipped:e,quantityReturnRequested:E,id:n==null?void 0:n.id,discounted:((O=(R=(c=(T=n==null?void 0:n.product)==null?void 0:T.price_range)==null?void 0:c.maximum_price)==null?void 0:R.regular_price)==null?void 0:O.value)*(n==null?void 0:n.quantity_ordered)!==((N=n==null?void 0:n.product_sale_price)==null?void 0:N.value)*(n==null?void 0:n.quantity_ordered),total:{value:((b=n==null?void 0:n.product_sale_price)==null?void 0:b.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((h=n==null?void 0:n.product_sale_price)==null?void 0:h.currency)||""},totalInclTax:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(r=n==null?void 0:n.product_sale_price)==null?void 0:r.currency},price:{value:((D=n==null?void 0:n.product_sale_price)==null?void 0:D.value)||0,currency:(u=n==null?void 0:n.product_sale_price)==null?void 0:u.currency},priceInclTax:{value:((A=n==null?void 0:n.product_sale_price)==null?void 0:A.value)||0,currency:(y=n==null?void 0:n.product_sale_price)==null?void 0:y.currency},totalQuantity:ua(n==null?void 0:n.quantity_ordered),regularPrice:{value:(F=(f=(G=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:G.maximum_price)==null?void 0:f.regular_price)==null?void 0:F.value,currency:(d=(q=(C=(S=n==null?void 0:n.product)==null?void 0:S.price_range)==null?void 0:C.maximum_price)==null?void 0:q.regular_price)==null?void 0:d.currency},product:ia(n==null?void 0:n.product),thumbnail:{label:((B=(k=n==null?void 0:n.product)==null?void 0:k.thumbnail)==null?void 0:B.label)||"",url:((U=($=n==null?void 0:n.product)==null?void 0:$.thumbnail)==null?void 0:U.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:((w=n.gift_card)==null?void 0:w.sender_name)||"",senderEmail:((o=n.gift_card)==null?void 0:o.sender_email)||"",recipientEmail:((P=n.gift_card)==null?void 0:P.recipient_email)||"",recipientName:((z=n.gift_card)==null?void 0:z.recipient_name)||"",message:((Y=n.gift_card)==null?void 0:Y.message)||""}:void 0,configurableOptions:sa(n),bundleOptions:n.__typename==="BundleOrderItem"?la(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?ea(n==null?void 0:n.downloadable_links):null}}),L=(a,n)=>{var O,N,b,h,g,r,D,u,A;const t=I(a.items),_=((O=Ea(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],i=n?_.filter(y=>y.returnNumber===n):_,{total:s,...l}=ta({...a,items:t,returns:i},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),e=(N=a==null?void 0:a.payment_methods)==null?void 0:N[0],E=(e==null?void 0:e.type)||"",T=(e==null?void 0:e.name)||"",c=(b=l==null?void 0:l.items)==null?void 0:b.reduce((y,p)=>y+(p==null?void 0:p.totalQuantity),0),R={...s,...l,totalQuantity:c,shipping:{amount:((h=s==null?void 0:s.totalShipping)==null?void 0:h.value)??0,currency:((g=s==null?void 0:s.totalShipping)==null?void 0:g.currency)||"",code:l.shippingMethod??""},payments:[{code:E,name:T}]};return Q(R,(A=(u=(D=(r=M==null?void 0:M.getConfig())==null?void 0:r.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:A.call(u,a))},Ra=(a,n,t)=>{var _,i,s,l,e,E,T;if((l=(s=(i=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:i.orders)==null?void 0:s.items)!=null&&l.length&&a==="orderData"){const c=(T=(E=(e=n==null?void 0:n.data)==null?void 0:e.customer)==null?void 0:E.orders)==null?void 0:T.items[0];return L(c,t)}return null},Ea=a=>{var s,l,e,E,T;if(!((s=a==null?void 0:a.items)!=null&&s.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,i={ordersReturn:[...n].sort((c,R)=>+R.number-+c.number).map(c=>{var r,D;const{order:R,status:O,number:N,created_at:b}=c,h=((D=(r=c==null?void 0:c.shipping)==null?void 0:r.tracking)==null?void 0:D.map(u=>{const{status:A,carrier:y,tracking_number:p}=u;return{status:A,carrier:y,trackingNumber:p}}))??[],g=c.items.map(u=>{var S;const A=u==null?void 0:u.quantity,y=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,G=u==null?void 0:u.uid,f=u==null?void 0:u.order_item,F=((S=I([f]))==null?void 0:S.reduce((C,q)=>q,{}))??{};return{uid:G,quantity:A,status:y,requestQuantity:p,...F}});return{createdReturnAt:b,returnStatus:O,token:R==null?void 0:R.token,orderNumber:R==null?void 0:R.number,returnNumber:N,items:g,tracking:h}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return Q(i,(T=(E=(e=(l=M==null?void 0:M.getConfig())==null?void 0:l.models)==null?void 0:e.CustomerOrdersReturnModel)==null?void 0:E.transformer)==null?void 0:T.call(E,{...n,...t}))},Sa=(a,n)=>{var _,i;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(i=a==null?void 0:a.data)==null?void 0:i.guestOrder;return L(t,n)},Ta=(a,n)=>{var _,i;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(i=a==null?void 0:a.data)==null?void 0:i.guestOrderByToken;return L(t,n)},ya=` +import{merge as P,Initializer as m}from"@dropins/tools/lib.js";import{events as L}from"@dropins/tools/event-bus.js";import{h as z}from"./network-error.js";import{PRODUCT_DETAILS_FRAGMENT as Y,PRICE_DETAILS_FRAGMENT as Q,GIFT_CARD_DETAILS_FRAGMENT as K,ORDER_ITEM_DETAILS_FRAGMENT as j,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as V,ORDER_SUMMARY_FRAGMENT as X,ADDRESS_FRAGMENT as H,RETURNS_FRAGMENT as J}from"../fragments.js";import{f as W,h as o}from"./fetch-graphql.js";const I=n=>n||0,r=n=>{var i,_,u,l,a,s,T,E,p;return{__typename:(n==null?void 0:n.__typename)||"",uid:(n==null?void 0:n.uid)||"",onlyXLeftInStock:(n==null?void 0:n.only_x_left_in_stock)??0,stockStatus:(n==null?void 0:n.stock_status)??"",priceRange:{maximumPrice:{regularPrice:{currency:((u=(_=(i=n==null?void 0:n.price_range)==null?void 0:i.maximum_price)==null?void 0:_.regular_price)==null?void 0:u.currency)??"",value:((s=(a=(l=n==null?void 0:n.price_range)==null?void 0:l.maximum_price)==null?void 0:a.regular_price)==null?void 0:s.value)??0}}},canonicalUrl:(n==null?void 0:n.canonical_url)??"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)??"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((T=n==null?void 0:n.image)==null?void 0:T.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((E=n==null?void 0:n.thumbnail)==null?void 0:E.label)||"",url:((p=n==null?void 0:n.thumbnail)==null?void 0:p.url)||""}}},d=n=>{if(!n||!("selected_options"in n))return;const i={};for(const _ of n.selected_options)i[_.label]=_.value;return i},nn=n=>{const i=n==null?void 0:n.map(u=>({uid:u.uid,label:u.label,values:u.values.map(l=>l.product_name).join(", ")})),_={};return i==null||i.forEach(u=>{_[u.label]=u.values}),Object.keys(_).length>0?_:null},_n=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(i=>i.title).join(", ")}:null,un=n=>({quantityCanceled:(n==null?void 0:n.quantity_canceled)??0,quantityInvoiced:(n==null?void 0:n.quantity_invoiced)??0,quantityOrdered:(n==null?void 0:n.quantity_ordered)??0,quantityRefunded:(n==null?void 0:n.quantity_refunded)??0,quantityReturned:(n==null?void 0:n.quantity_returned)??0,quantityShipped:(n==null?void 0:n.quantity_shipped)??0,quantityReturnRequested:(n==null?void 0:n.quantity_return_requested)??0}),ln=n=>({firstName:(n==null?void 0:n.firstname)??"",lastName:(n==null?void 0:n.lastname)??"",middleName:(n==null?void 0:n.middlename)??""}),$=n=>{const{firstName:i,lastName:_,middleName:u}=ln(n);return{firstName:i,lastName:_,middleName:u,city:(n==null?void 0:n.city)??"",company:(n==null?void 0:n.company)??"",country:(n==null?void 0:n.country)??"",countryCode:(n==null?void 0:n.country_code)??"",fax:(n==null?void 0:n.fax)??"",postCode:(n==null?void 0:n.postcode)??"",prefix:(n==null?void 0:n.prefix)??"",region:(n==null?void 0:n.region)??"",regionId:(n==null?void 0:n.region_id)??"",street:(n==null?void 0:n.street)??[],suffix:(n==null?void 0:n.suffix)??"",telephone:(n==null?void 0:n.telephone)??"",vatId:(n==null?void 0:n.vat_id)??"",customAttributes:(n==null?void 0:n.custom_attributes)??[]}},cn=n=>{const i={value:0,currency:"USD"};return{grandTotal:(n==null?void 0:n.grand_total)??i,totalGiftcard:(n==null?void 0:n.total_giftcard)??i,subtotalExclTax:(n==null?void 0:n.subtotal_excl_tax)??i,subtotalInclTax:(n==null?void 0:n.subtotal_incl_tax)??i,taxes:(n==null?void 0:n.taxes)??[],totalTax:(n==null?void 0:n.total_tax)??i,totalShipping:(n==null?void 0:n.total_shipping)??i,discounts:(n==null?void 0:n.discounts)??[]}},w=n=>{const i={value:0,currency:"USD"},_=(n==null?void 0:n.prices)??{};return{price:(_==null?void 0:_.price)??i,priceIncludingTax:(_==null?void 0:_.price_including_tax)??i,originalPrice:(_==null?void 0:_.original_price)??i,originalPriceIncludingTax:(_==null?void 0:_.original_price_including_tax)??i,discounts:(_==null?void 0:_.discounts)??[]}},tn=n=>{var i,_,u,l,a;return{senderName:((i=n.gift_card)==null?void 0:i.sender_name)||"",senderEmail:((_=n.gift_card)==null?void 0:_.sender_email)||"",recipientEmail:((u=n.gift_card)==null?void 0:u.recipient_email)||"",recipientName:((l=n.gift_card)==null?void 0:l.recipient_name)||"",message:((a=n.gift_card)==null?void 0:a.message)||""}},an=n=>{var i,_,u,l;return{label:((_=(i=n==null?void 0:n.product)==null?void 0:i.thumbnail)==null?void 0:_.label)||"",url:((l=(u=n==null?void 0:n.product)==null?void 0:u.thumbnail)==null?void 0:l.url)||""}},Z=n=>{var E,p,c,R,F,q,v,e,k,O,f,t,y,g,b,N,S,M;const{quantityCanceled:i,quantityInvoiced:_,quantityOrdered:u,quantityRefunded:l,quantityReturned:a,quantityShipped:s,quantityReturnRequested:T}=un(n);return{selectedOptions:(n==null?void 0:n.selected_options)??[],productSalePrice:n==null?void 0:n.product_sale_price,status:(n==null?void 0:n.status)??"",type:n==null?void 0:n.__typename,eligibleForReturn:(n==null?void 0:n.eligible_for_return)??!1,productSku:(n==null?void 0:n.product_sku)??"",productName:(n==null?void 0:n.product_name)??"",productUrlKey:(n==null?void 0:n.product_url_key)??"",quantityCanceled:i,quantityInvoiced:_,quantityOrdered:u,quantityRefunded:l,quantityReturned:a,quantityShipped:s,quantityReturnRequested:T,id:n==null?void 0:n.id,discounted:((E=n==null?void 0:n.prices)==null?void 0:E.original_price.value)*(n==null?void 0:n.quantity_ordered)>((p=n==null?void 0:n.prices)==null?void 0:p.price.value)*(n==null?void 0:n.quantity_ordered),total:{value:((c=n==null?void 0:n.product_sale_price)==null?void 0:c.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((R=n==null?void 0:n.product_sale_price)==null?void 0:R.currency)||""},totalInclTax:{value:((F=n==null?void 0:n.product_sale_price)==null?void 0:F.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(q=n==null?void 0:n.product_sale_price)==null?void 0:q.currency},price:{value:((v=n==null?void 0:n.product_sale_price)==null?void 0:v.value)||0,currency:(e=n==null?void 0:n.product_sale_price)==null?void 0:e.currency},prices:w(n),itemPrices:w(n),priceInclTax:{value:((k=n==null?void 0:n.product_sale_price)==null?void 0:k.value)||0,currency:(O=n==null?void 0:n.product_sale_price)==null?void 0:O.currency},totalQuantity:I(n==null?void 0:n.quantity_ordered),regularPrice:{value:(g=(y=(t=(f=n==null?void 0:n.product)==null?void 0:f.price_range)==null?void 0:t.maximum_price)==null?void 0:y.regular_price)==null?void 0:g.value,currency:(M=(S=(N=(b=n==null?void 0:n.product)==null?void 0:b.price_range)==null?void 0:N.maximum_price)==null?void 0:S.regular_price)==null?void 0:M.currency},product:r(n==null?void 0:n.product),thumbnail:an(n),giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?tn(n):void 0,configurableOptions:d(n),bundleOptions:n.__typename==="BundleOrderItem"?nn(n.bundle_options):null,downloadableLinks:n.__typename==="DownloadableOrderItem"?_n(n==null?void 0:n.downloadable_links):null}},U=n=>n==null?void 0:n.filter(i=>i.__typename).map(i=>Z(i)),sn=n=>({token:(n==null?void 0:n.token)??"",email:(n==null?void 0:n.email)??"",status:(n==null?void 0:n.status)??"",number:(n==null?void 0:n.number)??"",id:(n==null?void 0:n.id)??"",carrier:n.carrier??"",coupons:(n==null?void 0:n.applied_coupons)??[],orderDate:(n==null?void 0:n.order_date)??"",isVirtual:(n==null?void 0:n.is_virtual)??!1,availableActions:(n==null?void 0:n.available_actions)??[],orderStatusChangeDate:(n==null?void 0:n.order_status_change_date)??"",shippingMethod:(n==null?void 0:n.shipping_method)??""}),B=(n,i)=>{var t,y,g,b,N,S,M,G,C;const _=sn(n),u=$(n==null?void 0:n.billing_address),l=$(n==null?void 0:n.shipping_address),a=(t=n.shipments)==null?void 0:t.map(h=>({...h,items:h.items.map(A=>({id:A.id,productName:A.product_name,productSku:A.product_sku,quantityShipped:A.quantity_shipped,orderItem:Z(A.order_item)}))})),s=U(n.items),T=((y=En(n==null?void 0:n.returns))==null?void 0:y.ordersReturn)??[],E=i?T.filter(h=>h.returnNumber===i):T,p=U(n.items_eligible_for_return),c=cn(n==null?void 0:n.total),R=(g=n==null?void 0:n.payment_methods)==null?void 0:g[0],F=n==null?void 0:n.shipping_method,q=s==null?void 0:s.reduce((h,A)=>h+(A==null?void 0:A.totalQuantity),0),v={amount:((b=c==null?void 0:c.totalShipping)==null?void 0:b.value)??0,currency:((N=c==null?void 0:c.totalShipping)==null?void 0:N.currency)||"",code:(_==null?void 0:_.shippingMethod)??""},e=[{code:(R==null?void 0:R.type)??"",name:(R==null?void 0:R.name)??""}],k=c==null?void 0:c.subtotalExclTax,O=c==null?void 0:c.subtotalInclTax,f={..._,...c,subtotalExclTax:k,subtotalInclTax:O,billingAddress:u,shippingAddress:l,shipments:a,items:s,returns:E,itemsEligibleForReturn:p,totalQuantity:q,shippingMethod:F,shipping:v,payments:e};return P(f,(C=(G=(M=(S=x==null?void 0:x.getConfig())==null?void 0:S.models)==null?void 0:M.OrderDataModel)==null?void 0:G.transformer)==null?void 0:C.call(G,n))},Rn=(n,i,_)=>{var u,l,a,s,T,E,p;if((s=(a=(l=(u=i==null?void 0:i.data)==null?void 0:u.customer)==null?void 0:l.orders)==null?void 0:a.items)!=null&&s.length&&n==="orderData"){const c=(p=(E=(T=i==null?void 0:i.data)==null?void 0:T.customer)==null?void 0:E.orders)==null?void 0:p.items[0];return B(c,_)}return null},En=n=>{var a,s,T,E,p;if(!((a=n==null?void 0:n.items)!=null&&a.length))return null;const i=n==null?void 0:n.items,_=n==null?void 0:n.page_info,l={ordersReturn:[...i].sort((c,R)=>+R.number-+c.number).map(c=>{var O,f;const{order:R,status:F,number:q,created_at:v}=c,e=((f=(O=c==null?void 0:c.shipping)==null?void 0:O.tracking)==null?void 0:f.map(t=>{const{status:y,carrier:g,tracking_number:b}=t;return{status:y,carrier:g,trackingNumber:b}}))??[],k=c.items.map(t=>{var G;const y=t==null?void 0:t.quantity,g=t==null?void 0:t.status,b=t==null?void 0:t.request_quantity,N=t==null?void 0:t.uid,S=t==null?void 0:t.order_item,M=((G=U([S]))==null?void 0:G.reduce((C,h)=>h,{}))??{};return{uid:N,quantity:y,status:g,requestQuantity:b,...M}});return{createdReturnAt:v,returnStatus:F,token:R==null?void 0:R.token,orderNumber:R==null?void 0:R.number,returnNumber:q,items:k,tracking:e}}),..._?{pageInfo:{pageSize:_.page_size,totalPages:_.total_pages,currentPage:_.current_page}}:{}};return P(l,(p=(E=(T=(s=x==null?void 0:x.getConfig())==null?void 0:s.models)==null?void 0:T.CustomerOrdersReturnModel)==null?void 0:E.transformer)==null?void 0:p.call(E,{...i,..._}))},Gn=(n,i)=>{var u,l;if(!((u=n==null?void 0:n.data)!=null&&u.guestOrder))return null;const _=(l=n==null?void 0:n.data)==null?void 0:l.guestOrder;return B(_,i)},Tn=(n,i)=>{var u,l;if(!((u=n==null?void 0:n.data)!=null&&u.guestOrderByToken))return null;const _=(l=n==null?void 0:n.data)==null?void 0:l.guestOrderByToken;return B(_,i)},pn=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders(filter: { number: { eq: $orderNumber } }) { @@ -104,15 +104,15 @@ import{merge as Q,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${Y} + ${Q} ${K} ${j} - ${H} - ${J} ${V} - ${W} ${X} - ${Z} -`,pa=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await m(ya,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(i=>Ra(t??"orderData",i,n)).catch(x),Aa=` + ${H} + ${J} +`,yn=async({orderId:n,returnRef:i,queryType:_,returnsPageSize:u=50})=>await W(pn,{method:"GET",cache:"force-cache",variables:{orderNumber:n,pageSize:u}}).then(l=>Rn(_??"orderData",l,i)).catch(z),gn=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -201,12 +201,12 @@ import{merge as Q,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${Y} + ${Q} ${K} ${j} - ${H} - ${J} ${V} - ${W} ${X} - ${Z} -`,ra=async(a,n)=>await m(Aa,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>{var _;return(_=t.errors)!=null&&_.length&&t.errors[0].message==="Please login to view the order."?_a(t.errors):Ta(t,n)}).catch(x),Da="orderData",Oa=async a=>{var l;const n=typeof(a==null?void 0:a.orderRef)=="string"?a==null?void 0:a.orderRef:"",t=typeof(a==null?void 0:a.returnRef)=="string"?a==null?void 0:a.returnRef:"",_=n&&typeof(a==null?void 0:a.orderRef)=="string"&&((l=a==null?void 0:a.orderRef)==null?void 0:l.length)>20,i=(a==null?void 0:a.orderData)??null;if(i){v.emit("order/data",{...i,returnNumber:t});return}if(!n)return;const s=_?await ra(n,t):await pa({orderId:n,returnRef:t,queryType:Da});s?v.emit("order/data",{...s,returnNumber:t}):v.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},aa=new na({init:async a=>{const n={};aa.config.setConfig({...n,...a}),Oa(a).catch(console.error)},listeners:()=>[]}),M=aa.config;export{L as a,Sa as b,ra as c,M as d,pa as g,aa as i,Ea as t}; + ${H} + ${J} +`,bn=async(n,i)=>await W(gn,{method:"GET",cache:"no-cache",variables:{token:n}}).then(_=>{var u;return(u=_.errors)!=null&&u.length&&_.errors[0].message==="Please login to view the order."?o(_.errors):Tn(_,i)}).catch(z),An="orderData",hn=async n=>{var s;const i=typeof(n==null?void 0:n.orderRef)=="string"?n==null?void 0:n.orderRef:"",_=typeof(n==null?void 0:n.returnRef)=="string"?n==null?void 0:n.returnRef:"",u=i&&typeof(n==null?void 0:n.orderRef)=="string"&&((s=n==null?void 0:n.orderRef)==null?void 0:s.length)>20,l=(n==null?void 0:n.orderData)??null;if(l){L.emit("order/data",{...l,returnNumber:_});return}if(!i)return;const a=u?await bn(i,_):await yn({orderId:i,returnRef:_,queryType:An});a?L.emit("order/data",{...a,returnNumber:_}):L.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},D=new m({init:async n=>{const i={};D.config.setConfig({...i,...n}),hn(n??{}).catch(console.error)},listeners:()=>[]}),x=D.config;export{B as a,Gn as b,bn as c,x as d,yn as g,D as i,En as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/network-error.js b/scripts/__dropins__/storefront-order/chunks/network-error.js index ba4dbbfadd..e0ff0e7147 100644 --- a/scripts/__dropins__/storefront-order/chunks/network-error.js +++ b/scripts/__dropins__/storefront-order/chunks/network-error.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{events as f}from"@dropins/tools/event-bus.js";const l=r=>r.replace(/_([a-z])/g,(s,e)=>e.toUpperCase()),i=r=>r.replace(/([A-Z])/g,s=>`_${s.toLowerCase()}`),u=(r,s,e)=>{const c=["string","boolean","number"],a=s==="camelCase"?l:i;return Array.isArray(r)?r.map(o=>c.includes(typeof o)||o===null?o:typeof o=="object"?u(o,s,e):o):r!==null&&typeof r=="object"?Object.entries(r).reduce((o,[t,n])=>{const p=e&&e[t]?e[t]:a(t);return o[p]=c.includes(typeof n)||n===null?n:u(n,s,e),o},{}):r},C=r=>{const s=r instanceof DOMException&&r.name==="AbortError",e=r.name==="PlaceOrderError";throw!s&&!e&&f.emit("order/error",{source:"auth",type:"network",error:r.message}),r};export{u as a,l as c,C as h}; +import{events as t}from"@dropins/tools/event-bus.js";const s=r=>{const e=r instanceof DOMException&&r.name==="AbortError",o=r.name==="PlaceOrderError";throw!e&&!o&&t.emit("order/error",{source:"auth",type:"network",error:r.message}),r};export{s as h}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js index 4ace23884e..40053ed7cf 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as i,a as _}from"./network-error.js";import{f as o,h as s}from"./fetch-graphql.js";import{t as d}from"./transform-attributes-form.js";import{REQUEST_RETURN_ORDER_FRAGMENT as m}from"../fragments.js";import{merge as l}from"@dropins/tools/lib.js";import{d as f}from"./initialize.js";const h=r=>{var a,n,E,c,R,T;if(!((n=(a=r==null?void 0:r.data)==null?void 0:a.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,u={...t,createdAt:e};return l(u,(T=(R=(c=(E=f.getConfig())==null?void 0:E.models)==null?void 0:c.RequestReturnModel)==null?void 0:R.transformer)==null?void 0:T.call(R,r.data.requestReturn.return))},U=` +import{h as i}from"./network-error.js";import{f as o,h as s}from"./fetch-graphql.js";import{t as d,a as _}from"./transform-attributes-form.js";import{REQUEST_RETURN_ORDER_FRAGMENT as m}from"../fragments.js";import{merge as l}from"@dropins/tools/lib.js";import{d as f}from"./initialize.js";const h=r=>{var a,n,E,c,R,T;if(!((n=(a=r==null?void 0:r.data)==null?void 0:a.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,u={...t,createdAt:e};return l(u,(T=(R=(c=(E=f.getConfig())==null?void 0:E.models)==null?void 0:c.RequestReturnModel)==null?void 0:R.transformer)==null?void 0:T.call(R,r.data.requestReturn.return))},U=` query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { attributesList(entityType: $entityType) { items { diff --git a/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js b/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js index 19aed95cc1..a5294c1df4 100644 --- a/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js +++ b/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as i,a as d}from"./network-error.js";const l=n=>{let s=[];for(const e of n)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let o=2;o<=e.multiline_count;o++){const c={...e,name:`${e.code}_${o}`,code:`${e.code}_${o}`,id:`${e.code}_${o}`};s.push(c)}return s},f=(n=[])=>{var c;if(!(n!=null&&n.length))return[];const s=(c=n.filter(t=>{var r;return!((r=t.frontend_input)!=null&&r.includes("HIDDEN"))}))==null?void 0:c.map(({code:t,...r})=>{const u=t!=="country_id"?t:"country_code";return{...r,name:u,id:u,code:u}}),e=l(s);return[...s,...e].map(t=>{const r=i(t.code);return d({...t,customUpperCode:r},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((t,r)=>t.orderNumber-r.orderNumber)};export{f as t}; +const l=r=>r.replace(/_([a-z])/g,(t,n)=>n.toUpperCase()),a=r=>r.replace(/([A-Z])/g,t=>`_${t.toLowerCase()}`),i=(r,t,n)=>{const s=["string","boolean","number"],c=t==="camelCase"?l:a;return Array.isArray(r)?r.map(e=>s.includes(typeof e)||e===null?e:typeof e=="object"?i(e,t,n):e):r!==null&&typeof r=="object"?Object.entries(r).reduce((e,[o,u])=>{const f=n&&n[o]?n[o]:c(o);return e[f]=s.includes(typeof u)||u===null?u:i(u,t,n),e},{}):r},d=r=>{let t=[];for(const n of r)if(!(n.frontend_input!=="MULTILINE"||n.multiline_count<2))for(let s=2;s<=n.multiline_count;s++){const c={...n,name:`${n.code}_${s}`,code:`${n.code}_${s}`,id:`${n.code}_${s}`};t.push(c)}return t},p=(r=[])=>{var c;if(!(r!=null&&r.length))return[];const t=(c=r.filter(e=>{var o;return!((o=e.frontend_input)!=null&&o.includes("HIDDEN"))}))==null?void 0:c.map(({code:e,...o})=>{const u=e!=="country_id"?e:"country_code";return{...o,name:u,id:u,code:u}}),n=d(t);return[...t,...n].map(e=>{const o=l(e.code);return i({...e,customUpperCode:o},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((e,o)=>e.orderNumber-o.orderNumber)};export{i as a,l as c,p as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js b/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js index 4398ad0c43..d63ee78dc3 100644 --- a/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js +++ b/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{useState as i,useEffect as s}from"@dropins/tools/preact-hooks.js";import{g as f}from"./getStoreConfig.js";const c=()=>{const[n,e]=i(null);return s(()=>{const o=sessionStorage.getItem("orderStoreConfig"),r=o?JSON.parse(o):null;r?e(r):f().then(t=>{t&&(sessionStorage.setItem("orderStoreConfig",JSON.stringify(t)),e(t))})},[]),n};export{c as u}; +import{useState as f,useEffect as g}from"@dropins/tools/preact-hooks.js";import{g as S}from"./getStoreConfig.js";const C=()=>{const[s,r]=f(null);return g(()=>{var n;const e="orderStoreConfigPromise",i=sessionStorage.getItem("orderStoreConfig");if(i){const t=JSON.parse(i);r(t)}else{const t=window;t[e]||(t[e]=S().then(o=>(o&&sessionStorage.setItem("orderStoreConfig",JSON.stringify(o)),o))),(n=t[e])==null||n.then(o=>{o&&r(o)})}},[]),s};export{C as u}; diff --git a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts index 1e9c4f96cd..dac1da45b1 100644 --- a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts +++ b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts @@ -178,6 +178,7 @@ export declare const transformMockOrderInput: { customer: { orders: { items: { + uid: string; available_actions: string[]; status: string; number: string; @@ -3734,7 +3735,7 @@ export declare const storeConfigMock: { orderCancellationReasons: { description: string; }[]; - shoppingCartDisplayPrice: number; + shoppingOrderDisplayPrice: number; shoppingOrdersDisplaySubtotal: number; shoppingOrdersDisplayShipping: number; shoppingOrdersDisplayGrandTotal: boolean; diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index df04cdc644..5c7747ee6a 100644 --- a/scripts/__dropins__/storefront-order/containers/CreateReturn.js +++ b/scripts/__dropins__/storefront-order/containers/CreateReturn.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as G,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as P,useCallback as F}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as ne}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as re,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../fragments.js";import"../chunks/initialize.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.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"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:l})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...l}),[v,x]=w("products"),[h,d]=w(!0),[g,f]=w([]),[C,t]=w([]),[m,e]=w([]),c=D([]);c.current.length!==g.length&&(c.current=g.map((n,p)=>c.current[p]||K())),P(()=>{const n=ne.on("order/data",p=>{var u;R(p);const O=Y(p);e(O),L(((u=A("orderRef"))==null?void 0:u.length)>20),d(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),P(()=>{re("RMA_ITEM").then(n=>{n!=null&&n.length&&(t(n),d(!1))})},[]);const y=F(n=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(n==null?void 0:n.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(n==null?void 0:n.productSku)):[...p,n])},[]),S=F(n=>{x(n),i(),n==="products"&&f([])},[i]),E=F((n,p)=>{const O=g.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:n}:u);f(O)},[g]),Q=F(async(n,p)=>{if(!p)return;d(!0);const O={orderUid:o.id,contactEmail:o.email},u=I(c);k?ae({token:A("orderRef"),contactEmail:O.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...O,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),d(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:h,formsRef:c,attributesList:C,selectedProductList:g,itemsEligibleForReturn:m,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:Q}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=F(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const k=r($,{source:he[l.type]});s({...l,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},je=({className:a,orderData:s,slots:i,onSuccess:l,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),h=J(),{order:d,itemsEligibleForReturn:g,formsRef:f,attributesList:C,steps:t,loading:m,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:l,onError:k,handleSetInLineAlert:x});if(m)return r("div",{children:r(oe,{})});if(!m&&!C.length)return r("div",{});const Q=(h==null?void 0:h.baseMediaUrl)??"",n={products:r(be,{itemsEligibleForReturn:g,placeholderImage:Q,taxConfig:ie((h==null?void 0:h.shoppingCartDisplayPrice)??0),slots:i,translations:R,loading:m,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:r(ke,{placeholderImage:Q,slots:i,formsRef:f,loading:m,fieldsConfig:C,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:r(fe,{translations:R,routeReturnSuccess:L,orderData:d}),error:null};return N("div",{className:B(["order-create-return",a]),children:[r(W,{title:R.headerText}),v.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,n[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:s.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),r(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:l,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:h})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((d,g)=>{const{quantityReturnRequested:f,quantityShipped:C,eligibleForReturn:t}=d,m=o.some(y=>(y==null?void 0:y.productSku)===d.productSku&&d.eligibleForReturn),e=C===f&&t||!t,c=C-f===0?f:C-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(G,{"data-testid":`key_${g}`,name:`key_${g}`,checked:m,disabled:e,onChange:()=>{R({...d,currentReturnOrderQuantity:1})}}),r(ue,{placeholderImage:a,loading:l,product:{...d,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!m,onQuantity:c>1?y=>{x(y,d.productSku)}:void 0}),r(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},d.id)}),r("li",{className:"order-return-order-product-list__item",children:r(M,{type:"button",onClick:()=>h("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:l,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:h,formRef:d,handleChange:g,handleBlur:f,handleSubmit:C}=U({fieldsConfig:ee(L,l==null?void 0:l.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:d,onSubmit:C,name:"returnReasonForm",children:[l.map((t,m)=>{var p,O,u,b,T,q;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,m),S=`${t==null?void 0:t.id}_${m}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,Q={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(O=t==null?void 0:t.downloadableLinks)==null?void 0:O.result}:{}},n=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[r(V,{loading:k,title:r("div",{"data-testid":"product-name",children:(T=t==null?void 0:t.product)==null?void 0:T.name}),sku:r("div",{children:c==null?void 0:c.sku}),image:r(Z,{src:n,alt:((q=c==null?void 0:c.thumbnail)==null?void 0:q.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:Q}),r("form",{name:S,ref:i==null?void 0:i.current[m],"data-quantity":E,children:r(z,{className:"className",loading:k,fields:y,onChange:g,onBlur:f,errors:h,values:x})})]},t.id)}),r(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[r(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),r(M,{children:o.submit})]})})]})};export{je as CreateReturn,je as default}; +import{jsx as n,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as G,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as P,useCallback as F}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as re}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as ne,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../fragments.js";import"../chunks/initialize.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.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"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:l})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...l}),[v,x]=w("products"),[h,d]=w(!0),[g,f]=w([]),[C,t]=w([]),[m,e]=w([]),c=D([]);c.current.length!==g.length&&(c.current=g.map((r,p)=>c.current[p]||K())),P(()=>{const r=re.on("order/data",p=>{var u;R(p);const O=Y(p);e(O),L(((u=A("orderRef"))==null?void 0:u.length)>20),d(!1)},{eager:!0});return()=>{r==null||r.off()}},[]),P(()=>{ne("RMA_ITEM").then(r=>{r!=null&&r.length&&(t(r),d(!1))})},[]);const y=F(r=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(r==null?void 0:r.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(r==null?void 0:r.productSku)):[...p,r])},[]),S=F(r=>{x(r),i(),r==="products"&&f([])},[i]),E=F((r,p)=>{const O=g.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:r}:u);f(O)},[g]),Q=F(async(r,p)=>{if(!p)return;d(!0);const O={orderUid:o.id,contactEmail:o.email},u=I(c);k?ae({token:A("orderRef"),contactEmail:O.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...O,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),d(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:h,formsRef:c,attributesList:C,selectedProductList:g,itemsEligibleForReturn:m,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:Q}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=F(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const k=n($,{source:he[l.type]});s({...l,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},je=({className:a,orderData:s,slots:i,onSuccess:l,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),h=J(),{order:d,itemsEligibleForReturn:g,formsRef:f,attributesList:C,steps:t,loading:m,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:l,onError:k,handleSetInLineAlert:x});if(m)return n("div",{children:n(oe,{})});if(!m&&!C.length)return n("div",{});const Q=(h==null?void 0:h.baseMediaUrl)??"",r={products:n(be,{itemsEligibleForReturn:g,placeholderImage:Q,taxConfig:ie((h==null?void 0:h.shoppingOrderDisplayPrice)??0),slots:i,translations:R,loading:m,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:n(ke,{placeholderImage:Q,slots:i,formsRef:f,loading:m,fieldsConfig:C,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:n(fe,{translations:R,routeReturnSuccess:L,orderData:d}),error:null};return N("div",{className:B(["order-create-return",a]),children:[n(W,{title:R.headerText}),v.heading?n(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,r[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[n("p",{className:"order-return-order-message__title",children:s.successTitle}),n("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),n(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:l,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:h})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((d,g)=>{const{quantityReturnRequested:f,quantityShipped:C,eligibleForReturn:t}=d,m=o.some(y=>(y==null?void 0:y.productSku)===d.productSku&&d.eligibleForReturn),e=C===f&&t||!t,c=C-f===0?f:C-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[n(G,{"data-testid":`key_${g}`,name:`key_${g}`,checked:m,disabled:e,onChange:()=>{R({...d,currentReturnOrderQuantity:1})}}),n(ue,{placeholderImage:a,loading:l,product:{...d,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!m,onQuantity:c>1?y=>{x(y,d.productSku)}:void 0}),n(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},d.id)}),n("li",{className:"order-return-order-product-list__item",children:n(M,{type:"button",onClick:()=>h("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:l,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:h,formRef:d,handleChange:g,handleBlur:f,handleSubmit:C}=U({fieldsConfig:ee(L,l==null?void 0:l.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:d,onSubmit:C,name:"returnReasonForm",children:[l.map((t,m)=>{var p,O,u,b,T,q;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,m),S=`${t==null?void 0:t.id}_${m}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,Q={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(O=t==null?void 0:t.downloadableLinks)==null?void 0:O.result}:{}},r=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[n(V,{loading:k,title:n("div",{"data-testid":"product-name",children:(T=t==null?void 0:t.product)==null?void 0:T.name}),sku:n("div",{children:c==null?void 0:c.sku}),image:n(Z,{src:r,alt:((q=c==null?void 0:c.thumbnail)==null?void 0:q.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:Q}),n("form",{name:S,ref:i==null?void 0:i.current[m],"data-quantity":E,children:n(z,{className:"className",loading:k,fields:y,onChange:g,onBlur:f,errors:h,values:x})})]},t.id)}),n(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[n(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),n(M,{children:o.submit})]})})]})};export{je as CreateReturn,je as default}; diff --git a/scripts/__dropins__/storefront-order/containers/CustomerDetails.js b/scripts/__dropins__/storefront-order/containers/CustomerDetails.js index 75f96d413f..5bd0339188 100644 --- a/scripts/__dropins__/storefront-order/containers/CustomerDetails.js +++ b/scripts/__dropins__/storefront-order/containers/CustomerDetails.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as c,Fragment as L}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as T,classes as _}from"@dropins/tools/lib.js";import{useMemo as S,useState as k,useEffect as E,useCallback as B}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as z}from"@dropins/tools/event-bus.js";import{c as F}from"../chunks/network-error.js";import{g as q}from"../chunks/getAttributesForm.js";import{Icon as K,Price as G,Card as J,Header as Q}from"@dropins/tools/components.js";import{f as U}from"../chunks/returnOrdersHelper.js";import{f as X}from"../chunks/formatDateToLocale.js";import"../chunks/ShippingStatusCard.js";import*as u from"@dropins/tools/preact-compat.js";import{D as Y}from"../chunks/OrderLoaders.js";import{Text as ee,useText as te}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-attributes-form.js";import"../chunks/getFormValues.js";const re=i=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ne=i=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),O=(i,e)=>{var d;const m=o=>{const s=Array.isArray(o.value)?o.value.join(" "):o==null?void 0:o.value;return o.label?`${o.label}: ${s}`:s};return(d=i[e])==null?void 0:d.map((o,s)=>r("p",{children:m(o)},`${o.value}${s}`))},oe=i=>{var s,t;const e=i&&i.length>0,m=e?(s=i[0])==null?void 0:s.name:"",d=e?(t=i[0])==null?void 0:t.code:"";return{selectedPaymentMethod:m,selectedPaymentMethodCode:d,hasToDisplayPaymentMethod:e&&m!==""}},ie=({loading:i,order:e,withHeader:m=!0,title:d,paymentIconsMap:o={},normalizeAddress:s,translations:t,slots:l})=>{var D,M,A,N;const g=!!(e!=null&&e.returnNumber),n=(D=e==null?void 0:e.returns)==null?void 0:D[0],h=S(()=>({checkmo:re,card:ne,...o}),[o]);if(!e||i)return r(Y,{});const a=(e==null?void 0:e.email)??"",p=(M=e==null?void 0:e.shipping)==null?void 0:M.code,f=(A=e==null?void 0:e.shipping)==null?void 0:A.amount,w=(N=e==null?void 0:e.shipping)==null?void 0:N.currency,x=e==null?void 0:e.payments,{selectedPaymentMethod:P,selectedPaymentMethodCode:y,hasToDisplayPaymentMethod:H}=oe(x),v=h[y],C=O(s,"shippingAddress")??[],b=O(s,"billingAddress")??[],I=c("div",{className:"order-customer-details-content__container-email",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.emailTitle}),r("p",{children:a})]}),V=g?c("div",{className:"order-customer-details-content__container-return-information","data-testid":"returnDetailsBlock",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.returnInformationTitle}),r("div",{className:"order-customer-details-content__container-description",children:r(T,{"data-testid":"OrderReturnInformation",name:"OrderReturnInformation",slot:l==null?void 0:l.OrderReturnInformation,context:n,children:c(L,{children:[c("p",{children:[t.createdReturnAt,r("span",{children:X(n==null?void 0:n.createdReturnAt)})]}),c("p",{children:[t.returnStatusLabel,r(ee,{id:`Order.CustomerDetails.returnStatus.${U(n==null?void 0:n.returnStatus)}`})]}),c("p",{children:[t.orderNumberLabel,r("span",{children:n==null?void 0:n.orderNumber})]})]})})})]}):null,W=C.length?c("div",{className:"order-customer-details-content__container-shipping_address",children:[r("div",{className:"order-customer-details-content__container-title",children:t.shippingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:C})]}):null,j=b.length?c("div",{className:_(["order-customer-details-content__container-billing_address",["order-customer-details-content__container-billing_address--fullwidth",!C.length]]),children:[r("div",{className:"order-customer-details-content__container-title",children:t.billingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:b})]}):null,R=H?c("div",{className:_(["order-customer-details-content__container-payment_methods",["order-customer-details-content__container-payment_methods--fullwidth",!p]]),children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.paymentMethodsTitle}),c("p",{"data-testid":"payment_methods_description",className:_([["order-customer-details-content__container-payment_methods--icon",!!v]]),children:[r(T,{"data-testid":"PaymentMethodIcon",name:"PaymentMethodIcon",slot:l==null?void 0:l.PaymentMethodIcon,context:{selectedPaymentMethodCode:y},children:v?r(K,{source:v}):null}),P]})]}):null,Z=p?c("div",{className:"order-customer-details-content__container-shipping_methods",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.shippingMethodsTitle}),f?c("p",{"data-testid":"shipping_methods_price",children:[r(G,{amount:f,currency:w})," ",p]}):r("p",{"data-testid":"shipping_methods_placeholder",children:t==null?void 0:t.freeShipping})]}):null,$=g?V:c(L,{children:[j,Z,R]});return c(J,{"data-testid":"order-details",variant:"secondary",className:_(["order-customer-details-content"]),children:[m?r(Q,{title:d??(t==null?void 0:t.headerText)}):null,c("div",{className:_(["order-customer-details-content__container",["order-customer-details-content__container--no-margin",C.length||b.length]]),children:[I,W,$]})]})},se=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],ce=({orderData:i})=>{const[e,m]=k(!0),[d,o]=k(i),[s,t]=k([]);E(()=>{const n=z.on("order/data",h=>{o(h)},{eager:!0});return()=>{n==null||n.off()}},[]),E(()=>{q("shortRequest").then(n=>{if(n){const h=n.map(({name:a,orderNumber:p,label:f})=>({name:F(a),orderNumber:p,label:se.includes(a)?null:f}));t(h)}}).finally(()=>{m(!1)})},[]);const l=B(n=>{if(!s.length||!d||!d[n])return[];const h=Object.fromEntries(Object.entries(d[n]).map(([a,p])=>[a.toLowerCase(),p]));return s.filter(({name:a})=>h[a.toLowerCase()]).map(a=>({name:a.name,orderNumber:a.orderNumber,value:h[a.name.toLowerCase()],label:a.label}))},[s,d]),g=S(()=>({billingAddress:l("billingAddress"),shippingAddress:l("shippingAddress")}),[l]);return{order:d,normalizeAddress:g,loading:e}},Ae=({paymentIconsMap:i,orderData:e,title:m,className:d,slots:o})=>{const s=te({emailTitle:"Order.CustomerDetails.email.title",shippingAddressTitle:"Order.CustomerDetails.shippingAddress.title",shippingMethodsTitle:"Order.CustomerDetails.shippingMethods.title",billingAddressTitle:"Order.CustomerDetails.billingAddress.title",paymentMethodsTitle:"Order.CustomerDetails.paymentMethods.title",returnInformationTitle:"Order.CustomerDetails.returnInformation.title",headerText:"Order.CustomerDetails.headerText",freeShipping:"Order.CustomerDetails.freeShipping",createdReturnAt:"Order.CustomerDetails.orderReturnLabels.createdReturnAt",orderNumberLabel:"Order.CustomerDetails.orderReturnLabels.orderNumberLabel",returnStatusLabel:"Order.CustomerDetails.orderReturnLabels.returnStatusLabel"}),{order:t,normalizeAddress:l,loading:g}=ce({orderData:e});return r("div",{className:_(["order-customer-details",d]),children:r(ie,{slots:o,loading:g,order:t,title:m,paymentIconsMap:i,normalizeAddress:l,translations:s})})};export{Ae as CustomerDetails,Ae as default}; +import{jsx as r,jsxs as d,Fragment as L}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as T,classes as _}from"@dropins/tools/lib.js";import{useMemo as S,useState as k,useEffect as E,useCallback as B}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as z}from"@dropins/tools/event-bus.js";import{c as F}from"../chunks/transform-attributes-form.js";import{g as q}from"../chunks/getAttributesForm.js";import{Icon as K,Price as G,Card as J,Header as Q}from"@dropins/tools/components.js";import{f as U}from"../chunks/returnOrdersHelper.js";import{f as X}from"../chunks/formatDateToLocale.js";import"../chunks/ShippingStatusCard.js";import*as u from"@dropins/tools/preact-compat.js";import{D as Y}from"../chunks/OrderLoaders.js";import{Text as ee,useText as te}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";const re=i=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ne=i=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),O=(i,e)=>{var c;const m=o=>{const s=Array.isArray(o.value)?o.value.join(" "):o==null?void 0:o.value;return o.label?`${o.label}: ${s}`:s};return(c=i[e])==null?void 0:c.map((o,s)=>r("p",{children:m(o)},`${o.value}${s}`))},oe=i=>{var s,t;const e=i&&i.length>0,m=e?(s=i[0])==null?void 0:s.name:"",c=e?(t=i[0])==null?void 0:t.code:"";return{selectedPaymentMethod:m,selectedPaymentMethodCode:c,hasToDisplayPaymentMethod:e&&m!==""}},ie=({loading:i,order:e,withHeader:m=!0,title:c,paymentIconsMap:o={},normalizeAddress:s,translations:t,slots:l})=>{var D,M,A,N;const g=!!(e!=null&&e.returnNumber),n=(D=e==null?void 0:e.returns)==null?void 0:D[0],h=S(()=>({checkmo:re,card:ne,...o}),[o]);if(!e||i)return r(Y,{});const a=(e==null?void 0:e.email)??"",p=(M=e==null?void 0:e.shipping)==null?void 0:M.code,f=(A=e==null?void 0:e.shipping)==null?void 0:A.amount,w=(N=e==null?void 0:e.shipping)==null?void 0:N.currency,x=e==null?void 0:e.payments,{selectedPaymentMethod:P,selectedPaymentMethodCode:y,hasToDisplayPaymentMethod:H}=oe(x),v=h[y],C=O(s,"shippingAddress")??[],b=O(s,"billingAddress")??[],I=d("div",{className:"order-customer-details-content__container-email",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.emailTitle}),r("p",{children:a})]}),V=g?d("div",{className:"order-customer-details-content__container-return-information","data-testid":"returnDetailsBlock",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.returnInformationTitle}),r("div",{className:"order-customer-details-content__container-description",children:r(T,{"data-testid":"OrderReturnInformation",name:"OrderReturnInformation",slot:l==null?void 0:l.OrderReturnInformation,context:n,children:d(L,{children:[d("p",{children:[t.createdReturnAt,r("span",{children:X(n==null?void 0:n.createdReturnAt)})]}),d("p",{children:[t.returnStatusLabel,r(ee,{id:`Order.CustomerDetails.returnStatus.${U(n==null?void 0:n.returnStatus)}`})]}),d("p",{children:[t.orderNumberLabel,r("span",{children:n==null?void 0:n.orderNumber})]})]})})})]}):null,W=C.length?d("div",{className:"order-customer-details-content__container-shipping_address",children:[r("div",{className:"order-customer-details-content__container-title",children:t.shippingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:C})]}):null,j=b.length?d("div",{className:_(["order-customer-details-content__container-billing_address",["order-customer-details-content__container-billing_address--fullwidth",!C.length]]),children:[r("div",{className:"order-customer-details-content__container-title",children:t.billingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:b})]}):null,R=H?d("div",{className:_(["order-customer-details-content__container-payment_methods",["order-customer-details-content__container-payment_methods--fullwidth",!p]]),children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.paymentMethodsTitle}),d("p",{"data-testid":"payment_methods_description",className:_([["order-customer-details-content__container-payment_methods--icon",!!v]]),children:[r(T,{"data-testid":"PaymentMethodIcon",name:"PaymentMethodIcon",slot:l==null?void 0:l.PaymentMethodIcon,context:{selectedPaymentMethodCode:y},children:v?r(K,{source:v}):null}),P]})]}):null,Z=p?d("div",{className:"order-customer-details-content__container-shipping_methods",children:[r("div",{className:"order-customer-details-content__container-title",children:t==null?void 0:t.shippingMethodsTitle}),f?d("p",{"data-testid":"shipping_methods_price",children:[r(G,{amount:f,currency:w})," ",p]}):r("p",{"data-testid":"shipping_methods_placeholder",children:t==null?void 0:t.freeShipping})]}):null,$=g?V:d(L,{children:[j,Z,R]});return d(J,{"data-testid":"order-details",variant:"secondary",className:_(["order-customer-details-content"]),children:[m?r(Q,{title:c??(t==null?void 0:t.headerText)}):null,d("div",{className:_(["order-customer-details-content__container",["order-customer-details-content__container--no-margin",C.length||b.length]]),children:[I,W,$]})]})},se=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],ce=({orderData:i})=>{const[e,m]=k(!0),[c,o]=k(i),[s,t]=k([]);E(()=>{const n=z.on("order/data",h=>{o(h)},{eager:!0});return()=>{n==null||n.off()}},[]),E(()=>{q("shortRequest").then(n=>{if(n){const h=n.map(({name:a,orderNumber:p,label:f})=>({name:F(a),orderNumber:p,label:se.includes(a)?null:f}));t(h)}}).finally(()=>{m(!1)})},[]);const l=B(n=>{if(!s.length||!c||!c[n])return[];const h=c[n]?Object.fromEntries(Object.entries(c[n]).map(([a,p])=>[a.toLowerCase(),p])):{};return s.filter(({name:a})=>h[a.toLowerCase()]).map(a=>({name:a.name,orderNumber:a.orderNumber,value:h[a.name.toLowerCase()],label:a.label}))},[s,c]),g=S(()=>({billingAddress:l("billingAddress"),shippingAddress:l("shippingAddress")}),[l]);return{order:c,normalizeAddress:g,loading:e}},Ae=({paymentIconsMap:i,orderData:e,title:m,className:c,slots:o})=>{const s=te({emailTitle:"Order.CustomerDetails.email.title",shippingAddressTitle:"Order.CustomerDetails.shippingAddress.title",shippingMethodsTitle:"Order.CustomerDetails.shippingMethods.title",billingAddressTitle:"Order.CustomerDetails.billingAddress.title",paymentMethodsTitle:"Order.CustomerDetails.paymentMethods.title",returnInformationTitle:"Order.CustomerDetails.returnInformation.title",headerText:"Order.CustomerDetails.headerText",freeShipping:"Order.CustomerDetails.freeShipping",createdReturnAt:"Order.CustomerDetails.orderReturnLabels.createdReturnAt",orderNumberLabel:"Order.CustomerDetails.orderReturnLabels.orderNumberLabel",returnStatusLabel:"Order.CustomerDetails.orderReturnLabels.returnStatusLabel"}),{order:t,normalizeAddress:l,loading:g}=ce({orderData:e});return r("div",{className:_(["order-customer-details",c]),children:r(ie,{slots:o,loading:g,order:t,title:m,paymentIconsMap:i,normalizeAddress:l,translations:s})})};export{Ae as CustomerDetails,Ae as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js index 18e66d9b0a..a97f335aea 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{shoppingOrderDisplayPrice:o,shoppingOrdersDisplayShipping:a,shoppingOrdersDisplaySubtotal:h,...y}=e;m(p=>({...p,...y,shoppingOrderDisplayPrice: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,{});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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderHeader.js b/scripts/__dropins__/storefront-order/containers/OrderHeader.js index d73431e6fa..ea4ab4300c 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderHeader.js +++ b/scripts/__dropins__/storefront-order/containers/OrderHeader.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as l,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import{Icon as O,Header as d,Button as H}from"@dropins/tools/components.js";import{useState as f,useEffect as p}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import*as c from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as _}from"@dropins/tools/event-bus.js";import{b}from"../chunks/OrderLoaders.js";import{useText as w,Text as L}from"@dropins/tools/i18n.js";const V=e=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},c.createElement("g",{clipPath:"url(#clip0_4797_15077)"},c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),c.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"}),c.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"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_4797_15077"},c.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"}))));function s(e){var r;return{region:{region_id:e!=null&&e.regionId?Number(e==null?void 0:e.regionId):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,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:((r=e==null?void 0:e.customAttributes)==null?void 0:r.map(i=>({attribute_code:i.code,value:i.value})))||[]}}const M=({orderData:e,handleEmailAvailability:r,handleSignUpClick:i})=>{const[t,v]=f(e),[u,N]=f(),[C,h]=f(r?void 0:!0),a=t==null?void 0:t.email,E=i&&t!==void 0&&u===!1&&C===!0?()=>{const o=t.shippingAddress,n=t.billingAddress,A=[{code:"email",defaultValue:t.email},{code:"firstname",defaultValue:(n==null?void 0:n.firstName)??""},{code:"lastname",defaultValue:(n==null?void 0:n.lastName)??""}];let m=[];if(o){const g={...s(o),default_shipping:!0};m=[{...s(n),default_billing:!0},g]}else m=[{...s(n),default_billing:!0,default_shipping:!0}];i({inputsDefaultValueSet:A,addressesData:m})}:void 0;return p(()=>{const o=_.on("authenticated",n=>{N(n)},{eager:!0});return()=>{o==null||o.off()}},[]),p(()=>{const o=_.on("order/data",n=>{v(n)},{eager:!0});return()=>{o==null||o.off()}},[]),p(()=>{r&&u!==void 0&&(u||!a||r(a).then(o=>h(o)).catch(()=>h(!0)))},[u,r,a]),{order:t,onSignUpClickHandler:E}},R=e=>{var t;const{order:r,onSignUpClickHandler:i}=M(e);return l("div",{children:r?l(j,{customerName:(t=r.billingAddress)==null?void 0:t.firstName,onSignUpClick:i,orderNumber:r.number}):l(b,{})})},j=({customerName:e,orderNumber:r,onSignUpClick:i})=>{const t=w({title:l(L,{id:"Order.OrderHeader.title",fields:{name:e}}),defaultTitle:"Order.OrderHeader.defaultTitle",order:l(L,{id:"Order.OrderHeader.order",fields:{order:r}}),createAccountMessage:"Order.OrderHeader.CreateAccount.message",createAccountButton:"Order.OrderHeader.CreateAccount.button"});return k("div",{"data-testid":"order-header",className:"order-header order-header__card",children:[l(O,{source:V,size:"64",className:"order-header__icon"}),l(d,{className:"order-header__title",title:t.title,size:"large",divider:!1,children:e?t.title:t.defaultTitle}),l("p",{className:"order-header__order",children:t.order}),i&&k("div",{className:"order-header-create-account",children:[l("p",{className:"order-header-create-account__message",children:t.createAccountMessage}),l(H,{"data-testid":"create-account-button",className:"order-header-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:i,children:t.createAccountButton})]})]})};export{R as OrderHeader,R as default}; +import{jsx as u,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import{Icon as O,Header as H,Button as d}from"@dropins/tools/components.js";import{useState as f,useEffect as p}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import*as c from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as _}from"@dropins/tools/event-bus.js";import{b}from"../chunks/OrderLoaders.js";import{useText as w,Text as L}from"@dropins/tools/i18n.js";const V=e=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},c.createElement("g",{clipPath:"url(#clip0_4797_15077)"},c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),c.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"}),c.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"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_4797_15077"},c.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"}))));function s(e){var r;return{region:{region_id:e!=null&&e.regionId?Number(e==null?void 0:e.regionId):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,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:((r=e==null?void 0:e.customAttributes)==null?void 0:r.map(i=>({attribute_code:i.code,value:i.value})))||[]}}const M=({orderData:e,handleEmailAvailability:r,handleSignUpClick:i})=>{const[t,N]=f(e),[l,v]=f(),[C,h]=f(r?void 0:!0),a=t==null?void 0:t.email,E=i&&t!==void 0&&l===!1&&C===!0?()=>{const o=t.shippingAddress,n=t.billingAddress,A=[{code:"email",defaultValue:t.email},{code:"firstname",defaultValue:(n==null?void 0:n.firstName)??""},{code:"lastname",defaultValue:(n==null?void 0:n.lastName)??""}];let m=[];if(o){const g={...s(o),default_shipping:!0};m=[{...s(n),default_billing:!0},g]}else m=[{...s(n),default_billing:!0,default_shipping:!0}];i({inputsDefaultValueSet:A,addressesData:m})}:void 0;return p(()=>{const o=_.on("authenticated",n=>{v(n)},{eager:!0});return()=>{o==null||o.off()}},[]),p(()=>{const o=_.on("order/data",n=>{N(n)},{eager:!0});return()=>{o==null||o.off()}},[]),p(()=>{r&&l!==void 0&&(l||!a||r(a).then(o=>h(o)).catch(()=>h(!0)))},[l,r,a]),{order:t,onSignUpClickHandler:E}},R=e=>{var t;const{order:r,onSignUpClickHandler:i}=M(e);return r?u(j,{customerName:(t=r.billingAddress)==null?void 0:t.firstName,onSignUpClick:i,orderNumber:r.number}):u(b,{})},j=({customerName:e,orderNumber:r,onSignUpClick:i})=>{const t=w({title:u(L,{id:"Order.OrderHeader.title",fields:{name:e}}),defaultTitle:"Order.OrderHeader.defaultTitle",order:u(L,{id:"Order.OrderHeader.order",fields:{order:r}}),createAccountMessage:"Order.OrderHeader.CreateAccount.message",createAccountButton:"Order.OrderHeader.CreateAccount.button"});return k("div",{"data-testid":"order-header",className:"order-header order-header__card",children:[u(O,{source:V,size:"64",className:"order-header__icon"}),u(H,{className:"order-header__title",title:t.title,size:"large",divider:!1,children:e?t.title:t.defaultTitle}),u("p",{className:"order-header__order",children:t.order}),i&&k("div",{className:"order-header-create-account",children:[u("p",{className:"order-header-create-account__message",children:t.createAccountMessage}),u(d,{"data-testid":"create-account-button",className:"order-header-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:i,children:t.createAccountButton})]})]})};export{R as OrderHeader,R as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderProductList.js b/scripts/__dropins__/storefront-order/containers/OrderProductList.js index 2c8ad403ba..79a477f851 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderProductList.js +++ b/scripts/__dropins__/storefront-order/containers/OrderProductList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as a,jsxs as g}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{Card as q,Header as R}from"@dropins/tools/components.js";import{useState as P,useEffect as S,useMemo as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as b}from"../chunks/useGetStoreConfig.js";import{Fragment as x}from"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{s as Q}from"../chunks/setTaxStatus.js";import{a as k}from"../chunks/OrderLoaders.js";import{C as G}from"../chunks/CartSummaryItem.js";import{useText as M}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const v=({orderData:n})=>{const[u,i]=P(!0),[e,r]=P(n);return S(()=>{const t=N.on("order/data",o=>{r(o),i(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),{loading:u,order:e}},Y=({className:n,orderData:u,withHeader:i,showConfigurableOptions:e,routeProductDetails:r})=>{const t=b(),{loading:o,order:d}=v({orderData:u});return a("div",{className:h(["order-order-product-list",n]),children:a(I,{loading:o,placeholderImage:(t==null?void 0:t.baseMediaUrl)??"",taxConfig:Q((t==null?void 0:t.shoppingCartDisplayPrice)??0),order:d,withHeader:i,showConfigurableOptions:e,routeProductDetails:r})})},w=n=>{const u=(n==null?void 0:n.items)??[],i=u.filter(t=>(t==null?void 0:t.eligibleForReturn)&&(t==null?void 0:t.quantityReturnRequested)).map(t=>({...t,totalQuantity:t.quantityReturnRequested})),e=new Map(i.map(t=>[t.id,t])),r=u.map(t=>{const o=e.get(t==null?void 0:t.id);if(o){const d=t.totalQuantity-o.quantityReturnRequested;return d===0?null:{...t,totalQuantity:d}}return t}).filter(t=>t!==null);return{returnedList:i,canceledItems:r==null?void 0:r.filter(t=>t.quantityCanceled),nonCanceledItems:r==null?void 0:r.filter(t=>!t.quantityCanceled)}},I=({placeholderImage:n,loading:u,taxConfig:i,order:e=null,withHeader:r=!0,showConfigurableOptions:t,routeProductDetails:o})=>{const d=!!(e!=null&&e.returnNumber),c=M({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",returned:"Order.OrderProductListContent.returnedTitle",refunded:"Order.OrderProductListContent.refundedTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),L=T(()=>{var p,f;if(!e)return[];if(!d){const{returnedList:s,canceledItems:m,nonCanceledItems:O}=w(e);return[{type:"returned",list:s,title:c.returned},{type:"cancelled",list:m,title:c.cancelled},{type:"allItems",list:O,title:c.allOrders}].filter(C=>{var y;return((y=C==null?void 0:C.list)==null?void 0:y.length)>0})}return[{type:"returned",list:((f=(p=e.returns.find(s=>s.returnNumber===(e==null?void 0:e.returnNumber)))==null?void 0:p.items)==null?void 0:f.map(s=>({...s,totalQuantity:s.requestQuantity})))??[],title:c.returned}]},[e,d,c]);return e?L.every(l=>l.list.length===0)?null:a(q,{variant:"secondary",className:"order-order-product-list-content",children:L.map((l,p)=>{var s;const f=l.list.reduce((m,{totalQuantity:O})=>O+m,0);return g(x,{children:[r?a(R,{title:`${l.title} (${f})`}):null,a("ul",{className:"order-order-product-list-content__items",children:(s=l.list)==null?void 0:s.map(m=>a("li",{"data-testid":"order-product-list-content-item",children:a(G,{placeholderImage:n,loading:u,product:m,itemType:l.type,taxConfig:i,translations:c,showConfigurableOptions:t,routeProductDetails:o})},m.id))})]},p)})}):a(k,{})};export{Y as OrderProductList,Y as default}; +import{jsx as d,jsxs as g}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{Card as q,Header as R}from"@dropins/tools/components.js";import{useState as P,useEffect as S,useMemo as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as b}from"../chunks/useGetStoreConfig.js";import{Fragment as x}from"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{s as Q}from"../chunks/setTaxStatus.js";import{a as k}from"../chunks/OrderLoaders.js";import{C as G}from"../chunks/CartSummaryItem.js";import{useText as M}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const v=({orderData:s})=>{const[i,o]=P(!0),[e,r]=P(s);return S(()=>{const t=N.on("order/data",l=>{r(l),o(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),{loading:i,order:e}},Y=({className:s,orderData:i,withHeader:o,showConfigurableOptions:e,routeProductDetails:r})=>{const t=b(),{loading:l,order:a}=v({orderData:i});return d("div",{className:h(["order-order-product-list",s]),children:d(I,{loading:l,placeholderImage:(t==null?void 0:t.baseMediaUrl)??"",taxConfig:Q((t==null?void 0:t.shoppingOrderDisplayPrice)??0),order:a,withHeader:o,showConfigurableOptions:e,routeProductDetails:r})})},w=s=>{const i=(s==null?void 0:s.items)??[],o=i.filter(t=>(t==null?void 0:t.eligibleForReturn)&&(t==null?void 0:t.quantityReturnRequested)).map(t=>({...t,totalQuantity:t.quantityReturnRequested})),e=new Map(o.map(t=>[t.id,t])),r=i.map(t=>{const l=e.get(t==null?void 0:t.id);if(l){const a=t.totalQuantity-l.quantityReturnRequested;return a===0?null:{...t,totalQuantity:a}}return t}).filter(t=>t!==null);return{returnedList:o,canceledItems:r==null?void 0:r.filter(t=>t.quantityCanceled),nonCanceledItems:r==null?void 0:r.filter(t=>!t.quantityCanceled)}},I=({placeholderImage:s,loading:i,taxConfig:o,order:e=null,withHeader:r=!0,showConfigurableOptions:t,routeProductDetails:l})=>{const a=!!(e!=null&&e.returnNumber),m=M({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",returned:"Order.OrderProductListContent.returnedTitle",refunded:"Order.OrderProductListContent.refundedTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),L=T(()=>{var p,f;if(!e)return[];if(!a){const{returnedList:u,canceledItems:n,nonCanceledItems:O}=w(e);return[{type:"returned",list:u,title:m.returned},{type:"cancelled",list:n,title:m.cancelled},{type:"allItems",list:O,title:m.allOrders}].filter(C=>{var y;return((y=C==null?void 0:C.list)==null?void 0:y.length)>0})}return[{type:"returned",list:((f=(p=e.returns.find(u=>u.returnNumber===(e==null?void 0:e.returnNumber)))==null?void 0:p.items)==null?void 0:f.map(u=>({...u,totalQuantity:u.requestQuantity})))??[],title:m.returned}]},[e,a,m]);return e?L.every(c=>c.list.length===0)?null:d(q,{variant:"secondary",className:"order-order-product-list-content",children:L.map((c,p)=>{var u;const f=c.list.filter(n=>n!==null).reduce((n,{totalQuantity:O})=>O+n,0);return g(x,{children:[r?d(R,{title:`${c.title} (${f})`}):null,d("ul",{className:"order-order-product-list-content__items",children:(u=c.list)==null?void 0:u.filter(n=>n!==null).map(n=>d("li",{"data-testid":"order-product-list-content-item",children:d(G,{placeholderImage:s,loading:i,product:n,itemType:c.type,taxConfig:o,translations:m,showConfigurableOptions:t,routeProductDetails:l})},n.id))})]},p)})}):d(k,{})};export{Y as OrderProductList,Y as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index e391860b18..6fcca23c36 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderSearch.js +++ b/scripts/__dropins__/storefront-order/containers/OrderSearch.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as t,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{classes as M}from"@dropins/tools/lib.js";import{Card as V,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as H}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as B}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as z}from"../chunks/getGuestOrder.js";import{useText as U,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/initialize.js";const X=s=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},w.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"})),Z=({onError:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),n=U({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,i,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[n]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=B(e.target);await z(o).then(m=>{m||u({text:n.invalidSearch,type:"warning"}),N.emit("order/data",m)}).catch(async m=>{var S;let d=!0;s==null||s({error:m.message});const h=r?await x():{email:""};(h==null?void 0:h.email)===(o==null?void 0:o.email)?f(i,{orderRef:o.number}):d=a==null?void 0:a({render:h===null||((S=m==null?void 0:m.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:m.message,type:"warning"})}).finally(()=>{p(!1)})},[r,s,a,i,n.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},ne=({className:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:n}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return t("div",{className:M(["order-order-search",s]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:n})})},j=({onSubmit:s,loading:r,inLineAlert:a,fieldsConfig:i})=>L(V,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(C,{source:X})}):null,t(H,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:i,onSubmit:s,children:t("div",{className:"order-order-search-form__button-container",children:t(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{ne as OrderSearch,ne as default}; +import{jsx as t,jsxs as q}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as V,Icon as k,Button as C}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as U}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as H}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as B}from"../chunks/getGuestOrder.js";import{useText as z,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/initialize.js";const X=s=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},w.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"})),Z=({onError:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),n=z({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,i,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number",isUnique:!1}],[n]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=H(e.target);await B(o).then(m=>{m||u({text:n.invalidSearch,type:"warning"}),N.emit("order/data",m)}).catch(async m=>{var S;let d=!0;s==null||s({error:m.message});const h=r?await x():{email:""};(h==null?void 0:h.email)===(o==null?void 0:o.email)?f(i,{orderRef:o.number}):d=a==null?void 0:a({render:h===null||((S=m==null?void 0:m.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:m.message,type:"warning"})}).finally(()=>{p(!1)})},[r,s,a,i,n.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},ne=({className:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:n}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return t("div",{className:L(["order-order-search",s]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:n})})},j=({onSubmit:s,loading:r,inLineAlert:a,fieldsConfig:i})=>q(M,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(V,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(k,{source:X})}):null,t(U,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:i,onSubmit:s,children:t("div",{className:"order-order-search-form__button-container",children:t(C,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{ne as OrderSearch,ne as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index 1e1d15df87..b58a972aea 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderStatus.js +++ b/scripts/__dropins__/storefront-order/containers/OrderStatus.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as s,Fragment as S,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as $,classes as _}from"@dropins/tools/lib.js";import{Button as P,InLineAlert as B,Modal as V,Card as K,Header as Q}from"@dropins/tools/components.js";import{useState as C,useEffect as k,useCallback as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as J}from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as I}from"@dropins/tools/event-bus.js";import{a as X,c as Y,r as Z}from"../chunks/confirmCancelOrder.js";import{useText as O,Text as M}from"@dropins/tools/i18n.js";import{C as D}from"../chunks/OrderLoaders.js";import{f as ee}from"../chunks/returnOrdersHelper.js";import{f as w}from"../chunks/formatDateToLocale.js";import{c as b}from"../chunks/capitalizeFirst.js";import{r as U}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../fragments.js";import"../chunks/initialize.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(t=>(t.CANCEL="CANCEL",t.RETURN="RETURN",t.REORDER="REORDER",t))(y||{});const re=({className:t,orderData:e,slots:n,routeCreateReturn:r,routeOnSuccess:u,onError:i})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=J(()=>{const c=e==null?void 0:e.availableActions,o=!!(c!=null&&c.length),a=!!(e!=null&&e.returnNumber),m=()=>{U(r,{},e)};return s(S,{children:n!=null&&n.OrderActions?s($,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:e}):s("div",{"data-testid":"availableActionsList",className:_(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!o]]),children:c==null?void 0:c.map(p=>{switch(p){case y.CANCEL:return s(S,{children:a?null:s(ce,{orderRef:(e==null?void 0:e.token)??(e==null?void 0:e.id)})});case y.RETURN:return s(P,{variant:"secondary",onClick:m,children:a?d.createAnotherReturn:d.createReturn});case y.REORDER:return s(S,{children:a?null:s(ie,{orderData:e,onError:i,routeOnSuccess:u,children:d.reorder})})}})})})},[i,e,u,r,n,d]);return s("div",{className:_(["order-order-actions",t]),children:l})},ne=({orderData:t})=>{const[e,n]=C(t),[r,u]=C(t==null?void 0:t.status);return k(()=>{const i=I.on("order/data",d=>{n(d),u(d.status)},{eager:!0});return()=>{i==null||i.off()}},[]),{orderStatus:r,order:e}},H=t=>{const e=new URL(window.location.href);t.forEach(n=>{e.searchParams.has(n)&&e.searchParams.delete(n)}),window.history.replaceState({},document.title,e.toString())},se=({enableOrderCancellation:t})=>{const e=O({cancelOrderHeading:"Order.OrderStatusContent.actions.cancel",confirmGuestReturnHeading:"Order.OrderStatusContent.actions.confirmGuestReturn",orderCancelled:"Order.OrderStatusContent.orderCanceled.message",guestRequestReturnMessage:"Order.OrderStatusContent.actions.confirmGuestReturnMessage"}),[n,r]=C(!1),[u,i]=C(!1),[d,l]=C({heading:"",text:"",status:void 0}),c=T(()=>{r(!0),H(["order_id","confirmation_key","action"])},[]),o=T((a,m,p)=>{l({heading:a,text:m,status:p}),H(["action"])},[]);return k(()=>{const a=new URLSearchParams(window.location.search),m=a.get("order_id")??"",p=a.get("confirmation_key")??"",g=a.get("action")??"";u||!m||!p||!g||(t&&g==="cancel"&&(i(!0),X(m,p).then(()=>{l({heading:e.cancelOrderHeading,text:e.orderCancelled,status:"success"})}).catch(h=>{l({heading:e.cancelOrderHeading,text:h.message,status:"warning"})})),g==="return"&&(i(!0),Y(m,p).then(()=>{l({heading:e.confirmGuestReturnHeading,text:e.guestRequestReturnMessage,status:"success"})}).catch(h=>{l({heading:e.confirmGuestReturnHeading,text:h.message,status:"warning"})})))},[t,e,o,u]),{orderActionStatus:d,isDismissed:n,onDismiss:c}},be=({slots:t,orderData:e,className:n,statusTitle:r,status:u,routeCreateReturn:i,onError:d,routeOnSuccess:l})=>{const{orderStatus:c,order:o}=ne({orderData:e}),a=G(),{orderActionStatus:m,isDismissed:p,onDismiss:g}=se({enableOrderCancellation:a==null?void 0:a.orderCancellationEnabled});return A("div",{className:_(["order-order-status",n]),children:[!p&&(m==null?void 0:m.status)!==void 0?s(B,{style:{marginBottom:"1rem"},heading:m.heading,onDismiss:g,description:m.text,type:m.status}):null,o?s(oe,{title:r,status:u||c,slots:t,orderData:o,routeCreateReturn:i,onError:d,routeOnSuccess:l}):s(D,{withCard:!1})]})},ce=({orderRef:t})=>{const[e,n]=C(!1),r=()=>{n(!0)},u=()=>{n(!1)},i=G(),d=(i==null?void 0:i.orderCancellationReasons)??[],l=c=>c.map((o,a)=>({text:o==null?void 0:o.description,value:a.toString()}));return I.on("order/data",c=>{const o=String(c.status).toLocaleLowerCase();(o==="guest order cancellation requested"||o==="canceled")&&u()}),A(S,{children:[s(P,{variant:"secondary",onClick:r,"data-testid":"cancel-button",children:s(M,{id:"Order.OrderStatusContent.actions.cancel"})}),e&&s(V,{centered:!0,size:"medium",onClose:u,className:"order-order-cancel__modal",title:s("h2",{className:"order-order-cancel__title",children:s(M,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:s(te,{orderRef:t,cancelReasons:l(d)})})]})},N={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested","pending payment":"orderPendingPayment",rejected:"orderRejected",authorized:"orderAuthorized","paypal canceled reversal":"orderPaypalCanceledReversal","pending paypal":"orderPendingPaypal","paypal reversed":"orderPaypalReversed",closed:"orderClosed"},oe=({slots:t,title:e,status:n,orderData:r,routeCreateReturn:u,onError:i,routeOnSuccess:d})=>{var x,E,L;const l=!!(r!=null&&r.returnNumber),c=String(n).toLocaleLowerCase(),o=(x=r==null?void 0:r.returns)==null?void 0:x[0],a=(o==null?void 0:o.returnStatus)??"",m=(o==null?void 0:o.createdReturnAt)??"",p=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),g=O(`Order.OrderStatusContent.${N[c]}.title`),h=O(`Order.OrderStatusContent.${N[c]}.message`),R=O(`Order.OrderStatusContent.${N[c]}.messageWithoutDate`),f=O({title:`Order.OrderStatusContent.returnStatus.${ee(a)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return s("div",{});const q=g!=null&&g.title?g:{title:b(c)},v=h!=null&&h.message?h:p,F=R!=null&&R.messageWithoutDate?R:p,W=r!=null&&r.orderStatusChangeDate?v==null?void 0:v.message.replace("{DATE}",w(r==null?void 0:r.orderStatusChangeDate)):F.messageWithoutDate,j=((L=(E=f==null?void 0:f.returnMessage)==null?void 0:E.replace("{ORDER_CREATE_DATE}",w(r==null?void 0:r.orderDate)))==null?void 0:L.replace("{RETURN_CREATE_DATE}",w(m)))??"",z=l?e??(f.title||b(a)):e??q.title;return A(K,{className:"order-order-status-content",variant:"secondary",children:[s(Q,{title:z}),A("div",{className:"order-order-status-content__wrapper",children:[s("div",{className:_(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(t!=null&&t.OrderActions)]]),children:s("p",{children:l?j:W})}),s(re,{orderData:r,slots:t,routeCreateReturn:u,routeOnSuccess:d,onError:i})]})]})},ie=({onError:t,routeOnSuccess:e,orderData:n,children:r})=>{const[u,i]=C(!1),d=T(()=>{i(!0);const l=n==null?void 0:n.number;Z(l).then(({success:c,userInputErrors:o})=>{c&&U(e,{}),o.length&&(t==null||t(o))}).catch(c=>{t==null||t(c.message)}).finally(()=>{i(!1)})},[n,e,t]);return s(P,{type:"button",disabled:u,variant:"secondary",className:"order-reorder",onClick:d,children:r})};export{be as OrderStatus,be as default}; +import{jsx as s,Fragment as S,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as $,classes as _}from"@dropins/tools/lib.js";import{Button as P,InLineAlert as B,Modal as V,Card as K,Header as Q}from"@dropins/tools/components.js";import{useState as C,useEffect as k,useCallback as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as J}from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as I}from"@dropins/tools/event-bus.js";import{a as X,c as Y,r as Z}from"../chunks/confirmCancelOrder.js";import{useText as O,Text as M}from"@dropins/tools/i18n.js";import{C as D}from"../chunks/OrderLoaders.js";import{f as ee}from"../chunks/returnOrdersHelper.js";import{f as w}from"../chunks/formatDateToLocale.js";import{c as b}from"../chunks/capitalizeFirst.js";import{r as U}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../fragments.js";import"../chunks/initialize.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(t=>(t.CANCEL="CANCEL",t.RETURN="RETURN",t.REORDER="REORDER",t))(y||{});const re=({className:t,orderData:e,slots:n,routeCreateReturn:r,routeOnSuccess:u,onError:i})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=J(()=>{const c=e==null?void 0:e.availableActions,o=!!(c!=null&&c.length),a=!!(e!=null&&e.returnNumber),m=()=>{U(r,{},e)};return s(S,{children:n!=null&&n.OrderActions?s($,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:e}):s("div",{"data-testid":"availableActionsList",className:_(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!o]]),children:c==null?void 0:c.map(p=>{switch(p){case y.CANCEL:return s(S,{children:a?null:s(ce,{orderRef:(e==null?void 0:e.token)||(e==null?void 0:e.id)})});case y.RETURN:return s(P,{variant:"secondary",onClick:m,children:a?d.createAnotherReturn:d.createReturn});case y.REORDER:return s(S,{children:a?null:s(ie,{orderData:e,onError:i,routeOnSuccess:u,children:d.reorder})})}})})})},[i,e,u,r,n,d]);return s("div",{className:_(["order-order-actions",t]),children:l})},ne=({orderData:t})=>{const[e,n]=C(t),[r,u]=C(t==null?void 0:t.status);return k(()=>{const i=I.on("order/data",d=>{n(d),u(d.status)},{eager:!0});return()=>{i==null||i.off()}},[]),{orderStatus:r,order:e}},H=t=>{const e=new URL(window.location.href);t.forEach(n=>{e.searchParams.has(n)&&e.searchParams.delete(n)}),window.history.replaceState({},document.title,e.toString())},se=({enableOrderCancellation:t})=>{const e=O({cancelOrderHeading:"Order.OrderStatusContent.actions.cancel",confirmGuestReturnHeading:"Order.OrderStatusContent.actions.confirmGuestReturn",orderCancelled:"Order.OrderStatusContent.orderCanceled.message",guestRequestReturnMessage:"Order.OrderStatusContent.actions.confirmGuestReturnMessage"}),[n,r]=C(!1),[u,i]=C(!1),[d,l]=C({heading:"",text:"",status:void 0}),c=T(()=>{r(!0),H(["order_id","confirmation_key","action"])},[]),o=T((a,m,p)=>{l({heading:a,text:m,status:p}),H(["action"])},[]);return k(()=>{const a=new URLSearchParams(window.location.search),m=a.get("order_id")??"",p=a.get("confirmation_key")??"",g=a.get("action")??"";u||!m||!p||!g||(t&&g==="cancel"&&(i(!0),X(m,p).then(()=>{l({heading:e.cancelOrderHeading,text:e.orderCancelled,status:"success"})}).catch(h=>{l({heading:e.cancelOrderHeading,text:h.message,status:"warning"})})),g==="return"&&(i(!0),Y(m,p).then(()=>{l({heading:e.confirmGuestReturnHeading,text:e.guestRequestReturnMessage,status:"success"})}).catch(h=>{l({heading:e.confirmGuestReturnHeading,text:h.message,status:"warning"})})))},[t,e,o,u]),{orderActionStatus:d,isDismissed:n,onDismiss:c}},be=({slots:t,orderData:e,className:n,statusTitle:r,status:u,routeCreateReturn:i,onError:d,routeOnSuccess:l})=>{const{orderStatus:c,order:o}=ne({orderData:e}),a=G(),{orderActionStatus:m,isDismissed:p,onDismiss:g}=se({enableOrderCancellation:a==null?void 0:a.orderCancellationEnabled});return A("div",{className:_(["order-order-status",n]),children:[!p&&(m==null?void 0:m.status)!==void 0?s(B,{style:{marginBottom:"1rem"},heading:m.heading,onDismiss:g,description:m.text,type:m.status}):null,o?s(oe,{title:r,status:u||c,slots:t,orderData:o,routeCreateReturn:i,onError:d,routeOnSuccess:l}):s(D,{withCard:!1})]})},ce=({orderRef:t})=>{const[e,n]=C(!1),r=()=>{n(!0)},u=()=>{n(!1)},i=G(),d=(i==null?void 0:i.orderCancellationReasons)??[],l=c=>c.map((o,a)=>({text:o==null?void 0:o.description,value:a.toString()}));return I.on("order/data",c=>{const o=String(c.status).toLocaleLowerCase();(o==="guest order cancellation requested"||o==="canceled")&&u()}),A(S,{children:[s(P,{variant:"secondary",onClick:r,"data-testid":"cancel-button",children:s(M,{id:"Order.OrderStatusContent.actions.cancel"})}),e&&s(V,{centered:!0,size:"medium",onClose:u,className:"order-order-cancel__modal",title:s("h2",{className:"order-order-cancel__title",children:s(M,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:s(te,{orderRef:t,cancelReasons:l(d)})})]})},N={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested","pending payment":"orderPendingPayment",rejected:"orderRejected",authorized:"orderAuthorized","paypal canceled reversal":"orderPaypalCanceledReversal","pending paypal":"orderPendingPaypal","paypal reversed":"orderPaypalReversed",closed:"orderClosed"},oe=({slots:t,title:e,status:n,orderData:r,routeCreateReturn:u,onError:i,routeOnSuccess:d})=>{var x,E,L;const l=!!(r!=null&&r.returnNumber),c=String(n).toLocaleLowerCase(),o=(x=r==null?void 0:r.returns)==null?void 0:x[0],a=(o==null?void 0:o.returnStatus)??"",m=(o==null?void 0:o.createdReturnAt)??"",p=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),g=O(`Order.OrderStatusContent.${N[c]}.title`),h=O(`Order.OrderStatusContent.${N[c]}.message`),R=O(`Order.OrderStatusContent.${N[c]}.messageWithoutDate`),f=O({title:`Order.OrderStatusContent.returnStatus.${ee(a)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return s("div",{});const q=g!=null&&g.title?g:{title:b(c)},v=h!=null&&h.message?h:p,F=R!=null&&R.messageWithoutDate?R:p,W=r!=null&&r.orderStatusChangeDate?v==null?void 0:v.message.replace("{DATE}",w(r==null?void 0:r.orderStatusChangeDate)):F.messageWithoutDate,j=((L=(E=f==null?void 0:f.returnMessage)==null?void 0:E.replace("{ORDER_CREATE_DATE}",w(r==null?void 0:r.orderDate)))==null?void 0:L.replace("{RETURN_CREATE_DATE}",w(m)))??"",z=l?e??(f.title||b(a)):e??q.title;return A(K,{className:"order-order-status-content",variant:"secondary",children:[s(Q,{title:z}),A("div",{className:"order-order-status-content__wrapper",children:[s("div",{className:_(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(t!=null&&t.OrderActions)]]),children:s("p",{children:l?j:W})}),s(re,{orderData:r,slots:t,routeCreateReturn:u,routeOnSuccess:d,onError:i})]})]})},ie=({onError:t,routeOnSuccess:e,orderData:n,children:r})=>{const[u,i]=C(!1),d=T(()=>{i(!0);const l=n==null?void 0:n.number;Z(l).then(({success:c,userInputErrors:o})=>{c&&U(e,{}),o.length&&(t==null||t(o))}).catch(c=>{t==null||t(c.message)}).finally(()=>{i(!1)})},[n,e,t]);return s(P,{type:"button",disabled:u,variant:"secondary",className:"order-reorder",onClick:d,children:r})};export{be as OrderStatus,be as default}; diff --git a/scripts/__dropins__/storefront-order/data/models/order-details.d.ts b/scripts/__dropins__/storefront-order/data/models/order-details.d.ts index d3805af02c..e87a23982a 100644 --- a/scripts/__dropins__/storefront-order/data/models/order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/order-details.d.ts @@ -19,6 +19,12 @@ export type OrderAddressModel = { }[]; } | null; export type OrderItemProductModel = { + onlyXLeftInStock?: number; + priceRange?: { + maximumPrice?: { + regularPrice?: MoneyProps; + }; + }; uid: string; __typename: string; stockStatus?: string; @@ -36,6 +42,8 @@ export type OrderItemProductModel = { }; }; export type OrderItemModel = { + productSalePrice: MoneyProps; + status?: string; currentReturnOrderQuantity?: number; eligibleForReturn: boolean; productSku?: string; @@ -59,6 +67,20 @@ export type OrderItemModel = { count: number; result: string; } | null; + prices: { + priceIncludingTax: MoneyProps; + originalPrice: MoneyProps; + originalPriceIncludingTax: MoneyProps; + price: MoneyProps; + discounts: [ + { + label: string; + amount: { + value: number; + }; + } + ]; + }; itemPrices: { priceIncludingTax: MoneyProps; originalPrice: MoneyProps; @@ -91,7 +113,7 @@ export type OrderItemModel = { quantityRefunded: number; quantityReturned: number; quantityShipped: number; - requestQuantity: number; + requestQuantity?: number; totalQuantity: number; returnableQuantity?: number; quantityReturnRequested: number; @@ -120,7 +142,7 @@ export type ShipmentsModel = { }; export type OrderDataModel = { placeholderImage?: string; - returnNumber: string; + returnNumber?: string; id: string; orderStatusChangeDate?: string; number: string; diff --git a/scripts/__dropins__/storefront-order/data/models/store-config.d.ts b/scripts/__dropins__/storefront-order/data/models/store-config.d.ts index 9365f2ea14..60d6b50d4e 100644 --- a/scripts/__dropins__/storefront-order/data/models/store-config.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/store-config.d.ts @@ -17,7 +17,7 @@ export interface StoreConfigModel { baseMediaUrl: string; orderCancellationEnabled: boolean; orderCancellationReasons: OrderCancellationReason[]; - shoppingCartDisplayPrice: 1 | 2 | 3; + shoppingOrderDisplayPrice: 1 | 2 | 3; shoppingOrdersDisplayShipping: 1 | 2 | 3; shoppingOrdersDisplaySubtotal: 1 | 2 | 3; shoppingOrdersDisplayFullSummary: boolean; diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts index 5421b44993..643f5ddade 100644 --- a/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts @@ -1,5 +1,5 @@ import { QueryType, ResponseData, OrderProps, OrderItemProps } from '../../types'; -import { OrderItemModel, TransformedData } from '../models'; +import { OrderDataModel, OrderItemModel, TransformedData } from '../models'; export declare const transformConfigurableOptions: (item: OrderItemProps) => Record | undefined; export declare const transformBundleOptions: (data: any) => { @@ -12,6 +12,6 @@ export declare const transformLinks: (links: { result: string; } | null; export declare const transformOrderItems: (items: OrderItemProps[]) => OrderItemModel[]; -export declare const transformOrderData: (orderData: OrderProps, returnRef?: string) => any; +export declare const transformOrderData: (orderData: OrderProps, returnRef?: string) => OrderDataModel; export declare const transformOrderDetails: (queryType: QueryType, response: ResponseData, returnRef?: string) => TransformedData; //# sourceMappingURL=transform-order-details.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useOrderSearch.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useOrderSearch.d.ts index e1e6f8b152..e3f7be4ca3 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useOrderSearch.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useOrderSearch.d.ts @@ -17,6 +17,7 @@ export declare const useOrderSearch: ({ onError, isAuth, renderSignIn, routeCust name: string; id: string; code: string; + isUnique: boolean; }[]; }; //# sourceMappingURL=useOrderSearch.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/lib/categorizeProducts.d.ts b/scripts/__dropins__/storefront-order/lib/categorizeProducts.d.ts index b6953c0bed..de0cbb8cfa 100644 --- a/scripts/__dropins__/storefront-order/lib/categorizeProducts.d.ts +++ b/scripts/__dropins__/storefront-order/lib/categorizeProducts.d.ts @@ -1,8 +1,10 @@ -import { OrderDataModel } from '../data/models'; +import { OrderDataModel, OrderItemModel } from '../data/models'; export declare const categorizeProducts: (order: OrderDataModel) => { returnedList: { totalQuantity: number; + productSalePrice: import('../types/index').MoneyProps; + status?: string | undefined; currentReturnOrderQuantity?: number | undefined; eligibleForReturn: boolean; productSku?: string | undefined; @@ -26,6 +28,18 @@ export declare const categorizeProducts: (order: OrderDataModel) => { count: number; result: string; } | null; + prices: { + priceIncludingTax: import('../types/index').MoneyProps; + originalPrice: import('../types/index').MoneyProps; + originalPriceIncludingTax: import('../types/index').MoneyProps; + price: import('../types/index').MoneyProps; + discounts: [{ + label: string; + amount: { + value: number; + }; + }]; + }; itemPrices: { priceIncludingTax: import('../types/index').MoneyProps; originalPrice: import('../types/index').MoneyProps; @@ -56,11 +70,11 @@ export declare const categorizeProducts: (order: OrderDataModel) => { quantityRefunded: number; quantityReturned: number; quantityShipped: number; - requestQuantity: number; + requestQuantity?: number | undefined; returnableQuantity?: number | undefined; quantityReturnRequested: number; }[]; - canceledItems: (import('../data/models').OrderItemModel | null)[]; - nonCanceledItems: (import('../data/models').OrderItemModel | null)[]; + canceledItems: OrderItemModel[]; + nonCanceledItems: OrderItemModel[]; }; //# sourceMappingURL=categorizeProducts.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts b/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts index a4d5c227a8..e921da8cae 100644 --- a/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts @@ -36,6 +36,8 @@ interface ThumbnailImageProps { label?: string; } export interface ProductProps { + only_x_left_in_stock?: number; + stock_status?: string; thumbnail?: ThumbnailImageProps; image: ThumbnailImageProps; canonical_url: string; @@ -191,7 +193,9 @@ export interface ShipmentsProps { id: string; product_sku: string; product_name: string; - }; + quantity_shipped: number; + order_item: OrderItemProps; + }[]; } export declare enum AvailableActionsProps { CANCEL = "CANCEL", @@ -228,6 +232,8 @@ export interface ReturnsItemsProps { }[]; } export interface OrderProps { + is_virtual?: boolean; + order_status_change_date?: string; available_actions: AvailableActionsProps[]; shipping_method: string; status: string; diff --git a/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts b/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts index 17aafb587b..7ffa0735c0 100644 --- a/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts @@ -21,7 +21,7 @@ export interface CreateReturnProps { }>; }; className: string; - onSuccess?: (response: onSuccessTypes) => void; + onSuccess?: (response: onSuccessTypes | {}) => void; onError?: (message: string) => void; routeReturnSuccess?: () => string; showConfigurableOptions?: (options: options | {}) => options; @@ -63,7 +63,7 @@ export interface ReturnOrderMessageProps { } export interface UseCreateReturn { orderData?: OrderDataModel; - onSuccess?: (response: onSuccessTypes) => void; + onSuccess?: (response: onSuccessTypes | {}) => void; onError?: (message: string) => void; handleSetInLineAlert: (value?: InLineAlertProps) => void; } diff --git a/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts b/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts index 1578f9a786..24adb6b759 100644 --- a/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts @@ -5,8 +5,8 @@ type TaxTypes = { taxIncluded: boolean; taxExcluded: boolean; }; -export interface StoreConfigProps extends Omit { - shoppingCartDisplayPrice: TaxTypes; +export interface StoreConfigProps extends Omit { + shoppingOrderDisplayPrice: TaxTypes; shoppingOrdersDisplayShipping: TaxTypes; shoppingOrdersDisplaySubtotal: TaxTypes; }