From fcbef3b082e1c7768e7603c8763a3012b394da50 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Fri, 6 Dec 2024 22:25:18 +0100 Subject: [PATCH 1/5] Create return routing fix --- blocks/commerce-create-return/commerce-create-return.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/blocks/commerce-create-return/commerce-create-return.js b/blocks/commerce-create-return/commerce-create-return.js index 5f1e325b2b..9b4c30994e 100644 --- a/blocks/commerce-create-return/commerce-create-return.js +++ b/blocks/commerce-create-return/commerce-create-return.js @@ -10,6 +10,12 @@ import '../../scripts/initializers/order.js'; export default async function decorate(block) { await orderRenderer.render(CreateReturn, { - routeReturnSuccess: (orderData) => (checkIsAuthenticated() ? `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderData.number}` : `${ORDER_DETAILS_PATH}?orderRef=${orderData.token}`), + routeReturnSuccess: (orderData) => { + const orderRef = checkIsAuthenticated() ? orderData.number : orderData.token; + const encodedOrderRef = encodeURIComponent(orderRef); + const path = checkIsAuthenticated() ? CUSTOMER_ORDER_DETAILS_PATH : ORDER_DETAILS_PATH; + + return `${path}?orderRef=${encodedOrderRef}`; + }, })(block); } From 83b346b3360354c9517599c0c843e0ea77ccc370 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Fri, 6 Dec 2024 22:30:28 +0100 Subject: [PATCH 2/5] Install latest version of auth, acc and order dropins --- package-lock.json | 20 +- package.json | 6 +- scripts/__dropins__/storefront-account/api.js | 4 +- .../createCustomerAddress.graphql.d.ts | 2 +- .../storefront-account/api/fragments.d.ts | 4 + .../fragments/CustomerFragment.graphql.d.ts | 2 - .../graphql/getAttributesForm.graphql.d.ts | 2 +- .../graphql/getCustomerAddress.graphql.d.ts | 2 +- .../getOrderHistoryList.d.ts | 4 +- .../customerAddressFragment.graphql.d.ts | 2 - .../graphql/orderSummaryFragment.graphql.d.ts | 2 - .../graphql/getStoreConfig.graphql.d.ts | 2 +- .../CustomerAddressFragment.graphql.d.ts | 2 + .../api/graphql/CustomerFragment.graphql.d.ts | 2 + .../graphql/OrderSummaryFragment.graphql.d.ts | 2 + .../api/initialize/initialize.d.ts | 8 +- .../removeCustomerAddress.graphql.d.ts | 2 +- .../graphql/updateCustomer.graphql.d.ts | 2 +- .../updateCustomerAddress.graphql.d.ts | 2 +- .../graphql/updateCustomerEmail.graphql.d.ts | 2 +- .../updateCustomerPassword.graphql.d.ts | 2 +- .../chunks/CustomerInformationCard.js | 4 +- .../chunks/getOrderHistoryList.js | 222 +++++----- .../chunks/getStoreConfig.js | 12 + .../chunks/removeCustomerAddress.js | 37 +- .../chunks/updateCustomer.js | 58 +-- .../configs/mockDefaultAddress.config.d.ts | 47 +- .../containers/AddressForm.js | 2 + .../containers/Addresses.js | 2 + .../containers/CustomerInformation.js | 4 +- .../containers/OrdersList.js | 4 +- .../data/models/customer.d.ts | 1 - .../data/models/order-history-list.d.ts | 2 +- .../data/models/store-config.d.ts | 1 + .../transform-customer-address.d.ts | 1 - .../transform-order-history-list.d.ts | 4 +- .../hooks/containers/useOrdersList.d.ts | 1 + .../lib/transformDefaultValuesAddresses.d.ts | 11 + .../__dropins__/storefront-account/render.js | 4 +- .../types/api/getCustomer.types.d.ts | 1 - .../types/api/getCustomerAddress.type.d.ts | 4 + .../types/api/storeConfig.types.d.ts | 1 + .../types/ordersList.types.d.ts | 1 + scripts/__dropins__/storefront-auth/api.js | 4 +- .../graphql/confirmEmail.graphql.d.ts | 2 +- .../api/createCustomer/createCustomer.d.ts | 5 +- .../graphql/createCustomer.graphql.d.ts | 2 +- .../graphql/createCustomerV2.graphql.d.ts | 2 +- .../createCustomerAddress.graphql.d.ts | 2 +- .../storefront-auth/api/fragments.d.ts | 2 + .../api/getCustomerData/getCustomerData.d.ts | 4 +- .../graphql/getCustomerData.graphql.d.ts | 2 +- .../api/graphql/CustomerFragment.graphql.d.ts | 2 + .../api/initialize/initialize.d.ts | 6 +- .../resendConfirmationEmail.graphql.d.ts | 2 +- .../graphql/resetPassword.graphql.d.ts | 2 +- .../storefront-auth/chunks/Button2.js | 3 + .../chunks/EmailConfirmationForm.js | 1 - .../chunks/ResetPasswordForm.js | 4 +- .../storefront-auth/chunks/SignInForm.js | 4 +- .../storefront-auth/chunks/SignUpForm.js | 4 +- .../storefront-auth/chunks/SkeletonLoader.js | 2 + .../chunks/UpdatePasswordForm.js | 1 - .../storefront-auth/chunks/confirmEmail.js | 9 +- .../chunks/createCustomerAddress.js | 28 +- .../chunks/focusOnEmptyPasswordField.js | 3 + .../chunks/getCustomerToken.js | 13 +- .../storefront-auth/chunks/getStoreConfig.js | 2 + .../storefront-auth/chunks/index.js | 4 +- .../storefront-auth/chunks/index2.js | 4 +- .../storefront-auth/chunks/index3.js | 4 +- .../storefront-auth/chunks/initialize.js | 2 + .../storefront-auth/chunks/network-error.js | 2 + .../chunks/requestPasswordResetEmail.js | 2 + .../chunks/resendConfirmationEmail.js | 9 +- .../storefront-auth/chunks/resetPassword.js | 14 +- .../chunks/revokeCustomerToken.js | 2 + .../chunks/setReCaptchaToken.js | 2 + .../chunks/simplifyTransformAttributesForm.js | 4 +- .../chunks/transform-attributes-form.js | 2 + .../chunks/usePasswordValidationMessage.js | 2 + .../storefront-auth/components/Form/Form.d.ts | 2 +- .../storefront-auth/components/index.d.ts | 1 + .../configs/defaultCreateUserConfigs.d.ts | 26 +- .../storefront-auth/containers/AuthCombine.js | 4 +- .../containers/ResetPassword.js | 4 +- .../storefront-auth/containers/SignIn.js | 4 +- .../storefront-auth/containers/SignUp.js | 4 +- .../containers/SuccessNotification.js | 4 +- .../containers/UpdatePassword.js | 4 +- .../data/models/customer-data.d.ts | 11 +- .../data/transforms/index.d.ts | 1 + .../transforms/transform-create-customer.d.ts | 7 + .../transforms/transform-customer-data.d.ts | 4 +- .../storefront-auth/fragments.d.ts | 1 + .../__dropins__/storefront-auth/fragments.js | 11 + .../hooks/components/useSignInForm.d.ts | 3 +- .../hooks/components/useSignUpForm.d.ts | 3 + .../storefront-auth/i18n/en_US.json.d.ts | 3 +- .../lib/focusOnEmptyPasswordField.d.ts | 2 + scripts/__dropins__/storefront-auth/render.js | 8 +- .../types/api/createCustomer.types.d.ts | 27 +- .../types/api/getCustomerData.types.d.ts | 1 + scripts/__dropins__/storefront-order/api.js | 174 ++------ .../storefront-order/api/fragment.d.ts | 7 + .../graphql/getAttributesForm.graphql.d.ts | 2 +- .../graphql/getCustomer.graphql.d.ts | 2 +- .../getCustomerOrdersReturn.d.ts | 2 +- .../graphql/getGuestOrder.graphql.d.ts | 1 - .../customerAddressFragment.graphql.d.ts | 2 - .../getOrderDetailsById/graphql/index.d.ts | 6 - .../graphql/orderItemsFragment.graphql.d.ts | 6 - .../graphql/orderSummaryFragment.graphql.d.ts | 2 - .../graphql/returnsFragment.graphql.d.ts | 2 - .../graphql/StoreConfigQuery.d.ts | 2 +- .../CustomerAddressFragment.graphql.d.ts | 2 + .../graphql/GurestOrderFragment.graphql.d.ts | 2 + .../graphql/OrderItemsFragment.graphql.d.ts | 6 + .../graphql/OrderSummaryFragment.graphql.d.ts | 2 + .../RequestReturnOrderFragment.graphql.d.ts | 2 + .../api/graphql/ReturnsFragment.graphql.d.ts | 2 + .../storefront-order/api/index.d.ts | 19 +- .../api/initialize/initialize.d.ts | 8 +- .../graphql/placeOrderMutation.d.ts | 2 + .../api/placeOrder/index.d.ts | 2 + .../api/placeOrder/placeOrder.d.ts | 4 + .../graphql/reorderItems.graphql.d.ts | 2 +- .../api/requestReturn/graphql/fragments.d.ts | 2 - .../api/requestReturn/requestReturn.d.ts | 8 +- .../chunks/CartSummaryItem.js | 2 +- .../chunks/GurestOrderFragment.graphql.js | 99 +++++ .../chunks/OrderCancelForm.js | 2 +- .../storefront-order/chunks/OrderLoaders.js | 2 +- .../chunks/ReturnsListContent.js | 2 +- .../{OrderCancel.js => ShippingStatusCard.js} | 0 .../storefront-order/chunks/convertCase.js | 3 - .../chunks/getAttributesForm.js | 2 +- .../storefront-order/chunks/getCustomer.js | 11 - .../chunks/getCustomerOrdersReturn.js | 34 +- .../chunks/getGuestOrder.graphql.js | 160 ------- .../storefront-order/chunks/getGuestOrder.js | 18 + .../storefront-order/chunks/getStoreConfig.js | 27 +- .../storefront-order/chunks/initialize.js | 407 ++++++++++++++++++ .../storefront-order/chunks/network-error.js | 2 +- .../storefront-order/chunks/reorderItems.js | 24 +- .../chunks/requestGuestOrderCancel.js | 165 +++---- .../storefront-order/chunks/requestReturn.js | 33 +- .../chunks/transform-attributes-form.js | 2 +- .../chunks/transform-order-details.js | 142 ------ .../chunks/useGetStoreConfig.js | 3 + .../components/OrderHeader/OrderHeader.d.ts | 9 + .../components/OrderHeader/index.d.ts | 2 + .../components/OrderLoaders/OrderLoaders.d.ts | 1 + .../storefront-order/components/index.d.ts | 23 +- .../storefront-order/configs/mock.config.d.ts | 67 +++ .../containers/CreateReturn.js | 2 +- .../containers/CustomerDetails.js | 2 +- .../containers/OrderCancelForm.js | 2 +- .../containers/OrderCostSummary.js | 2 +- .../containers/OrderHeader.d.ts | 3 + .../containers/OrderHeader.js | 3 + .../containers/OrderHeader/OrderHeader.d.ts | 5 + .../containers/OrderHeader/index.d.ts | 3 + .../containers/OrderProductList.js | 2 +- .../containers/OrderReturns.js | 2 +- .../containers/OrderSearch.js | 2 +- .../containers/OrderStatus.js | 17 +- .../containers/ReturnsList.js | 2 +- .../containers/ShippingStatus.js | 2 +- .../storefront-order/containers/index.d.ts | 15 +- .../storefront-order/data/models/acdl.d.ts | 99 +++++ .../storefront-order/data/models/index.d.ts | 7 +- .../data/models/order-details.d.ts | 1 + .../data/models/request-return.d.ts | 7 + .../data/models/store-config.d.ts | 1 + .../data/transforms/index.d.ts | 11 +- .../data/transforms/transform-acdl.d.ts | 5 + .../transform-customer-address-input.d.ts | 22 + .../transforms/transform-place-order.d.ts | 5 + .../transforms/transform-request-return.d.ts | 5 + .../hooks/containers/useCreateReturn.d.ts | 4 +- .../hooks/containers/useOrderCostSummary.d.ts | 2 +- .../hooks/containers/useOrderHeader.d.ts | 8 + .../hooks/containers/useOrderProductList.d.ts | 3 +- .../storefront-order/hooks/index.d.ts | 12 +- .../storefront-order/i18n/en_US.json.d.ts | 52 ++- .../storefront-order/lib/acdl.d.ts | 18 + .../storefront-order/lib/capitalizeFirst.d.ts | 2 + .../__dropins__/storefront-order/render.js | 4 +- .../types/api/placeOrder.types.d.ts | 19 + .../types/createReturn.types.d.ts | 2 + .../storefront-order/types/index.d.ts | 30 +- .../types/orderCostSummary.types.d.ts | 1 + .../types/orderHeader.types.d.ts | 19 + .../types/orderProductList.types.d.ts | 2 + .../types/returnsList.types.d.ts | 1 + .../types/shippingStatus.types.d.ts | 1 + 197 files changed, 1686 insertions(+), 1033 deletions(-) create mode 100644 scripts/__dropins__/storefront-account/api/fragments.d.ts delete mode 100644 scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts delete mode 100644 scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/customerAddressFragment.graphql.d.ts delete mode 100644 scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/orderSummaryFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-account/api/graphql/CustomerAddressFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-account/api/graphql/CustomerFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-account/api/graphql/OrderSummaryFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-account/chunks/getStoreConfig.js create mode 100644 scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts create mode 100644 scripts/__dropins__/storefront-auth/api/fragments.d.ts create mode 100644 scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-auth/chunks/Button2.js delete mode 100644 scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js delete mode 100644 scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js create mode 100644 scripts/__dropins__/storefront-auth/chunks/focusOnEmptyPasswordField.js create mode 100644 scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts create mode 100644 scripts/__dropins__/storefront-auth/fragments.d.ts create mode 100644 scripts/__dropins__/storefront-auth/fragments.js create mode 100644 scripts/__dropins__/storefront-auth/lib/focusOnEmptyPasswordField.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/fragment.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/customerAddressFragment.graphql.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/index.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderSummaryFragment.graphql.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/CustomerAddressFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/RequestReturnOrderFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/graphql/ReturnsFragment.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/placeOrder/graphql/placeOrderMutation.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/placeOrder/index.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/placeOrder/placeOrder.d.ts delete mode 100644 scripts/__dropins__/storefront-order/api/requestReturn/graphql/fragments.d.ts create mode 100644 scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js rename scripts/__dropins__/storefront-order/chunks/{OrderCancel.js => ShippingStatusCard.js} (100%) delete mode 100644 scripts/__dropins__/storefront-order/chunks/convertCase.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/getCustomer.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js create mode 100644 scripts/__dropins__/storefront-order/chunks/getGuestOrder.js create mode 100644 scripts/__dropins__/storefront-order/chunks/initialize.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/transform-order-details.js create mode 100644 scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js create mode 100644 scripts/__dropins__/storefront-order/components/OrderHeader/OrderHeader.d.ts create mode 100644 scripts/__dropins__/storefront-order/components/OrderHeader/index.d.ts create mode 100644 scripts/__dropins__/storefront-order/containers/OrderHeader.d.ts create mode 100644 scripts/__dropins__/storefront-order/containers/OrderHeader.js create mode 100644 scripts/__dropins__/storefront-order/containers/OrderHeader/OrderHeader.d.ts create mode 100644 scripts/__dropins__/storefront-order/containers/OrderHeader/index.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/models/acdl.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/models/request-return.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/transforms/transform-acdl.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/transforms/transform-customer-address-input.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/transforms/transform-place-order.d.ts create mode 100644 scripts/__dropins__/storefront-order/data/transforms/transform-request-return.d.ts create mode 100644 scripts/__dropins__/storefront-order/hooks/containers/useOrderHeader.d.ts create mode 100644 scripts/__dropins__/storefront-order/lib/acdl.d.ts create mode 100644 scripts/__dropins__/storefront-order/lib/capitalizeFirst.d.ts create mode 100644 scripts/__dropins__/storefront-order/types/api/placeOrder.types.d.ts create mode 100644 scripts/__dropins__/storefront-order/types/orderHeader.types.d.ts diff --git a/package-lock.json b/package-lock.json index e115c0f02f..e277b67281 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "0.1.0-alpha20", - "@dropins/storefront-auth": "0.0.1-alpha25", + "@dropins/storefront-account": "1.0.0-beta2", + "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "0.1.0-alpha26", + "@dropins/storefront-order": "0.1.0-alpha32", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" }, @@ -765,10 +765,14 @@ } }, "node_modules/@dropins/storefront-account": { - "version": "0.1.0-alpha20" + "version": "1.0.0-beta2", + "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-1.0.0-beta2.tgz", + "integrity": "sha512-kXTjWeNc9SyJ2HtG3Ev6nrR6GsxiHcM4IEMRY1L8/yX5qFwpR8p+iFsUhzRGstGH5MErj2IeAnaiAJ1QMoqtcA==" }, "node_modules/@dropins/storefront-auth": { - "version": "0.0.1-alpha25" + "version": "1.0.0-beta2", + "resolved": "https://registry.npmjs.org/@dropins/storefront-auth/-/storefront-auth-1.0.0-beta2.tgz", + "integrity": "sha512-H56wGX0G4lJSXfl8Biq6rpYoxYFj9/I/yCtREFWjbwTUe2ElONlAIJsf2iLlQLh2yH7Gv7+FkFtx7zm/A2Mnrw==" }, "node_modules/@dropins/storefront-cart": { "version": "0.10.0" @@ -779,9 +783,9 @@ "integrity": "sha512-w/6Me6NL1ImA8E3jSzazRihI6kLazVcOWTyXVycr0AgYz8Q2pBSCt9KlMzWZnFT9VsRuIn+wwMd8AsbQqQpetg==" }, "node_modules/@dropins/storefront-order": { - "version": "0.1.0-alpha26", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-0.1.0-alpha26.tgz", - "integrity": "sha512-8QW4Ks+4QA3huprNffb9Yy4WJptZmTYvfa6gJg6NJxKIGbnoUBzlq2gxb8kKmOKXuCssxqtqKMitOwzI6BFB9A==" + "version": "0.1.0-alpha32", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-0.1.0-alpha32.tgz", + "integrity": "sha512-kgoLuROfpMaenX8sJzHMWJxeY4OuQ11CVtTpkDQyxGi7jLhal1eR1ZLjF0MDC8/QZXWMME6OUodPHubQlqSXlw==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0-beta3", diff --git a/package.json b/package.json index a5f0eae6b4..974667ff55 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "0.1.0-alpha20", - "@dropins/storefront-auth": "0.0.1-alpha25", + "@dropins/storefront-account": "1.0.0-beta2", + "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "0.1.0-alpha26", + "@dropins/storefront-order": "0.1.0-alpha32", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" } diff --git a/scripts/__dropins__/storefront-account/api.js b/scripts/__dropins__/storefront-account/api.js index 80d1dacbc0..9b5c62e921 100644 --- a/scripts/__dropins__/storefront-account/api.js +++ b/scripts/__dropins__/storefront-account/api.js @@ -1 +1,3 @@ -import{Initializer as r}from"@dropins/tools/lib.js";import{d as m,f as u,c as f,g as p,h as c,e as C,i as h,j as l,r as A,s as x,a as H,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as b,a as z,c as v,b as w,u as y}from"./chunks/updateCustomer.js";import{g as P}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const e=new r({init:async t=>{const s={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};e.config.setConfig({...s,...t})},listeners:()=>[]}),n=e.config;export{n as config,m as createCustomerAddress,u as fetchGraphQl,f as getAttributesForm,p as getConfig,c as getCountries,b as getCustomer,C as getCustomerAddress,P as getOrderHistoryList,h as getRegions,z as getStoreConfig,e as initialize,l as removeCustomerAddress,A as removeFetchGraphQlHeader,x as setEndpoint,H as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,v as updateCustomer,G as updateCustomerAddress,w as updateCustomerEmail,y as updateCustomerPassword}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{c as o,g as d,i}from"./chunks/getStoreConfig.js";import{d as g,f as p,c as u,g as C,h as f,e as h,i as c,j as n,r as l,s as A,a as x,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as Q,b,a as v,u as E}from"./chunks/updateCustomer.js";import{g as w}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";export{o as config,g as createCustomerAddress,p as fetchGraphQl,u as getAttributesForm,C as getConfig,f as getCountries,Q as getCustomer,h as getCustomerAddress,w as getOrderHistoryList,c as getRegions,d as getStoreConfig,i as initialize,n as removeCustomerAddress,l as removeFetchGraphQlHeader,A as setEndpoint,x as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,b as updateCustomer,G as updateCustomerAddress,v as updateCustomerEmail,E as updateCustomerPassword}; diff --git a/scripts/__dropins__/storefront-account/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts index 2421c4a7f4..ce704ced84 100644 --- a/scripts/__dropins__/storefront-account/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input:$input) {\n firstname\n }\n }\n"; +export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\n }\n }\n"; //# sourceMappingURL=createCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/fragments.d.ts b/scripts/__dropins__/storefront-account/api/fragments.d.ts new file mode 100644 index 0000000000..c81868b7a4 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/fragments.d.ts @@ -0,0 +1,4 @@ +export { BASIC_CUSTOMER_INFO_FRAGMENT } from './graphql/CustomerFragment.graphql'; +export { ADDRESS_FRAGMENT } from './graphql/CustomerAddressFragment.graphql'; +export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql'; +//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts deleted file mode 100644 index bd2d4a00d0..0000000000 --- a/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n dob\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n"; -//# sourceMappingURL=CustomerFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts index e210426503..de5037a870 100644 --- a/scripts/__dropins__/storefront-account/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts @@ -1,3 +1,3 @@ export declare const GET_ATTRIBUTES_FORM = "\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\n }\n }\n"; -export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n"; +export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n"; //# sourceMappingURL=getAttributesForm.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts index 0386fdb80d..1a32153512 100644 --- a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; +export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n middlename\n fax\n prefix\n suffix\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; //# sourceMappingURL=getCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/getOrderHistoryList.d.ts b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/getOrderHistoryList.d.ts index f3cbf32378..f6bb3fec19 100644 --- a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/getOrderHistoryList.d.ts +++ b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/getOrderHistoryList.d.ts @@ -1,4 +1,4 @@ -import { OrderHistory } from '../../data/models'; +import { OrderHistoryModel } from '../../data/models'; -export declare const getOrderHistoryList: (pageSize: number, selectOrdersDate: string, currentPage: number) => Promise; +export declare const getOrderHistoryList: (pageSize: number, selectOrdersDate: string, currentPage: number) => Promise; //# sourceMappingURL=getOrderHistoryList.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/customerAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/customerAddressFragment.graphql.d.ts deleted file mode 100644 index fe3f1ab4c0..0000000000 --- a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/customerAddressFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const ADDRESS = "\nfragment AddressesList on OrderAddress {\n city\n company\n country_code\n fax\n firstname\n lastname\n middlename\n postcode\n prefix\n region\n region_id\n street\n suffix\n telephone\n vat_id\n}"; -//# sourceMappingURL=customerAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/orderSummaryFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/orderSummaryFragment.graphql.d.ts deleted file mode 100644 index 0f8961ec6f..0000000000 --- a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/orderSummaryFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const ORDER_SUMMARY = "\nfragment OrderSummary on OrderTotal {\n __typename\n grand_total {\n value\n currency\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n}"; -//# sourceMappingURL=orderSummaryFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts index 6af98bcb32..129d8e7a5e 100644 --- a/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n"; +export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n base_media_url\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n"; //# sourceMappingURL=getStoreConfig.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/graphql/CustomerAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/graphql/CustomerAddressFragment.graphql.d.ts new file mode 100644 index 0000000000..33dd3d63a5 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/graphql/CustomerAddressFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const ADDRESS_FRAGMENT = "\n fragment ADDRESS_FRAGMENT on OrderAddress {\n city\n company\n country_code\n fax\n firstname\n lastname\n middlename\n postcode\n prefix\n region\n region_id\n street\n suffix\n telephone\n vat_id\n }\n"; +//# sourceMappingURL=CustomerAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/graphql/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/graphql/CustomerFragment.graphql.d.ts new file mode 100644 index 0000000000..6cdd32d89c --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/graphql/CustomerFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BASIC_CUSTOMER_INFO_FRAGMENT on Customer {\n date_of_birth\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n"; +//# sourceMappingURL=CustomerFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/graphql/OrderSummaryFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/graphql/OrderSummaryFragment.graphql.d.ts new file mode 100644 index 0000000000..c1d3684423 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/graphql/OrderSummaryFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n __typename\n grand_total {\n value\n currency\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; +//# sourceMappingURL=OrderSummaryFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-account/api/initialize/initialize.d.ts index 6f189d6764..475210185d 100644 --- a/scripts/__dropins__/storefront-account/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-account/api/initialize/initialize.d.ts @@ -1,5 +1,7 @@ -import { Initializer } from '@dropins/tools/types/elsie/src/lib'; +import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib'; import { Lang } from '@dropins/tools/types/elsie/src/i18n'; +import { OrderHistoryModel } from '../../data/models'; +import { CustomerDataModelShort } from '../../data/models/customer'; type ConfigProps = { langDefinitions?: Lang; @@ -7,6 +9,10 @@ type ConfigProps = { header?: string; tokenPrefix?: string; }; + models?: { + OrderHistoryModel?: Model; + CustomerDataModelShort?: Model; + }; }; export declare const initialize: Initializer; export declare const config: import('@dropins/tools/types/elsie/src/lib').Config; diff --git a/scripts/__dropins__/storefront-account/api/removeCustomerAddress/graphql/removeCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/removeCustomerAddress/graphql/removeCustomerAddress.graphql.d.ts index 886af4c5ea..f5e4c0a126 100644 --- a/scripts/__dropins__/storefront-account/api/removeCustomerAddress/graphql/removeCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/removeCustomerAddress/graphql/removeCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const REMOVE_CUSTOMER_ADDRESS = "\n mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {\n deleteCustomerAddress(id:$id)\n }\n"; +export declare const REMOVE_CUSTOMER_ADDRESS = "\n mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {\n deleteCustomerAddress(id: $id)\n }\n"; //# sourceMappingURL=removeCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomer/graphql/updateCustomer.graphql.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomer/graphql/updateCustomer.graphql.d.ts index 5948b580ef..972e3fe550 100644 --- a/scripts/__dropins__/storefront-account/api/updateCustomer/graphql/updateCustomer.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/updateCustomer/graphql/updateCustomer.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const UPDATE_CUSTOMER_V2 = "\n mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {\n updateCustomerV2(input:$input) {\n customer {\n email\n }\n }\n }\n"; +export declare const UPDATE_CUSTOMER_V2 = "\n mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {\n updateCustomerV2(input: $input) {\n customer {\n email\n }\n }\n }\n"; //# sourceMappingURL=updateCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerAddress/graphql/updateCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerAddress/graphql/updateCustomerAddress.graphql.d.ts index 31486a869b..25a6d864de 100644 --- a/scripts/__dropins__/storefront-account/api/updateCustomerAddress/graphql/updateCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/updateCustomerAddress/graphql/updateCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const UPDATE_CUSTOMER_ADDRESS = "\n mutation UPDATE_CUSTOMER_ADDRESS($id: Int!,\n $input: CustomerAddressInput) {\n updateCustomerAddress(id:$id, input:$input) {\n firstname\n }\n }\n"; +export declare const UPDATE_CUSTOMER_ADDRESS = "\n mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, $input: CustomerAddressInput) {\n updateCustomerAddress(id: $id, input: $input) {\n firstname\n }\n }\n"; //# sourceMappingURL=updateCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts index 9173e7848c..d1614aa6e0 100644 --- a/scripts/__dropins__/storefront-account/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const UPDATE_CUSTOMER_EMAIL = "\n mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) {\n updateCustomerEmail(email:$email password:$password) {\n customer {\n email\n }\n }\n }\n"; +export declare const UPDATE_CUSTOMER_EMAIL = "\n mutation UPDATE_CUSTOMER_EMAIL($email: String!, $password: String!) {\n updateCustomerEmail(email: $email, password: $password) {\n customer {\n email\n }\n }\n }\n"; //# sourceMappingURL=updateCustomerEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts index ef98a002c7..b7bbf9c2a4 100644 --- a/scripts/__dropins__/storefront-account/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CHANGE_CUSTOMER_PASSWORD = "\n mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) {\n changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) {\n email\n }\n }\n"; +export declare const CHANGE_CUSTOMER_PASSWORD = "\n mutation CHANGE_CUSTOMER_PASSWORD(\n $currentPassword: String!\n $newPassword: String!\n ) {\n changeCustomerPassword(\n currentPassword: $currentPassword\n newPassword: $newPassword\n ) {\n email\n }\n }\n"; //# sourceMappingURL=updateCustomerPassword.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js index 95e03fa5ac..8b0c990a19 100644 --- a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -1 +1,3 @@ -import{jsx as a,Fragment as Q,jsxs as W}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as qe,Input as Pe,InputDate as We,Checkbox as xe,TextArea as je,Card as he,Skeleton as we,SkeletonRow as G,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as De,Header as Je,InLineAlert as Xe}from"@dropins/tools/components.js";import{useRef as Ye,useState as N,useEffect as ee,useCallback as k,useMemo as Qe}from"@dropins/tools/preact-hooks.js";import{k as et,o as Re,u as Ce,c as Ve,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as K from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as _e}from"@dropins/tools/preact-compat.js";import{Fragment as Ne}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:I,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:I,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T,forwardFormRef:l,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var w,V;const{requiredFieldError:d,lengthTextError:l,numericError:i,alphaNumWithSpacesError:o,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:I}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((w=s==null?void 0:s.validateRules)!=null&&w.length))return x;const t=it(s==null?void 0:s.validateRules),h=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,_=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+h,+f)&&!(_||T))return{[L]:l.replace("{min}",h).replace("{max}",f)};if(!At(e,+_,+T)&&(_||T))return{[L]:I.replace("{min}",Te(_)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:o},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((V=r[L])!=null&&V.length)?{[L]:z.error}:x},He=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],l=r.match(/^(.*)Multiline_(\d+)$/);if(l){const i=l[1],o=parseInt(l[2],10);n[i]||(n[i]=[]),n[i].push({index:o,value:d})}else Object.keys(e).filter(o=>o.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((l,i)=>l.index-i.index),s[r]=d.map(l=>l.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?He(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Re(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=et(e,"camelCase",{firstname:"firstName",lastname:"lastName"}),r=Mt(bt(n));if(!s)return r;const[d,l]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...l&&{regionId:+l}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).every(r=>r in s&&s[r]!==""),Be=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:l})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),o=Ye(null),[c,u]=N({}),[p,y]=N({}),[g,I]=N({}),[L,x]=N(!0),[t,h]=N(!1),[f,_]=N(!1),[T,Z]=N(!0),[z,w]=N(!1);ee(()=>{const m=()=>{if(o.current){const b=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,M=o.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[e==null?void 0:e.length]);const V=k((m=!1)=>{let v=!0;const b={...p};let M=null;for(const[O,A]of Object.entries(c)){const $=e==null?void 0:e.find(S=>S.customUpperCode.includes(O)),U=ye(A.toString(),$,i,b);U[O]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(S=>b[S])||null)}if(m||y(b),M&&o.current&&!m){const O=o.current.elements.namedItem(M);O==null||O.focus()}return v},[p,e,c,i]),C=k((m,v,b,M)=>{const O={...me(o),[v]:m,...v.includes("countryCode")?{region:""}:{}},A={data:ae(O,!0),isDataValid:Ze(b,O)};w(A.isDataValid),V(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(A)),n==null||n(A,{},M)},[V,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:m,errorList:v}=vt(e);u(b=>({...m,...b})),y(v),I(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const m=me(o),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(m,!0)??{},n==null||n({data:b,isDataValid:M},{},null),w(M),_(!0)}},[c,g]),ee(()=>{var O;if(!T)return;const m=me(o),v=!!(m!=null&&m.countryCode),b=!!((O=m==null?void 0:m.region)!=null&&O.length);m&&v&&!b&&Be(n)&&!l&&C(m==null?void 0:m.region,"region",g,null)},[T,L,e,o,n,C,g,t,l]);const H=k((m,v)=>{const{name:b,value:M,type:O,checked:A}=m==null?void 0:m.target,$=O==="checkbox"?A:M;u(B=>{const te={...B,[b]:$};return b==="countryCode"&&(te.region="",x(!0),h(!1)),te}),r==null||r({[b]:$}),_(!0);const U=e==null?void 0:e.find(B=>B.customUpperCode.includes(b));let S=v?{...v}:{...p};if(U){const B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}C($,b,g,m)},[r,e,p,i,C,g,L]),q=k(m=>{const{name:v}=m==null?void 0:m.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((m,v)=>{const{name:b,value:M,type:O,checked:A}=m==null?void 0:m.target,$=O==="checkbox"?A:M,U=e==null?void 0:e.find(S=>S.customUpperCode===b);if(U){const S=v?{...v}:{...p},B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}},[p,e,i]),D=k(m=>{m.preventDefault();const v=V();s==null||s(m,v)},[V,s]);return{isDataValid:z,formData:c,errors:p,formRef:o,handleInputChange:H,onFocus:q,handleBlur:P,handleSubmit:D,handleValidationSubmit:V}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const _t=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:l,onBlur:i,onFocus:o,slots:c})=>{const u=`${d}__field`,p=(t,h)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:l,handleOnBlur:i,handleOnFocus:o,errorMessage:h,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,h,f)=>{var T;const _=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??h??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(qe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:o,handleSelect:l,defaultValue:_,value:_})},t.id)})},g=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(Pe,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:o,onChange:l})},t.id)}),I=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:h||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l,disabled:e||t.disabled})},t.id)}),L=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:h||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l})},t.id)}),x=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l})},t.id)});return n.length?a(Q,{children:n.map(t=>{const h=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,h):g(t,f,h);case se.MULTILINE:return g(t,f,h);case se.SELECT:return y(t,f,h);case se.DATE:return I(t,f,h);case se.BOOLEAN:return L(t,f,h);case se.TEXTAREA:return x(t,f,h);default:return null}})}):null}),ze=({testId:e,withCard:s=!0})=>{const n=W(we,{"data-testid":e||"skeletonLoader",children:[a(G,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(G,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(G,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>W(we,{"data-testid":"addressFormLoader",children:[a(G,{variant:"heading",size:"medium"}),a(G,{variant:"empty",size:"medium"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large",fullWidth:!0}),a(G,{size:"large",fullWidth:!0,lines:3}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:l,children:i,className:o="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:I,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:h,formData:f,errors:_,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:w,handleValidationSubmit:V,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const H=me(T);return{handleValidationSubmit:V,formData:ae(H,!0),isDataValid:h}}),n||!(c!=null&&c.length)?a(Nt,{}):W("form",{className:X(["account-form",o]),onSubmit:w,name:d,ref:T,children:[a(_t,{className:o,loading:l,fields:c,onChange:Z,onBlur:z,errors:_,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,I?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:H=>{Z(H),L==null||L(H)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:l,keysSortOrder:i,addressData:o,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=l?"minifiedView":"fullSizeView",I=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=I.cardLabelBilling.toLocaleUpperCase(),x=I.cardLabelShipping.toLocaleUpperCase(),t=I.defaultLabelText.toLocaleUpperCase(),h=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=_e(()=>{u==null||u(o==null?void 0:o.id),p==null||p()},[p,o==null?void 0:o.id,u]),_=_e(()=>{u==null||u(o==null?void 0:o.id),y==null||y()},[y,o==null?void 0:o.id,u]),T=be(()=>{if(!i)return[];const{region:C,...H}=o,q={...H,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[o,i]),{shippingLabel:Z,billingLabel:z,hideShipping:w,hideBilling:V}=h;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(ze,{}):W(Q,{children:[W("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:I.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:_,className:"account-address-card__action--editbutton","data-testid":"editButton",children:I.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,H)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${H}`,children:q},H)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?W("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:x}):null,o!=null&&o.defaultBilling?a(pe,{label:L}):null]}):null,s?W("div",{className:"account-address-card__labels",children:[!w&&(o!=null&&o.defaultShipping)?a(pe,{label:Z}):null,!V&&(o!=null&&o.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>K.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},K.createElement("g",{id:"Large"},K.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),K.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},K.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),K.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>K.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",...e},K.createElement("g",{id:"Large"},K.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),K.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},K.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"})))),Ft=e=>K.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},K.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),It=e=>K.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},K.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const l=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return W(o,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:l,closeModal:i})=>{const o=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return r?W(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),W("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:l,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",l=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:It,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!i.text?null:a(De,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing"],t1=["email","firstname","lastname","middlename","gender","dob","date_of_birth","prefix","suffix"],Ue=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,l)=>Number(l.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:l,onSuccess:i})=>{const[o,c]=N(""),[u,p]=N(!1),[y,g]=N(!1),[I,L]=N(!1),[x,t]=N(!1),[h,f]=N(!1),[_,T]=N(""),[Z,z]=N([]),[w,V]=N([]),C=k(async()=>{L(!0),Promise.all([Ve("shortRequest"),tt()]).then(A=>{const[$,U]=A;if($){const S=$.map(({name:B,orderNumber:te,label:re})=>({name:rt(B),orderNumber:te,label:St.includes(B)?null:re}));V(S)}if(U)if(d){const S=U.filter(B=>!!B.defaultShipping||!!B.defaultBilling);z(S)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var A;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(S=>+S.id===n)||Ue(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((A=$==null?void 0:$.id)==null?void 0:A.toString())),r==null||r(U)}},[Z,n,r,s,e]);const H=k(A=>{T(A),f(!1)},[]),q=k((A,$)=>{const U=(A==null?void 0:A.target).value;c(U);const S={data:ae($),isDataValid:!ve(ae($))};r==null||r(S),U!=="0"&&f(!1)},[r]),P=k(()=>{g(!0)},[]),D=k(()=>{T(""),g(!1),p(!1)},[]),m=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(_,Z),st(+_).then(()=>{C(),D()}).finally(()=>{t(!1)})},[Z,_,D,C]),b=k(()=>{f(!1)},[]),M=k(()=>{Be(l)&&d&&!h?window.location.href=l():(f(!0),T(""))},[h,l,d]),O=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:w,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:I,addNewAddress:h,addressesList:Z,addressId:_,handleRenderForm:P,handleRenderModal:m,removeAddress:v,onCloseBtnClick:D,setEditingAddressId:H,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:O,handleSelectAddressOption:q,selectedAddressOption:o}},r1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:l="",showFormLoader:i=!1,onAddressData:o,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:I=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:h=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:_,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:w=!0,routeAddressesPage:V,onSuccess:C,onError:H})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:D,submitLoading:m,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:O,addressesList:A,addressId:$,handleRenderForm:U,handleRenderModal:S,removeAddress:B,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:l,minifiedView:t,routeAddressesPage:V,onSuccess:C,onAddressData:o,selectShipping:g,selectBilling:I}),R=s??(g&&I?"selectedAddress":g?"selectedShippingAddress":I?"selectedBillingAddress":"default"),j=L?W("div",{className:"account-addresses-wrapper--select-view",children:[(J=Ue(A,g,I))==null?void 0:J.map((E,Y)=>W(Ne,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:R,id:`${R}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${R}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:I,minifiedView:t,addressData:E,keysSortOrder:D,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:R,id:`${R}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${R}_addressActions`,className:"account-addresses-wrapper__label",children:O?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",O]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:R,showFormLoader:i,isOpen:O,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:o})}):A!=null&&A.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:O,routeAddressesPage:ie}):null})]}):W(Q,{children:[A.map(E=>a(Ne,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:te,onSuccess:re,onError:H})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:D,loading:M,setAddressId:Le,handleRenderModal:t&&h||!t&&f?S:void 0,handleRenderForm:t&&h||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:O?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:O,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:!!(A!=null&&A.length),showBillingCheckBox:!!(A!=null&&A.length),shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:oe,onSuccess:re,onError:H})}):a(Fe,{minifiedView:t,addNewAddress:O,routeAddressesPage:ie})})]});return W("div",{children:[a("div",{children:x?a(Je,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),W("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(Ot,{minifiedView:t,addressData:A==null?void 0:A.find(E=>E.id===$),keysSortOrder:D,submitLoading:m,open:v,closeModal:te,onRemoveAddress:B}),M?a(ze,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:R,isOpen:!(A!=null&&A.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:o}):a(xt,{isEmpty:!(A!=null&&A.length),typeList:"address",minifiedView:t}),j]})]})}),ke={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...ke,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...ke,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const l=r[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),Ie=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:l,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:l,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?r[l]=e[l]:d.push({attribute_code:Re(l),value:e[l]})}),d.length>0&&(r.custom_attributesV2=d),r},Oe=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=He(x)),s.includes(L)&&r.push(x)}const{street:l,streetMultiline_2:i,streetMultiline_1:o,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const l=s.find(i=>(i==null?void 0:i.id)===d.regionId);l?n[r]={...d,text:l.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((l,i)=>{n[`${r}Multiline_${i+2}`]=l})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:l,showShippingCheckBox:i,showBillingCheckBox:o,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[I,L]=N({text:"",type:"success"}),[x,t]=N(e??!1),[h,f]=N(r||""),[_,T]=N([]),[Z,z]=N([]),[w,V]=N([]),[C,H]=N([]),[q,P]=N([]),[D,m]=N(!1),[v,b]=N(!1),[M,O]=N(()=>{var R,j;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(j=(R=JSON.parse(F))==null?void 0:R.data)==null?void 0:j.countryCode}:c}),[A,$]=N(!1),[U,S]=N(!1),[B,te]=N(()=>{var j,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(j=JSON.parse(F))==null?void 0:j.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{Ve(h?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[h]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:R,optionalZipCountries:j})=>{z(F),H(R),P(j),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),S(!0);const F=M==null?void 0:M.countryCode;at(F).then(R=>{V(R);const j=C.find(E=>E===F),J=q.find(E=>E===F);m(!!j),b(!J),$(!1),S(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,R)=>{if(!R)return null;t(!0);const j=Ie(F.target),J=Oe(j);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,R)=>{if(!R)return;t(!0);const{saveAddressBook:j,...J}=Ie(F.target),E=Oe(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=Qe(()=>{if(!_.length)return[];const F={...Vt,defaultValue:l,isHidden:s&&!B?!0:!i},R={...Ht,defaultValue:d,isHidden:s&&!B?!0:!o},j=[..._,F,R],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,w):{},Y=Bt(qt(E,c),j);return zt({fields:Y,addressId:h,countryOptions:Z,disableField:A,regionOptions:w,isRequiredRegion:D,isRequiredPostCode:v})},[_,l,s,B,i,d,o,g,w,c,h,Z,A,D,v]),ue=k(F=>{O(R=>({...R,...F}))},[]);return{isWaitingForResponse:U,regionOptions:w,saveCheckBoxAddress:B,inLineAlert:I,addressId:h,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:I=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:w,addressId:V,submitLoading:C,normalizeFieldsConfig:H,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:D,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:I,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:_,onCloseBtnClick:h,formName:s});return x?W("div",{className:X(["account-address-form-wrapper",c]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,w.text?a(Xe,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:w.type,variant:"secondary",heading:w.text,icon:w.icon}):null,W(Tt,{regionOptions:M,forwardFormRef:l,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:H,onSubmit:t||(V?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[V?a("input",{type:"hidden",name:"addressId",value:V,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:V}}):a(Q,{children:r?null:W(Q,{children:[a(de,{type:"button",onClick:D,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,ze as C,xt as E,Tt as F,$t as S,r1 as a,Be as c,t1 as d,Ie as g,Ut as n}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as xe,TextArea as De,Card as he,Skeleton as we,SkeletonRow as D,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as _,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{m as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as _e}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var S,H;const{requiredFieldError:d,lengthTextError:o,numericError:i,alphaNumWithSpacesError:l,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:O}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((S=s==null?void 0:s.validateRules)!=null&&S.length))return x;const t=it(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,N=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+A,+f)&&!(N||T))return{[L]:o.replace("{min}",A).replace("{max}",f)};if(!At(e,+N,+T)&&(N||T))return{[L]:O.replace("{min}",Te(N)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((H=r[L])!=null&&H.length)?{[L]:z.error}:x},Be=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const i=o[1],l=parseInt(o[2],10);n[i]||(n[i]=[]),n[i].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((o,i)=>o.index-i.index),s[r]=d.map(o=>o.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Ve(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Mt(bt(n));if(!s)return r;const[d,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...o&&{regionId:+o}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).length?Object.keys(e).every(r=>r in s&&s[r]!==""):!1,ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:o})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Qe(null),[c,u]=_({}),[p,y]=_({}),[g,O]=_({}),[L,x]=_(!0),[t,A]=_(!1),[f,N]=_(!1),[T,Z]=_(!0),[z,S]=_(!1);ee(()=>{const h=()=>{if(l.current){const b=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,M=l.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const H=k((h=!1)=>{let v=!0;const b={...p};let M=null;for(const[I,m]of Object.entries(c)){const $=e==null?void 0:e.find(w=>w.customUpperCode.includes(I)),U=ye(m.toString(),$,i,b);U[I]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(w=>b[w])||null)}if(h||y(b),M&&l.current&&!h){const I=l.current.elements.namedItem(M);I==null||I.focus()}return v},[p,e,c,i]),C=k((h,v,b,M)=>{const I={...me(l),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(I,!0),isDataValid:Ze(b,I)};S(m.isDataValid),H(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},M)},[H,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=vt(e);u(b=>({...h,...b})),y(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const h=me(l),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:M},{},null),S(M),N(!0)}},[c,g]),ee(()=>{var I;if(!T)return;const h=me(l),v=!!(h!=null&&h.countryCode),b=!!((I=h==null?void 0:h.region)!=null&&I.length);h&&v&&!b&&ze(n)&&!o&&C(h==null?void 0:h.region,"region",g,null)},[T,L,e,l,n,C,g,t,o]);const B=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M;u(R=>{const te={...R,[b]:$};return b==="countryCode"&&(te.region="",x(!0),A(!1)),te}),r==null||r({[b]:$}),N(!0);const U=e==null?void 0:e.find(R=>R.customUpperCode.includes(b));let w=v?{...v}:{...p};if(U){const R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}C($,b,g,h)},[r,e,p,i,C,g,L]),q=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M,U=e==null?void 0:e.find(w=>w.customUpperCode===b);if(U){const w=v?{...v}:{...p},R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}},[p,e,i]),K=k(h=>{h.preventDefault();const v=H();s==null||s(h,v)},[H,s]);return{isDataValid:z,formData:c,errors:p,formRef:l,handleInputChange:B,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:H}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const Nt=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:o,onBlur:i,onFocus:l,slots:c})=>{const u=`${d}__field`,p=(t,A)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:i,handleOnFocus:l,errorMessage:A,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,A,f)=>{var T;const N=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??A??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:l,handleSelect:o,defaultValue:N,value:N})},t.id)})},g=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:l,onChange:o})},t.id)}),O=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:A||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:A||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)}),x=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,A):g(t,f,A);case se.MULTILINE:return g(t,f,A);case se.SELECT:return y(t,f,A);case se.DATE:return O(t,f,A);case se.BOOLEAN:return L(t,f,A);case se.TEXTAREA:return x(t,f,A);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(we,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},_t=()=>j(we,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:o,children:i,className:l="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:A,formData:f,errors:N,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:S,handleValidationSubmit:H,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const B=me(T);return{handleValidationSubmit:H,formData:ae(B,!0),isDataValid:A}}),n||!(c!=null&&c.length)?a(_t,{}):j("form",{className:X(["account-form",l]),onSubmit:S,name:d,ref:T,children:[a(Nt,{className:l,loading:o,fields:c,onChange:Z,onBlur:z,errors:N,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:B=>{Z(B),L==null||L(B)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:i,addressData:l,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=o?"minifiedView":"fullSizeView",O=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),x=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=Ne(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),N=Ne(()=>{u==null||u(l==null?void 0:l.id),y==null||y()},[y,l==null?void 0:l.id,u]),T=be(()=>{if(!i)return[];const{region:C,...B}=l,q={...B,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,i]),{shippingLabel:Z,billingLabel:z,hideShipping:S,hideBilling:H}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:O.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:N,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,B)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${B}`,children:q},B)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:x}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!S&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!H&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>G.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",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.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"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),Ot=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return j(l,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},It=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:o,closeModal:i})=>{const l=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${l}.Addresses.removeAddressModal.title`,description:`Account.${l}.Addresses.removeAddressModal.description`,actionCancel:`Account.${l}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${l}.Addresses.removeAddressModal.actionConfirm`});return r?j(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:o,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",o=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Ot,text:a("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!i.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],r1=["email","firstname","lastname","middlename","gender","date_of_birth","prefix","suffix","fax"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:i})=>{const[l,c]=_(""),[u,p]=_(!1),[y,g]=_(!1),[O,L]=_(!1),[x,t]=_(!1),[A,f]=_(!1),[N,T]=_(""),[Z,z]=_([]),[S,H]=_([]),C=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(m=>{const[$,U]=m;if($){const w=$.map(({name:R,orderNumber:te,label:re})=>({name:rt(R),orderNumber:te,label:St.includes(R)?null:re}));H(w)}if(U)if(d){const w=U.filter(R=>!!R.defaultShipping||!!R.defaultBilling);z(w)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var m;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(w=>+w.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((m=$==null?void 0:$.id)==null?void 0:m.toString())),r==null||r(U)}},[Z,n,r,s,e]);const B=k(m=>{T(m),f(!1)},[]),q=k((m,$)=>{const U=(m==null?void 0:m.target).value,w=(m==null?void 0:m.target).nextSibling;c(U);const R={data:ae($),isDataValid:!ve(ae($))};r==null||r(R),f(U==="0"),w&&(w.focus(),window.scrollBy(0,100))},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),h=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(N,Z),st(+N).then(()=>{C(),K()}).finally(()=>{t(!1)})},[Z,N,K,C]),b=k(()=>{f(!1)},[]),M=k(()=>{ze(o)&&d&&!A?window.location.href=o():(f(!0),T(""))},[A,o,d]),I=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:S,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:O,addNewAddress:A,addressesList:Z,addressId:N,handleRenderForm:P,handleRenderModal:h,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:B,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:I,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:o="",showFormLoader:i=!1,onAddressData:l,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:O=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:N,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:S=!0,routeAddressesPage:H,onSuccess:C,onError:B})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:I,addressesList:m,addressId:$,handleRenderForm:U,handleRenderModal:w,removeAddress:R,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:o,minifiedView:t,routeAddressesPage:H,onSuccess:C,onAddressData:l,selectShipping:g,selectBilling:O}),V=s??(g&&O?"selectedAddress":g?"selectedShippingAddress":O?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(m,g,O))==null?void 0:J.map((E,Y)=>j(_e,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:V,id:`${V}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${V}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:O,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:V,id:`${V}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${V}_addressActions`,className:"account-addresses-wrapper__label",children:I?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",I]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:V,showFormLoader:i,isOpen:I,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l})}):m!=null&&m.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:I,routeAddressesPage:ie}):null})]}):j(Q,{children:[m.map(E=>a(_e,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:te,onSuccess:re,onError:B})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&A||!t&&f?w:void 0,handleRenderForm:t&&A||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:I?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:I,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:oe,onSuccess:re,onError:B})}):a(Fe,{minifiedView:t,addNewAddress:I,routeAddressesPage:ie})})]});return j("div",{children:[a("div",{children:x?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(It,{minifiedView:t,addressData:m==null?void 0:m.find(E=>E.id===$),keysSortOrder:K,submitLoading:h,open:v,closeModal:te,onRemoveAddress:R}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:V,isOpen:!(m!=null&&m.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l}):a(xt,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const o=r[n.customUpperCode];n.customUpperCode==="region"&&typeof o=="object"?d.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:d.defaultValue=o}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:o,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(o=>{n.includes(o)?r[o]=e[o]:d.push({attribute_code:Ve(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Ie=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=Be(x)),s.includes(L)&&r.push(x)}const{street:o,streetMultiline_2:i,streetMultiline_1:l,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const o=s.find(i=>(i==null?void 0:i.id)===d.regionId);o?n[r]={...d,text:o.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((o,i)=>{n[`${r}Multiline_${i+2}`]=o})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:i,showBillingCheckBox:l,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[O,L]=_({text:"",type:"success"}),[x,t]=_(e??!1),[A,f]=_(r||""),[N,T]=_([]),[Z,z]=_([]),[S,H]=_([]),[C,B]=_([]),[q,P]=_([]),[K,h]=_(!1),[v,b]=_(!1),[M,I]=_(()=>{var V,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(V=JSON.parse(F))==null?void 0:V.data)==null?void 0:W.countryCode}:c}),[m,$]=_(!1),[U,w]=_(!1),[R,te]=_(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[A]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:V,optionalZipCountries:W})=>{z(F),B(V),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),w(!0);const F=M==null?void 0:M.countryCode;at(F).then(V=>{H(V);const W=C.find(E=>E===F),J=q.find(E=>E===F);h(!!W),b(!J),$(!1),w(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,V)=>{if(!V)return null;t(!0);const W=Oe(F.target),J=Ie(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,V)=>{if(!V)return;t(!0);const{saveAddressBook:W,...J}=Oe(F.target),E=Ie(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=et(()=>{if(!N.length)return[];const F={...Vt,defaultValue:o,isHidden:s&&!R?!0:!i},V={...Ht,defaultValue:d,isHidden:s&&!R?!0:!l},W=[...N,F,V],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,S):{},Y=Bt(qt(E,c),W);return zt({fields:Y,addressId:A,countryOptions:Z,disableField:m,regionOptions:S,isRequiredRegion:K,isRequiredPostCode:v})},[N,o,s,R,i,d,l,g,S,c,A,Z,m,K,v]),ue=k(F=>{I(V=>({...V,...F}))},[]);return{isWaitingForResponse:U,regionOptions:S,saveCheckBoxAddress:R,inLineAlert:O,addressId:A,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},jt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(s[o.code]=o.value)});const{customAttributes:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:S,addressId:H,submitLoading:C,normalizeFieldsConfig:B,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:N,onCloseBtnClick:A,formName:s});return x?j("div",{className:X(["account-address-form-wrapper",c]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,S.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:S.type,variant:"secondary",heading:S.text,icon:S.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:o,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:B,onSubmit:t||(H?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[H?a("input",{type:"hidden",name:"addressId",value:H,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:H}}):a(Q,{children:r?null:j(Q,{children:[a(de,{type:"button",onClick:K,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,xt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Oe as g,Ut as n}; diff --git a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js index 84ca43ae12..12b10de16d 100644 --- a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js +++ b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js @@ -1,124 +1,138 @@ -import{t as u,k as i,f as _,l as f,m as p}from"./removeCustomerAddress.js";const g=(r,a="en-US",s={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},e=new Date(r);return isNaN(e.getTime())?"Invalid Date":new Intl.DateTimeFormat(a,t).format(e)},y=r=>{var d,c;if(!((c=(d=r.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:a,page_info:s,total_count:o,date_of_first_order:t}=r.data.customer.orders,{returns:e}=r.data.customer;return{items:a.map(n=>{const l={...n,returns:e==null?void 0:e.items.filter(m=>m.order.id===n.id),order_date:g(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(t,"camelCase",{})}},h=` -fragment AddressesList on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id -}`,O=` -fragment OrderSummary on OrderTotal { - __typename - grand_total { - value - currency +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{t as T,m as s,f as A,l as M}from"./removeCustomerAddress.js";import{c as C}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as v}from"@dropins/tools/lib.js";const I=(t,r="en-US",a={})=>{const e={...{day:"2-digit",month:"2-digit",year:"numeric"},...a},d=new Date(t);return isNaN(d.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,e).format(d)},N=t=>{var m,u,l,_,f,g,p,R,E,S,n,y;if(!((u=(m=t.data)==null?void 0:m.customer)!=null&&u.orders))return null;const{page_info:r,total_count:a,date_of_first_order:i}=t.data.customer.orders,e=((_=(l=t==null?void 0:t.data)==null?void 0:l.customer)==null?void 0:_.returns)??[],c={items:(((p=(g=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:g.orders)==null?void 0:p.items)??[]).map(o=>{var O;const D={...o,returns:(O=e==null?void 0:e.items)==null?void 0:O.filter(h=>h.order.id===o.id),order_date:I(o.order_date),shipping_address:T(o.shipping_address),billing_address:T(o.billing_address)};return s(D,"camelCase",{})}),pageInfo:s(r,"camelCase",{}),totalCount:s(a,"camelCase",{}),dateOfFirstOrder:s(i,"camelCase",{})};return v(c,(y=(n=(S=(E=(R=C)==null?void 0:R.getConfig())==null?void 0:E.models)==null?void 0:S.OrderHistoryModel)==null?void 0:n.transformer)==null?void 0:y.call(n,t.data))},b=` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id } - subtotal { - currency - value - } - taxes { - amount { - currency +`,G=` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + __typename + grand_total { value + currency } - rate - title - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { + subtotal { currency value } - label - } -}`,S=` - query GET_CUSTOMER_ORDERS_LIST($currentPage: Int, $pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) { - customer { - returns { - items { - uid - number - order { - id - } + taxes { + amount { + currency + value } + rate + title } - orders(currentPage: $currentPage, pageSize: $pageSize, filter: $filter, sort: $sort) { - page_info { - page_size - total_pages - current_page + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value } - date_of_first_order - total_count - items { - token - email - shipping_method - payment_methods { - name - type - } - shipping_address { - ...AddressesList - } - billing_address { - ...AddressesList - } - shipments { - id - number - tracking { - title + label + } + } +`,F=` + query GET_CUSTOMER_ORDERS_LIST( + $currentPage: Int + $pageSize: Int + $filter: CustomerOrdersFilterInput + $sort: CustomerOrderSortInput + ) { + customer { + returns { + items { + uid number - carrier + order { + id } } - number - id - order_date - carrier - status + } + orders( + currentPage: $currentPage + pageSize: $pageSize + filter: $filter + sort: $sort + ) { + page_info { + page_size + total_pages + current_page + } + date_of_first_order + total_count items { - status - product_name + token + email + shipping_method + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + shipments { + id + number + tracking { + title + number + carrier + } + } + number id - quantity_ordered - quantity_shipped - quantity_invoiced - product { - sku - url_key - small_image { - url + order_date + carrier + status + items { + status + product_name + id + quantity_ordered + quantity_shipped + quantity_invoiced + product { + sku + url_key + small_image { + url + } } } - } - total { - ...OrderSummary + total { + ...ORDER_SUMMARY_FRAGMENT + } } } } } -} -${h} -${O} -`,E={sort_direction:"DESC",sort_field:"CREATED_AT"},C=async(r,a,s)=>{const o=a.includes("viewAll")?{}:{order_date:JSON.parse(a)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:r,currentPage:s,filter:o,sort:E}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?f(t.errors):y(t)}).catch(p)};export{C as g}; + ${b} + ${G} +`,$={sort_direction:"DESC",sort_field:"CREATED_AT"},L=async(t,r,a)=>{const i=r.includes("viewAll")?{}:{order_date:JSON.parse(r)};return await A(F,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:a,filter:i,sort:$}}).then(e=>N(e)).catch(M)};export{L as g}; diff --git a/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js new file mode 100644 index 0000000000..f4d640d7a5 --- /dev/null +++ b/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js @@ -0,0 +1,12 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{Initializer as f}from"@dropins/tools/lib.js";import{f as h,k as _,l as g}from"./removeCustomerAddress.js";const c=new f({init:async t=>{const r={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};c.config.setConfig({...r,...t})},listeners:()=>[]}),C=c.config,l=t=>{var r,a,i,e,o,n;return{baseMediaUrl:(a=(r=t==null?void 0:t.data)==null?void 0:r.storeConfig)==null?void 0:a.base_media_url,minLength:+((e=(i=t==null?void 0:t.data)==null?void 0:i.storeConfig)==null?void 0:e.minimum_password_length)||3,requiredCharacterClasses:+((n=(o=t==null?void 0:t.data)==null?void 0:o.storeConfig)==null?void 0:n.required_character_classes_number)||0}},m=` + query GET_STORE_CONFIG { + storeConfig { + base_media_url + autocomplete_on_storefront + minimum_password_length + required_character_classes_number + } + } +`,s=async()=>await h(m,{method:"GET",cache:"force-cache"}).then(t=>{var r;return(r=t.errors)!=null&&r.length?_(t.errors):l(t)}).catch(g);export{C as c,s as g,c as i}; diff --git a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js index 9a1dcf7657..ddfc72ff9a 100644 --- a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js +++ b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js @@ -1,4 +1,6 @@ -import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),A=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:A;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?a(i,e,r):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,_])=>{const u=r&&r[c]?r[c]:o(c);return i[u]=n.includes(typeof _)||_===null?_:a(_,e,r),i},{}):t},{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),p=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}from"@dropins/tools/fetch-graphql.js";const S=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),g=(t,n,e)=>{const r=["string","boolean","number"],o=n==="camelCase"?S:p;return Array.isArray(t)?t.map(i=>r.includes(typeof i)||i===null?i:typeof i=="object"?g(i,n,e):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,a])=>{const u=e&&e[c]?e[c]:o(c);return i[u]=r.includes(typeof a)||a===null?a:g(a,n,e),i},{}):t},{setEndpoint:k,setFetchGraphQlHeader:H,removeFetchGraphQlHeader:J,setFetchGraphQlHeaders:K,fetchGraphQl:s,getConfig:L}=new C().getMethods(),T=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -30,9 +32,9 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,R=` +`,A=` query GET_ATTRIBUTES_FORM_SHORT { - attributesForm(formCode: "customer_register_address") { + attributesForm(formCode: "customer_register_address") { items { frontend_input label @@ -44,18 +46,22 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},h=t=>{const e=t.map(r=>r.message).join(" ");throw Error(e)},S=t=>{let e=[];for(const r of t)if(!(r.frontend_input!=="MULTILINE"||r.multiline_count<2))for(let n=2;n<=r.multiline_count;n++){const o={...r,is_required:!1,name:`${r.code}_multiline_${n}`,code:`${r.code}_multiline_${n}`,id:`${r.code}_multiline_${n}`};e.push(o)}return e},y=t=>{var i,c,_;const e=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const r=(_=e.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:_.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),n=S(r);return r.concat(n).map(u=>{var g;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),m=(g=u.options)==null?void 0:g.map(E=>({isDefault:E.is_default,text:E.label,value:E.value}));return a({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const e={};for(const r in t){const n=t[r];!Array.isArray(n)||n.length===0||(r==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(e[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?e[r]=o:e[`${r}_multiline_${i+1}`]=o}):e[r]=n[0])}return e},d=t=>{var e,r,n;return a({firstname:(t==null?void 0:t.firstname)||"",lastname:(t==null?void 0:t.lastname)||"",city:(t==null?void 0:t.city)||"",company:(t==null?void 0:t.company)||"",country_code:(t==null?void 0:t.country_code)||"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)||"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)||"",region_id:((n=t==null?void 0:t.region)==null?void 0:n.region_id)||""},telephone:(t==null?void 0:t.telephone)||"",id:(t==null?void 0:t.id)||"",vat_id:(t==null?void 0:t.vat_id)||"",postcode:(t==null?void 0:t.postcode)||"",default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},O=t=>{var r,n;const e=((n=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:n.addresses)||[];return e.length?e.map(d).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},$=t=>{var c,_;if(!((_=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&_.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:e,storeConfig:r}=t.data,n=r==null?void 0:r.countries_with_required_region.split(","),o=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:e.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:n,optionalZipCountries:o}},N=t=>{var r,n;return(n=(r=t==null?void 0:t.data)==null?void 0:r.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:_}=o;return!!(i&&c&&_)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>await s(t!=="shortRequest"?p:R,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):y(e)}).catch(f),G=` +`,_=t=>{throw t instanceof DOMException&&t.name==="AbortError"||b.emit("error",{source:"auth",type:"network",error:t}),t},f=t=>{const n=t.map(e=>e.message).join(" ");throw Error(n)},y=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let r=2;r<=e.multiline_count;r++){const o={...e,is_required:!1,name:`${e.code}_multiline_${r}`,code:`${e.code}_multiline_${r}`,id:`${e.code}_multiline_${r}`};n.push(o)}return n},R=t=>{var i,c,a;const n=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!n.length)return[];const e=(a=n.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:a.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),r=y(e);return e.concat(r).map(u=>{var E;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":S(u.code),m=(E=u.options)==null?void 0:E.map(h=>({isDefault:h.is_default,text:h.label,value:h.value}));return g({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const n={};for(const e in t){const r=t[e];!Array.isArray(r)||r.length===0||(e==="custom_attributesV2"?r.forEach(o=>{typeof o=="object"&&"value"in o&&(n[o==null?void 0:o.code]=o==null?void 0:o.value)}):r.length>1?r.forEach((o,i)=>{i===0?n[e]=o:n[`${e}_multiline_${i+1}`]=o}):n[e]=r[0])}return n},N=t=>({prefix:(t==null?void 0:t.prefix)??"",suffix:(t==null?void 0:t.suffix)??"",firstname:(t==null?void 0:t.firstname)??"",lastname:(t==null?void 0:t.lastname)??"",middlename:(t==null?void 0:t.middlename)??""}),O=t=>({id:(t==null?void 0:t.id)??"",vat_id:(t==null?void 0:t.vat_id)??"",postcode:(t==null?void 0:t.postcode)??"",country_code:(t==null?void 0:t.country_code)??""}),I=t=>({company:(t==null?void 0:t.company)??"",telephone:(t==null?void 0:t.telephone)??"",fax:(t==null?void 0:t.fax)??""}),$=t=>{var e,r,o;return g({...N(t),...O(t),...I(t),city:(t==null?void 0:t.city)??"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)??"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)??"",region_id:((o=t==null?void 0:t.region)==null?void 0:o.region_id)??""},default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},G=t=>{var r,o;const n=((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.addresses)||[];return n.length?n.map($).sort((i,c)=>(Number(c.defaultBilling)||Number(c.defaultShipping))-(Number(i.defaultBilling)||Number(i.defaultShipping))):[]},M=t=>{var c,a;if(!((a=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&a.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:n,storeConfig:e}=t.data,r=e==null?void 0:e.countries_with_required_region.split(","),o=e==null?void 0:e.optional_zip_countries.split(",");return{availableCountries:n.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:r,optionalZipCountries:o}},U=t=>{var e,r;return(r=(e=t==null?void 0:t.data)==null?void 0:e.country)!=null&&r.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:a}=o;return!!(i&&c&&a)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},P=async t=>{const n=`_account_attributesForm_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(t!=="shortRequest"?T:A,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=R(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},w=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { - createCustomerAddress(input:$input) { + createCustomerAddress(input: $input) { firstname } } -`,L=async t=>await s(G,{method:"POST",variables:{input:a(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(e=>{var r,n,o;return(r=e.errors)!=null&&r.length?h(e.errors):((o=(n=e==null?void 0:e.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),I=` +`,d=async t=>await s(w,{method:"POST",variables:{input:g(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(n=>{var e,r,o;return(e=n.errors)!=null&&e.length?f(n.errors):((o=(r=n==null?void 0:n.data)==null?void 0:r.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(_),x=` query GET_CUSTOMER_ADDRESS { customer { addresses { firstname lastname + middlename + fax + prefix + suffix city company country_code @@ -80,7 +86,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,P=async()=>await s(I,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):O(t)}).catch(f),M=` +`,z=async()=>await s(x,{method:"GET",cache:"no-cache"}).then(t=>{var n;return(n=t.errors)!=null&&n.length?f(t.errors):G(t)}).catch(_),F=` query GET_COUNTRIES_QUERY { countries { two_letter_abbreviation @@ -91,7 +97,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr optional_zip_countries } } -`,z=async()=>await s(M,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):$(t)}).catch(f),U=` +`,Z=async()=>{const t="_account_countries",n=sessionStorage.getItem(t);return n?JSON.parse(n):await s(F,{method:"GET",cache:"no-cache"}).then(e=>{var o;if((o=e.errors)!=null&&o.length)return f(e.errors);const r=M(e);return sessionStorage.setItem(t,JSON.stringify(r)),r}).catch(_)},q=` query GET_REGIONS($countryCode: String!) { country(id: $countryCode) { id @@ -102,15 +108,14 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,Z=async t=>await s(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):N(e)}).catch(f),w=` - mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, - $input: CustomerAddressInput) { - updateCustomerAddress(id:$id, input:$input) { +`,W=async t=>{const n=`_account_regions_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(q,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=U(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},V=` + mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, $input: CustomerAddressInput) { + updateCustomerAddress(id: $id, input: $input) { firstname - } + } } -`,K=async t=>{const{addressId:e,...r}=t;return e?await s(w,{method:"POST",variables:{id:e,input:a(r,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(n=>{var o,i,c;return(o=n.errors)!=null&&o.length?h(n.errors):((c=(i=n==null?void 0:n.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(f):""},q=` +`,Y=async t=>{const{addressId:n,...e}=t;return n?await s(V,{method:"POST",variables:{id:n,input:g(e,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(r=>{var o,i,c;return(o=r.errors)!=null&&o.length?f(r.errors):((c=(i=r==null?void 0:r.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(_):""},B=` mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) { - deleteCustomerAddress(id:$id) + deleteCustomerAddress(id: $id) } -`,W=async t=>await s(q,{method:"POST",variables:{id:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):e.data.deleteCustomerAddress}).catch(f);export{B as a,j as b,H as c,L as d,P as e,s as f,k as g,z as h,Z as i,W as j,a as k,h as l,f as m,b as n,A as o,Q as r,x as s,d as t,K as u}; +`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,f as k,_ as l,g as m,S as n,p as o,J as r,k as s,$ as t,Y as u}; diff --git a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js index bf2d67bd23..5452afb2cd 100644 --- a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js +++ b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js @@ -1,7 +1,8 @@ -import{n as $,f as d,l,m as _,k as I}from"./removeCustomerAddress.js";const y=t=>{var r,m,u,c,i,h,C,f,o,e,E,g,T,S,w,n,O,P,b,A,R,U,N;const a=(u=(m=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:m.custom_attributes)==null?void 0:u.reduce((G,M)=>(G[$(M.code)]=M.value??"",G),{});return{email:((i=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:i.email)||"",firstName:((C=(h=t==null?void 0:t.data)==null?void 0:h.customer)==null?void 0:C.firstname)||"",lastName:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.lastname)||"",middleName:((E=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:E.middlename)||"",gender:(T=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:T.gender,dob:((w=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:w.dob)||"",dateOfBirth:((O=(n=t==null?void 0:t.data)==null?void 0:n.customer)==null?void 0:O.date_of_birth)||"",prefix:((b=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:b.prefix)||"",suffix:((R=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:R.suffix)||"",createdAt:((N=(U=t==null?void 0:t.data)==null?void 0:U.customer)==null?void 0:N.created_at)||"",...a}},v=t=>{var a,r,m,u;return{minLength:+((r=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:r.minimum_password_length)||3,requiredCharacterClasses:+((u=(m=t==null?void 0:t.data)==null?void 0:m.storeConfig)==null?void 0:u.required_character_classes_number)||0}},x=` - fragment BasicCustomerInfo on Customer { +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";import{c as y}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as V}from"@dropins/tools/lib.js";const B=t=>{var r,u,i,d,f,o,e,E,h,S,T,g,w,O,A,P,M,R,U,N,n,b,$,G,c,I;const m=(i=(u=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:u.custom_attributes)==null?void 0:i.reduce((v,x)=>(v[D(x.code)]=x.value??"",v),{}),a={email:((f=(d=t==null?void 0:t.data)==null?void 0:d.customer)==null?void 0:f.email)||"",firstName:((e=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:e.firstname)||"",lastName:((h=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:h.lastname)||"",middleName:((T=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:T.middlename)||"",gender:((w=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:w.gender)||"1",dateOfBirth:((A=(O=t==null?void 0:t.data)==null?void 0:O.customer)==null?void 0:A.date_of_birth)||"",prefix:((M=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:M.prefix)||"",suffix:((U=(R=t==null?void 0:t.data)==null?void 0:R.customer)==null?void 0:U.suffix)||"",createdAt:((n=(N=t==null?void 0:t.data)==null?void 0:N.customer)==null?void 0:n.created_at)||"",...m};return V(a,(I=(c=(G=($=(b=y)==null?void 0:b.getConfig())==null?void 0:$.models)==null?void 0:G.CustomerDataModelShort)==null?void 0:c.transformer)==null?void 0:I.call(c,t.data))},k=` + fragment BASIC_CUSTOMER_INFO_FRAGMENT on Customer { date_of_birth - dob email firstname gender @@ -11,47 +12,46 @@ import{n as $,f as d,l,m as _,k as I}from"./removeCustomerAddress.js";const y=t= suffix created_at } -`,D=` +`,L=` query GET_CUSTOMER { - customer { - ...BasicCustomerInfo + customer { + ...BASIC_CUSTOMER_INFO_FRAGMENT custom_attributes { - ... on AttributeValue { + ... on AttributeValue { + code + value + } code - value } - code - } } } -${x}`,k=async()=>await d(D,{method:"GET",cache:"no-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):y(t)}).catch(_),q=` - mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) { - changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) { + ${k} +`,J=async()=>await l(L,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?C(t.errors):B(t)}).catch(_),H=` + mutation CHANGE_CUSTOMER_PASSWORD( + $currentPassword: String! + $newPassword: String! + ) { + changeCustomerPassword( + currentPassword: $currentPassword + newPassword: $newPassword + ) { email } } -`,H=async({currentPassword:t,newPassword:a})=>await d(q,{method:"POST",variables:{currentPassword:t,newPassword:a}}).then(r=>{var m,u,c;return(m=r.errors)!=null&&m.length?l(r.errors):((c=(u=r==null?void 0:r.data)==null?void 0:u.changeCustomerPassword)==null?void 0:c.email)||""}).catch(_),F=` - query GET_STORE_CONFIG { - storeConfig { - autocomplete_on_storefront - minimum_password_length - required_character_classes_number - } - } -`,W=async()=>await d(F,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):v(t)}).catch(_),V=` - mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) { - updateCustomerEmail(email:$email password:$password) { +`,X=async({currentPassword:t,newPassword:m})=>await l(H,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var r,u,i;return(r=a.errors)!=null&&r.length?C(a.errors):((i=(u=a==null?void 0:a.data)==null?void 0:u.changeCustomerPassword)==null?void 0:i.email)||""}).catch(_),W=` + mutation UPDATE_CUSTOMER_EMAIL($email: String!, $password: String!) { + updateCustomerEmail(email: $email, password: $password) { customer { - email + email } } } -`,K=async({email:t,password:a})=>await d(V,{method:"POST",variables:{email:t,password:a}}).then(r=>{var m,u,c,i;return(m=r.errors)!=null&&m.length?l(r.errors):((i=(c=(u=r==null?void 0:r.data)==null?void 0:u.updateCustomerEmail)==null?void 0:c.customer)==null?void 0:i.email)||""}).catch(_),B=` +`,Y=async({email:t,password:m})=>await l(W,{method:"POST",variables:{email:t,password:m}}).then(a=>{var r,u,i,d;return(r=a.errors)!=null&&r.length?C(a.errors):((d=(i=(u=a==null?void 0:a.data)==null?void 0:u.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(_),q=` mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) { - updateCustomerV2(input:$input) { + updateCustomerV2(input: $input) { customer { - email + email } } } -`,Q=async t=>await d(B,{method:"POST",variables:{input:I(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(a=>{var r,m,u,c;return(r=a.errors)!=null&&r.length?l(a.errors):((c=(u=(m=a==null?void 0:a.data)==null?void 0:m.updateCustomerV2)==null?void 0:u.customer)==null?void 0:c.email)||""}).catch(_);export{W as a,K as b,Q as c,k as g,H as u}; +`,Z=async t=>await l(q,{method:"POST",variables:{input:F(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,r,u,i;return(a=m.errors)!=null&&a.length?C(m.errors):((i=(u=(r=m==null?void 0:m.data)==null?void 0:r.updateCustomerV2)==null?void 0:u.customer)==null?void 0:i.email)||""}).catch(_);export{Y as a,Z as b,J as g,X as u}; diff --git a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts index c985d9cdcf..e1e41541a6 100644 --- a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts +++ b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts @@ -94,6 +94,10 @@ export declare const mockDefaultAddress: { streetMultiline_2: string; defaultShipping: boolean; defaultBilling: boolean; + fax: string; + middlename: string; + prefix: string; + suffix: string; }; export declare const mockResponseAddressWithText: { firstname: string; @@ -114,45 +118,10 @@ export declare const mockResponseAddressWithText: { default_shipping: boolean; default_billing: boolean; custom_attributesV2: never[]; -}; -export declare const mockResponseAddressEmpty: { - firstname: string; - lastname: string; - city: string; - company: string; - country_code: string; - region: { - region: string; - region_code: string; - region_id: string; - }; - telephone: string; - id: string; - vat_id: string; - postcode: string; - street: string[]; - default_shipping: boolean; - default_billing: boolean; - custom_attributesV2: never[]; -}; -export declare const mockDefaultAddressEmpty: { - firstname: string; - lastname: string; - city: string; - company: string; - countryCode: string; - region: { - region: string; - regionCode: string; - regionId: string; - }; - telephone: string; - id: string; - vatId: string; - postcode: string; - street: string; - defaultShipping: boolean; - defaultBilling: boolean; + fax: string; + middlename: string; + prefix: string; + suffix: string; }; export declare const mockResponseCountries: { two_letter_abbreviation: string; diff --git a/scripts/__dropins__/storefront-account/containers/AddressForm.js b/scripts/__dropins__/storefront-account/containers/AddressForm.js index 154dd81c21..9284ac8a3d 100644 --- a/scripts/__dropins__/storefront-account/containers/AddressForm.js +++ b/scripts/__dropins__/storefront-account/containers/AddressForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{A as l,A as u}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";export{l as AddressForm,u as default}; diff --git a/scripts/__dropins__/storefront-account/containers/Addresses.js b/scripts/__dropins__/storefront-account/containers/Addresses.js index 79553d3545..836ce978cc 100644 --- a/scripts/__dropins__/storefront-account/containers/Addresses.js +++ b/scripts/__dropins__/storefront-account/containers/Addresses.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B}from"@dropins/tools/lib.js";import{a as C}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const O=({hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,forwardFormRef:a,showSaveCheckBox:c,saveCheckBoxValue:f,selectShipping:n,selectBilling:l,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,showShippingCheckBox:W,showBillingCheckBox:b,shippingCheckBoxValue:g,billingCheckBoxValue:k,onAddressData:q,routeAddressesPage:w,onSuccess:y,onError:z})=>s("div",{className:B(["account-addresses",r]),"data-testid":"addressesid",children:s(C,{hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,onAddressData:q,forwardFormRef:a,selectShipping:n,selectBilling:l,showSaveCheckBox:c,saveCheckBoxValue:f,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,billingCheckBoxValue:k,shippingCheckBoxValue:g,showBillingCheckBox:b,showShippingCheckBox:W,routeAddressesPage:w,onSuccess:y,onError:z})});export{O as Addresses,O as default}; diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js index 6e7d20a894..f1c2c438af 100644 --- a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js @@ -1 +1,3 @@ -import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{a as Ce,u as Pe,g as pe,c as ee,b as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Re=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Re as CustomerInformation,Re as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ce}from"../chunks/getStoreConfig.js";import{u as Pe,g as pe,b as ee,a as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Je=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Je as CustomerInformation,Je as default}; diff --git a/scripts/__dropins__/storefront-account/containers/OrdersList.js b/scripts/__dropins__/storefront-account/containers/OrdersList.js index ee1cfb13ef..4b594a5824 100644 --- a/scripts/__dropins__/storefront-account/containers/OrdersList.js +++ b/scripts/__dropins__/storefront-account/containers/OrdersList.js @@ -1 +1,3 @@ -import{jsx as t,jsxs as L,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as F}from"@dropins/tools/lib.js";import{S as Y,c as J,E as V,C as W}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as K,Icon as D,ContentGrid as j,Image as E,Header as G,Picker as U,Pagination as m}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";import{useState as v,useEffect as z,useMemo as Q,useCallback as H}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as R}from"../chunks/getOrderHistoryList.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const q={size:"32",stroke:"2"},B=({minifiedView:n,orderNumber:r,orderToken:e,routeOrdersList:a,routeOrderDetails:d})=>{const i=n?"minifiedView":"fullSizeView",h=I({viewAllOrdersButton:`Account.${i}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${i}.OrdersList.ariaLabelLink`});return a?t("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",n]]),"data-testid":"ordersListActionButtonMinifiedView",href:a(),children:t(K,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:L("div",{className:"account-orders-list-action__card-wrapper",children:[t("p",{children:h.viewAllOrdersButton}),t(D,{source:Y,...q})]})})}):t("a",{"aria-label":`${h.ariaLabelLink} ${r??e}`,href:J(d)?d(r,e):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:t(D,{source:Y,...q})})},X=()=>{const[n,r]=v(window.innerWidth<768);return z(()=>{const e=()=>{r(window.innerWidth<768)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),n},Z=({minifiedView:n,item:r,withThumbnails:e,children:a,slots:d,routeTracking:i,routeOrderProduct:h,routeReturnDetails:O,...A})=>{var S,y,$,_,k,w,x,M,g;const p=n?"minifiedView":"fullSizeView",o=I({orderNumber:`Account.${p}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${p}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${p}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${p}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${p}.OrdersList.OrdersListCard.orderDate`}),f=X(),c=J(h);return L(K,{variant:"secondary",...A,className:C(["account-orders-list-card",["account-orders-list-card--full",((S=r==null?void 0:r.items)==null?void 0:S.length)>6]]),children:[t("div",{className:"account-orders-list-card__content",children:d!=null&&d.OrdersListCard?t(F,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:d==null?void 0:d.OrdersListCard,context:{orderHistoryListItem:r}}):L(N,{children:[t("div",{children:r==null?void 0:r.status}),L("p",{children:[o.deliveryDateText," ",r==null?void 0:r.orderDate]}),L("p",{children:[o.orderNumber," ",r.number]}),(y=r==null?void 0:r.shipments)==null?void 0:y.map(s=>{var l;return(l=s==null?void 0:s.tracking)==null?void 0:l.map(u=>{const b=i==null?void 0:i(u);return L("p",{"data-testid":u.number,children:[t("span",{children:`${o.carrier} ${u.carrier.toLocaleUpperCase()} `}),b?t("a",{href:b,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:u.number}):t("span",{className:"account-orders-list-card__content--track_number",children:u.number})]},s.id)})}),r!=null&&r.returns&&(($=r.returns)!=null&&$.length)?L("p",{"data-testid":r.number,children:[L("span",{children:[o.returnsText," "]}),(_=r==null?void 0:r.returns)==null?void 0:_.map(s=>t("span",{"data-testid":s.number,children:L("a",{href:(O==null?void 0:O({orderNumber:r.number,orderToken:r.token,returnNumber:s.number}))??"#",className:"account-orders-list-card__content--return_number",children:[s.number," "]})},s.uid))]},r.id):null,L("p",{children:["$",(k=r==null?void 0:r.total)==null?void 0:k.grandTotal.value]}),L("p",{"data-testid":"itemsAmount",children:[(w=r==null?void 0:r.items)!=null&&w.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((s,l)=>{const u=(l==null?void 0:l.quantityOrdered)||0;return s+u},0):0," ",o.itemsAmount]}),(M=r==null?void 0:r.items)==null?void 0:M.map((s,l)=>{if(l>=0&&l<10)return L("p",{className:"account-orders-list-card__content--product-name",children:[L("span",{className:"account-orders-list-card__content--quantity",children:[(s==null?void 0:s.quantityOrdered)>1?s==null?void 0:s.quantityOrdered:null," "]}),s==null?void 0:s.productName.replaceAll("-"," ")]},`${l}_${s.id}`);if(l===11)return t("p",{children:"..."},"ellipsis")})]})}),e&&((g=r==null?void 0:r.items)!=null&&g.length)?t(j,{maxColumns:f?3:9,emptyGridContent:t(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",f]]),"data-testid":"ordersListCardImages",children:r.items.map((s,l)=>{var T;const u=(T=s==null?void 0:s.product)==null?void 0:T.smallImage.url,b=s==null?void 0:s.productName;return c?t("a",{href:h==null?void 0:h(s),target:"_blank",rel:"noreferrer",children:t(E,{src:u,width:65,height:65,alt:b})},s.id+l):t(E,{src:u,width:65,height:65,alt:b},s.id+l)})}):null,t("div",{className:"account-orders-list-card__actions",children:a})]})},rr=({ordersInMinifiedView:n,minifiedView:r,pageSize:e,selectedDate:a,selectedPage:d,handleSetFirstOrderDate:i})=>{const[h,O]=v([]),[A,p]=v({totalPages:1,currentPage:1,pageSize:1}),[o,f]=v(!1);return z(()=>{f(!0),R(r?n:e,a,d).then(c=>{!c||!c.items||(p(c.pageInfo),O(c.items),i==null||i(c.dateOfFirstOrder))}).finally(()=>{f(!1)})},[i,r,n,e,a,d]),{loading:o,orderHistoryListItems:h,pageInfo:A}},P=(n,r=1)=>{const e=new Date,a=new Date(e);switch(n){case"sixMonthsAgo":{a.setMonth(a.getMonth()-r);break}case"oneYearAgo":{a.setFullYear(a.getFullYear()-r);break}default:return""}return{from:a==null?void 0:a.toISOString().split("T")[0],to:`${e==null?void 0:e.toISOString().split("T")[0]} 23:59:59`}},tr=n=>{const r=[],e=new Date().getFullYear();for(let a=n;a<=e-1;a++)r.push({value:`{"from":"${a}-01-01","to":"${a+1}-01-01 23:59:59"}`,text:a.toString()});return r},sr=()=>{const n=I({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[r,e]=v(),[a,d]=v(JSON.stringify(P("sixMonthsAgo",6))),[i,h]=v(1);z(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[i]);const O=Q(()=>{const o=[{value:JSON.stringify(P("sixMonthsAgo",6)),text:n.pastSixMonths},{value:JSON.stringify(P("oneYearAgo",1)),text:n.currentYear},{value:"viewAll",text:n.viewAll}];if(r){const c=new Date(r).getFullYear();o==null||o.splice(2,0,...tr(c))}return o},[n,r]),A=H(o=>{e(o)},[]),p=H(o=>{const c=o.target.value;d(c),h(1)},[]);return{selectableDateList:O,selectedDate:a,selectedPage:i,handleSelectDate:p,setSelectedPage:h,handleSetFirstOrderDate:A}},er=({className:n,withHeader:r=!0,minifiedView:e=!1,withThumbnails:a=!0,withFilter:d=!0,ordersInMinifiedView:i=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})=>{const S=e?"minifiedView":"fullSizeView",y=I({containerTitle:`Account.${S}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${S}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:x,handleSetFirstOrderDate:M}=sr(),{pageInfo:g,loading:s,orderHistoryListItems:l}=rr({minifiedView:e,pageSize:h,ordersInMinifiedView:i,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:M});return L("div",{children:[r?t(G,{"aria-label":y.containerTitle,role:"region",title:y.containerTitle,divider:!e,className:e?"account-orders-list-header":""}):null,L("div",{className:C(["account-orders-list",n]),children:[!e&&d?L("div",{className:"account-orders-list__date-select",children:[t("span",{children:y.dateOrderPlaced}),t(U,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,s?t(N,{children:Array.from(Array(g==null?void 0:g.pageSize).keys()).map(u=>t(W,{testId:"orderSkeletonLoader",withCard:!1},u))}):t(N,{children:l.length?t(N,{children:l.map((u,b)=>t(Z,{routeTracking:o,routeOrderProduct:f,routeReturnDetails:p,minifiedView:e,item:u,withThumbnails:a,slots:c,children:c!=null&&c.OrdersListAction?t(F,{"data-testid":`ordersListActionSlot_${b}`,name:"OrdersListAction",slot:c==null?void 0:c.OrdersListAction,context:{orderHistoryListItem:u}}):t(B,{minifiedView:e,orderNumber:u.number,orderToken:u.token,routeOrderDetails:A})},b))}):t(V,{isEmpty:!l.length,typeList:"orders",minifiedView:e})}),!e&&(g==null?void 0:g.totalPages)>1?t(m,{totalPages:g==null?void 0:g.totalPages,currentPage:w,onChange:x}):null,e?t(B,{minifiedView:e,routeOrdersList:O}):null]})]})},Or=({className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})=>t("div",{className:C(["account-orders-list",n]),"data-testid":"ordersListId",children:t(er,{className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})});export{Or as OrdersList,Or as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as s,jsxs as u,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as j}from"@dropins/tools/lib.js";import{S as B,c as m,E as U,C as Q}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,ContentGrid as R,Image as J,Header as X,Picker as Z,Pagination as rr}from"@dropins/tools/components.js";import{useText as z}from"@dropins/tools/i18n.js";import{useState as S,useEffect as P,useMemo as tr,useCallback as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as sr}from"../chunks/getOrderHistoryList.js";import{g as er}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const V={size:"32",stroke:"2"},W=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:L})=>{const n=a?"minifiedView":"fullSizeView",h=z({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:h.viewAllOrdersButton}),s(F,{source:B,...V})]})})}):s("a",{"aria-label":`${h.ariaLabelLink} ${c??r}`,href:m(L)?L(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(F,{source:B,...V})})},ar=()=>{const[a,c]=S(window.innerWidth<768);return P(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},cr=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:L,slots:n,routeTracking:h,routeOrderProduct:O,routeReturnDetails:A,...b})=>{var p,$,_,k,w,I,x,f,M;const o=c?"minifiedView":"fullSizeView",g=z({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=ar(),y=m(O);return u(G,{variant:"secondary",...b,className:C(["account-orders-list-card",["account-orders-list-card--full",((p=r==null?void 0:r.items)==null?void 0:p.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(j,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):u(N,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[g.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[g.orderNumber," ",r.number]}),($=r==null?void 0:r.shipments)==null?void 0:$.map(t=>{var l;return(l=t==null?void 0:t.tracking)==null?void 0:l.map(i=>{const v=h==null?void 0:h(i);return u("p",{"data-testid":i.number,children:[s("span",{children:`${g.carrier} ${i.carrier.toLocaleUpperCase()} `}),v?s("a",{href:v,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:i.number}):s("span",{className:"account-orders-list-card__content--track_number",children:i.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[g.returnsText," "]}),(k=r==null?void 0:r.returns)==null?void 0:k.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(A==null?void 0:A({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,u("p",{children:["$",(w=r==null?void 0:r.total)==null?void 0:w.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[(I=r==null?void 0:r.items)!=null&&I.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((t,l)=>{const i=(l==null?void 0:l.quantityOrdered)||0;return t+i},0):0," ",g.itemsAmount]}),(f=r==null?void 0:r.items)==null?void 0:f.map((t,l)=>{if(l>=0&&l<10)return u("p",{className:"account-orders-list-card__content--product-name",children:[u("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${l}_${t.id}`);if(l===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((M=r==null?void 0:r.items)!=null&&M.length)?s(R,{maxColumns:d?3:9,emptyGridContent:s(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,l)=>{var Y,D,E,H,q;const i=(E=(D=(Y=t==null?void 0:t.product)==null?void 0:Y.smallImage)==null?void 0:D.url)!=null&&E.length?(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url:a,v=(t==null?void 0:t.productName)??"";return y?s("a",{href:(O==null?void 0:O(t))??"",target:"_blank",rel:"noreferrer",children:s(J,{src:i,width:65,height:65,alt:v})},t.id+l):s(J,{src:i,width:65,height:65,alt:v},t.id+l)})}):null,s("div",{className:"account-orders-list-card__actions",children:L})]})},nr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:L,handleSetFirstOrderDate:n})=>{const[h,O]=S([]),[A,b]=S({totalPages:1,currentPage:1,pageSize:1}),[o,g]=S(!1),[d,y]=S("");return P(()=>{er().then(p=>{y(p.baseMediaUrl)})},[]),P(()=>{g(!0),sr(c?a:r,e,L).then(p=>{!p||!p.items||(b(p.pageInfo),O(p.items),n==null||n(p.dateOfFirstOrder))}).finally(()=>{g(!1)})},[n,c,a,r,e,L]),{loading:o,orderHistoryListItems:h,pageInfo:A,placeholderImage:d}},T=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},or=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},dr=()=>{const a=z({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=S(),[e,L]=S(JSON.stringify(T("sixMonthsAgo",6))),[n,h]=S(1);P(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const O=tr(()=>{const o=[{value:JSON.stringify(T("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(T("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...or(d))}return o},[a,c]),A=K(o=>{r(o)},[]),b=K(o=>{const d=o.target.value;L(d),h(1)},[]);return{selectableDateList:O,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:h,handleSetFirstOrderDate:A}},ir=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:L=!0,ordersInMinifiedView:n=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>{const y=r?"minifiedView":"fullSizeView",p=z({containerTitle:`Account.${y}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${y}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:I,handleSetFirstOrderDate:x}=dr(),{pageInfo:f,loading:M,orderHistoryListItems:t,placeholderImage:l}=nr({minifiedView:r,pageSize:h,ordersInMinifiedView:n,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:x});return u("div",{children:[c?s(X,{"aria-label":p.containerTitle,role:"region",title:p.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",a]),children:[!r&&L?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:p.dateOrderPlaced}),s(Z,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,M?s(N,{children:Array.from(Array(f==null?void 0:f.pageSize).keys()).map(i=>s(Q,{testId:"orderSkeletonLoader",withCard:!1},i))}):s(N,{children:t.length?s(N,{children:t.map((i,v)=>s(cr,{placeholderImage:l,routeTracking:o,routeOrderProduct:g,routeReturnDetails:b,minifiedView:r,item:i,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(j,{"data-testid":`ordersListActionSlot_${v}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:i}}):s(W,{minifiedView:r,orderNumber:i.number,orderToken:i.token,routeOrderDetails:A})},v))}):s(U,{isEmpty:!t.length,typeList:"orders",minifiedView:r})}),!r&&(f==null?void 0:f.totalPages)>1?s(rr,{totalPages:f==null?void 0:f.totalPages,currentPage:w,onChange:I}):null,r?s(W,{minifiedView:r,routeOrdersList:O}):null]})]})},_r=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>s("div",{className:C(["account-orders-list",a]),"data-testid":"ordersListId",children:s(ir,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})});export{_r as OrdersList,_r as default}; diff --git a/scripts/__dropins__/storefront-account/data/models/customer.d.ts b/scripts/__dropins__/storefront-account/data/models/customer.d.ts index 31da09a4e5..c39c90e098 100644 --- a/scripts/__dropins__/storefront-account/data/models/customer.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/customer.d.ts @@ -3,7 +3,6 @@ export interface CustomerDataModelShort { lastName: string; middleName: string; dateOfBirth: string; - dob: string; prefix: string; gender: 1 | 2 | string; suffix: string; diff --git a/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts b/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts index 7bd14b2fc1..348728a07e 100644 --- a/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts @@ -71,7 +71,7 @@ export type PaginationInfo = { pageSize: number; totalPages: number; }; -export interface OrderHistory { +export interface OrderHistoryModel { items: OrderDetails[]; pageInfo: PaginationInfo; totalCount: number; diff --git a/scripts/__dropins__/storefront-account/data/models/store-config.d.ts b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts index 2f2ba6e973..d1252c83b8 100644 --- a/scripts/__dropins__/storefront-account/data/models/store-config.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts @@ -1,4 +1,5 @@ export interface StoreConfigModel { + baseMediaUrl: string; minLength: number; requiredCharacterClasses: number; } diff --git a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts index b87aad14d4..f623e26f76 100644 --- a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts +++ b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts @@ -1,7 +1,6 @@ import { CustomerAddressesModel } from '../models'; import { AddressResponse, UserAddressesProps } from '../../types'; -export declare const expandArraysInObject: (inputObject: UserAddressesProps) => Record; export declare const transformSingleAddress: (addressData: UserAddressesProps) => CustomerAddressesModel; export declare const transformMultipleAddresses: (response: AddressResponse) => CustomerAddressesModel[] | [ ]; diff --git a/scripts/__dropins__/storefront-account/data/transforms/transform-order-history-list.d.ts b/scripts/__dropins__/storefront-account/data/transforms/transform-order-history-list.d.ts index 90be3ab54c..9e4c769058 100644 --- a/scripts/__dropins__/storefront-account/data/transforms/transform-order-history-list.d.ts +++ b/scripts/__dropins__/storefront-account/data/transforms/transform-order-history-list.d.ts @@ -1,5 +1,5 @@ import { OrderHistoryListResponse } from '../../types'; -import { OrderHistory } from '../models'; +import { OrderHistoryModel } from '../models'; -export declare const transformOrderHistoryList: (response: OrderHistoryListResponse) => OrderHistory | null; +export declare const transformOrderHistoryList: (response: OrderHistoryListResponse) => OrderHistoryModel | null; //# sourceMappingURL=transform-order-history-list.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts index 2ec3945b4d..c96ecc7466 100644 --- a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts +++ b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts @@ -9,5 +9,6 @@ export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageS currentPage: number; pageSize: number; }; + placeholderImage: string; }; //# sourceMappingURL=useOrdersList.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts b/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts new file mode 100644 index 0000000000..a1343fb736 --- /dev/null +++ b/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts @@ -0,0 +1,11 @@ +import { CustomerAddressesModel } from '../data/models'; + +type CustomAttributesType = { + customAttributes?: { + code: string; + value: string; + }[]; +}; +export declare const transformDefaultValuesAddresses: (address?: CustomerAddressesModel & CustomAttributesType) => CustomerAddressesModel; +export {}; +//# sourceMappingURL=transformDefaultValuesAddresses.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/render.js b/scripts/__dropins__/storefront-account/render.js index fe3b541d85..1db2e2da6e 100644 --- a/scripts/__dropins__/storefront-account/render.js +++ b/scripts/__dropins__/storefront-account/render.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ (function(e,r){try{if(typeof document<"u"){const a=document.createElement("style"),o=r.styleId;for(const t in r.attributes)a.setAttribute(t,r.attributes[t]);a.setAttribute("data-dropin",o),a.appendChild(document.createTextNode(e));const c=document.querySelector('style[data-dropin="sdk"]');if(c)c.after(a);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(`.account-orders-list-header{margin-bottom:var(--spacing-medium)}.account-orders-list ul{list-style:none;margin:0;padding:0}.account-orders-list__date-select{margin-bottom:var(--spacing-xbig)}.account-orders-list__date-select span{display:inline-block;font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-xsmall)}.account-orders-list__date-select .dropin-picker{max-width:224px} -.account-form{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.account-form{display:grid;grid-template-columns:repeat(2,1fr)}.account-form>.dropin-field:nth-child(1),.account-form>.dropin-field:nth-child(2){grid-column:span 1}.account-form>.dropin-field:nth-child(3),.account-form>.dropin-field:nth-child(4),.account-form>.dropin-field:nth-child(5){grid-column:span 2}.account-form>.dropin-field:nth-child(6),.account-form>.dropin-field:nth-child(7){grid-column:span 1}.account-form>.dropin-field:nth-child(8),.account-form>.dropin-field:nth-child(9){grid-column:span 1}.account-form>.dropin-field:nth-child(n+10){grid-column:span 2}}.account-form [class$=-hidden]{position:absolute;opacity:0;height:0;width:0;overflow:hidden;clip:rect(0,0,0,0)}.account-account-loaders--card-loader{margin-bottom:var(--spacing-small)}.account-account-loaders--picker-loader div:first-child{max-width:200px}.account-account-loaders--picker-loader div:nth-child(3){max-width:400px}.account-address-card{margin-bottom:var(--spacing-small)}.account-address-card .dropin-card__content{display:grid;grid-template-columns:1fr auto;gap:var(--spacing-small) 0px;grid-template-areas:"description action" "labels action"}.account-address-card .account-address-card__action{display:flex;justify-content:flex-end;align-items:baseline;cursor:pointer;grid-area:action}.account-address-card .account-address-card__action--editbutton{margin-left:var(--spacing-small)}.account-address-card .account-address-card__action button{padding:0}.account-address-card .account-address-card__action button:hover{text-decoration:underline}.account-address-card .account-address-card__description{grid-area:description;margin:0;padding:0}.account-address-card .account-address-card__labels{display:flex;gap:0 var(--spacing-xsmall);grid-area:labels}.account-address-card .account-address-card__description p{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);line-height:var(--spacing-xbig);color:var(--color-neutral-800);padding:0;margin:0 var(--spacing-xsmall) 0 0}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(2){margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0;color:var(--color-neutral-800);font:var(--type-button-2-font);font-weight:500;cursor:default}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(3),.account-address-card .account-address-card__description p:nth-child(4),.account-address-card .account-address-card__description p:nth-child(6){float:left}.account-actions-address{cursor:pointer;padding:var(--spacing-xsmall) var(--spacing-medium);border-radius:var(--shape-border-radius-2);border:var(--shape-border-width-2) solid var(--color-neutral-400);background-color:var(--color-neutral-50);width:100%;height:88px;display:flex;align-items:center;justify-content:space-between}.account-actions-address--selectable{max-width:100%;width:auto}.account-actions-address__title{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-actions-address svg{stroke:var(--shape-icon-stroke-4);color:var(--color-neutral-800)}.account-address-modal{position:relative;padding:var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig);width:100%;margin:auto;max-width:721px}.dropin-modal__body--medium>.dropin-modal__header-title,.dropin-modal__body--full>.dropin-modal__header-title,.account-address-modal .dropin-modal__content{margin:0;align-items:center}.account-address-modal .dropin-modal__header-title-content h3{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);margin:0;padding:0}.account-address-modal .account-address-modal__spinner{position:absolute;top:0;left:0;background-color:var(--color-neutral-200);opacity:.8;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1}.account-address-modal p{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-modal .account-address-modal__buttons{display:flex;align-items:center;justify-content:right;gap:0 var(--spacing-small)}.account-empty-list{margin-bottom:var(--spacing-small)}.account-empty-list.account-empty-list--minified,.account-empty-list .dropin-card{border:none}.account-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.account-empty-list.account-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.account-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.account-empty-list.account-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.account-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.account-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.account-orders-list-action{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.account-orders-list-action--minifiedView{width:100%;text-align:left;font:var(--type-body-1-default-font)}.account-orders-list-action.account-orders-list-action--minifiedView:hover{text-decoration:none}.account-orders-list-action--minifiedView .account-orders-list-action__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.account-orders-list-action__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-orders-list-action__card-wrapper svg,.account-orders-list-action svg{color:var(--color-neutral-800)}.account-orders-list-action--minifiedView .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.account-orders-list-action--minifiedView p{font:var(--type-body-1-strong-font)}.account-orders-list-card{height:100%;margin-bottom:var(--spacing-small)}.account-orders-list-card .dropin-card__content{padding:var(--spacing-medium);display:grid;grid-template-areas:"content actions" "imageList actions";gap:0;max-height:100%}.account-orders-list-card .account-orders-list-card__content{grid-area:content;margin-bottom:var(--spacing-small)}.account-orders-list-card__content--quantity{font-weight:500;color:var(--color-neutral-800)}.account-orders-list-card__content--track_number,.account-orders-list-card__content--return_number{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.account-orders-list-card .account-orders-list-card__content>div:first-child{font-weight:500}.account-orders-list-card .account-orders-list-card__content p,.account-orders-list-card .account-orders-list-card__content div{padding:0;text-align:left;font:var(--type-body-1-default-font);margin:0 0 var(--spacing-small) 0;color:var(--color-neutral-800)}.account-orders-list-card p.account-orders-list-card__content--product-name{margin:0}.account-orders-list-card .account-orders-list-card__content p:last-child{margin:0}.account-orders-list-card .account-orders-list-card__content div{font:var(--type-button-2-font);margin-bottom:var(--spacing-small)}.account-orders-list-card .account-orders-list-card__actions{grid-area:actions}.account-orders-list-card .account-orders-list-card__images{overflow:auto}.account-orders-list-card .account-orders-list-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.account-orders-list-card .account-orders-list-card__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.account-orders-list-card .account-orders-list-card__images img{object-fit:contain;width:65px;height:65px}.account-orders-list-card .account-orders-list-card__actions{position:relative;align-self:center;margin-left:auto}@media (min-width: 768px){.account-orders-list-card.account-orders-list-card--full .dropin-card__content{max-height:100%}}.account-addresses-header{margin-bottom:var(--spacing-medium)}.account-addresses-wrapper{box-sizing:border-box;position:relative}.account-addresses-wrapper--select-view{position:relative;margin:0;padding:0;border:none}.account-addresses-wrapper--select-view input[type=radio]{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;padding:0;margin:-1px;border:0;overflow:hidden}.account-addresses-wrapper--select-view .account-addresses-wrapper__label{cursor:pointer;display:block;border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card{border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label:nth-child(2){border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:nth-child(2)>.account-address-card{border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child,.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child>.account-actions-address.account-actions-address--address{border-radius:0 0 var(--shape-border-radius-1) var(--shape-border-radius-1)}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-200)}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-addresses-form__footer__wrapper{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-50)}.account-addresses-wrapper--select-view .account-address-card{margin:0}.account-addresses-wrapper--select-view .account-addresses-form__footer__wrapper{padding:var(--spacing-medium)}.account-address-form-wrapper{box-sizing:border-box;background-color:var(--color-neutral-50)}.account-address-form-wrapper__notification{margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__buttons{display:flex;align-items:center;justify-content:end;gap:0 var(--spacing-medium);margin-top:var(--spacing-medium)}.account-address-form-wrapper__buttons--empty{gap:0;margin:0;padding:0;display:inline-block}.account-address-form-wrapper__buttons button{min-width:142px}.account-change-password .dropin-card__content{gap:0}.account-change-password__title,.account-change-password .account-change-password__notification,.account-change-password .account-change-password__fields .account-change-password__fields-item{margin-bottom:var(--spacing-medium)}.account-change-password .account-change-password__fields .account-change-password__fields-item:last-child{margin-bottom:0}.account-change-password .account-change-password__actions{display:flex;justify-content:right;align-items:center;gap:0 var(--grid-3-gutters);margin-top:var(--spacing-xlarge)}.account-change-password .account-change-password__actions button{min-width:144px}.account-edit-customer-information__title{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .dropin-card__content{gap:0}.account-edit-customer-information .account-edit-customer-information__notification{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .account-edit-customer-information-form__field:nth-child(n+3),.account-edit-customer-information .account-edit-customer-information__password{grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions{display:flex;justify-content:end;align-items:center;gap:0 var(--grid-2-gutters);grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions button{min-width:144px}.customer-information__title{margin-bottom:var(--spacing-medium)}.account-customer-information-card-short{margin-bottom:var(--spacing-small)}.account-customer-information-card .dropin-card__content{gap:0}.account-customer-information-card__wrapper{display:grid;grid-template-columns:1fr auto;align-items:start}.account-customer-information-card .account-customer-information-card__actions{display:flex;justify-content:space-between;align-items:center;gap:0 var(--grid-2-gutters)}.account-customer-information-card .account-customer-information-card__actions button{cursor:pointer;margin:0;padding:0}.account-customer-information-card__content p{font:var(--type-body-1-default-font);margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-xbig);padding:0}.account-customer-information-card__content p:nth-child(1),.account-customer-information-card__content p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0}.account-customer-information-card__content p:nth-child(1){float:left}`,{styleId:"account"}); +.account-form{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.account-form{display:grid;grid-template-columns:repeat(2,1fr)}.account-form>.dropin-field:nth-child(1),.account-form>.dropin-field:nth-child(2){grid-column:span 1}.account-form>.dropin-field:nth-child(3),.account-form>.dropin-field:nth-child(4),.account-form>.dropin-field:nth-child(5){grid-column:span 2}.account-form>.dropin-field:nth-child(6),.account-form>.dropin-field:nth-child(7){grid-column:span 1}.account-form>.dropin-field:nth-child(8),.account-form>.dropin-field:nth-child(9){grid-column:span 1}.account-form>.dropin-field:nth-child(n+10){grid-column:span 2}}.account-form [class$=-hidden]{position:absolute;opacity:0;height:0;width:0;overflow:hidden;clip:rect(0,0,0,0)}.account-account-loaders--card-loader{margin-bottom:var(--spacing-small)}.account-account-loaders--picker-loader div:first-child{max-width:200px}.account-account-loaders--picker-loader div:nth-child(3){max-width:400px}.account-address-card{margin-bottom:var(--spacing-small)}.account-address-card .dropin-card__content{display:grid;grid-template-columns:1fr auto;gap:var(--spacing-small) 0px;grid-template-areas:"description action" "labels action"}.account-address-card .account-address-card__action{display:flex;justify-content:flex-end;align-items:baseline;cursor:pointer;grid-area:action}.account-address-card .account-address-card__action--editbutton{margin-left:var(--spacing-small)}.account-address-card .account-address-card__action button{padding:0}.account-address-card .account-address-card__action button:hover{text-decoration:underline}.account-address-card .account-address-card__description{grid-area:description;margin:0;padding:0}.account-address-card .account-address-card__labels{display:flex;gap:0 var(--spacing-xsmall);grid-area:labels}.account-address-card .account-address-card__description p{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);line-height:var(--spacing-xbig);color:var(--color-neutral-800);padding:0;margin:0 var(--spacing-xsmall) 0 0}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(2){margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0;color:var(--color-neutral-800);font:var(--type-button-2-font);font-weight:500;cursor:default}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(3),.account-address-card .account-address-card__description p:nth-child(4),.account-address-card .account-address-card__description p:nth-child(6){float:left}.account-actions-address{cursor:pointer;padding:var(--spacing-xsmall) var(--spacing-medium);border-radius:var(--shape-border-radius-2);border:var(--shape-border-width-2) solid var(--color-neutral-400);background-color:var(--color-neutral-50);width:100%;height:88px;display:flex;align-items:center;justify-content:space-between}.account-actions-address--selectable{max-width:100%;width:auto}.account-actions-address__title{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-actions-address svg{stroke:var(--shape-icon-stroke-4);color:var(--color-neutral-800)}.account-address-modal{position:relative;padding:var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig);width:100%;margin:auto;max-width:721px}.dropin-modal__body--medium>.dropin-modal__header-title,.dropin-modal__body--full>.dropin-modal__header-title,.account-address-modal .dropin-modal__content{margin:0;align-items:center}.account-address-modal .dropin-modal__header-title-content h3{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);margin:0;padding:0}.account-address-modal .account-address-modal__spinner{position:absolute;top:0;left:0;background-color:var(--color-neutral-200);opacity:.8;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1}.account-address-modal p{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-modal .account-address-modal__buttons{display:flex;align-items:center;justify-content:right;gap:0 var(--spacing-small)}.account-empty-list{margin-bottom:var(--spacing-small)}.account-empty-list.account-empty-list--minified,.account-empty-list .dropin-card{border:none}.account-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.account-empty-list.account-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.account-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.account-empty-list.account-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.account-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.account-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.account-orders-list-action{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}a.account-orders-list-action:focus-visible{display:inline-block}.account-orders-list-action--minifiedView{width:100%;text-align:left;font:var(--type-body-1-default-font)}.account-orders-list-action.account-orders-list-action--minifiedView:hover{text-decoration:none}.account-orders-list-action--minifiedView .account-orders-list-action__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.account-orders-list-action__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-orders-list-action__card-wrapper svg,.account-orders-list-action svg{color:var(--color-neutral-800)}.account-orders-list-action--minifiedView .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.account-orders-list-action--minifiedView p{font:var(--type-body-1-strong-font)}.account-orders-list-card{height:100%;margin-bottom:var(--spacing-small)}.account-orders-list-card .dropin-card__content{padding:var(--spacing-medium);display:grid;grid-template-areas:"content actions" "imageList actions";gap:0;max-height:100%}.account-orders-list-card .account-orders-list-card__content{grid-area:content;margin-bottom:var(--spacing-small)}.account-orders-list-card__content--quantity{font-weight:500;color:var(--color-neutral-800)}.account-orders-list-card__content--track_number,.account-orders-list-card__content--return_number{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.account-orders-list-card .account-orders-list-card__content>div:first-child{font-weight:500}.account-orders-list-card .account-orders-list-card__content p,.account-orders-list-card .account-orders-list-card__content div{padding:0;text-align:left;font:var(--type-body-1-default-font);margin:0 0 var(--spacing-small) 0;color:var(--color-neutral-800)}.account-orders-list-card p.account-orders-list-card__content--product-name{margin:0}.account-orders-list-card .account-orders-list-card__content p:last-child{margin:0}.account-orders-list-card .account-orders-list-card__content div{font:var(--type-button-2-font);margin-bottom:var(--spacing-small)}.account-orders-list-card .account-orders-list-card__actions{grid-area:actions}.account-orders-list-card .account-orders-list-card__images{overflow:auto}.account-orders-list-card .account-orders-list-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.account-orders-list-card .account-orders-list-card__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.account-orders-list-card .account-orders-list-card__images img{object-fit:contain;width:65px;height:65px}.account-orders-list-card .account-orders-list-card__actions{position:relative;align-self:center;margin-left:auto}@media (min-width: 768px){.account-orders-list-card.account-orders-list-card--full .dropin-card__content{max-height:100%}}.account-addresses-header{margin-bottom:var(--spacing-medium)}.account-addresses-wrapper{box-sizing:border-box;position:relative}.account-addresses-wrapper--select-view{position:relative;margin:0;padding:0;border:none}.account-addresses-wrapper--select-view input[type=radio]{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;padding:0;margin:-1px;border:0;overflow:hidden}.account-addresses-wrapper--select-view .account-addresses-wrapper__label{cursor:pointer;display:block;border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card{border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label:nth-child(2){border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:nth-child(2)>.account-address-card{border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child,.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child>.account-actions-address.account-actions-address--address{border-radius:0 0 var(--shape-border-radius-1) var(--shape-border-radius-1)}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-200)}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:focus+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);outline:var(--spacing-xxsmall) solid var(--color-button-focus);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-addresses-form__footer__wrapper{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-50)}.account-addresses-wrapper--select-view .account-address-card{margin:0}.account-addresses-wrapper--select-view .account-addresses-form__footer__wrapper{padding:var(--spacing-medium)}.account-address-form-wrapper{box-sizing:border-box;background-color:var(--color-neutral-50)}.account-address-form-wrapper__notification{margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__buttons{display:flex;align-items:center;justify-content:end;gap:0 var(--spacing-medium);margin-top:var(--spacing-medium)}.account-address-form-wrapper__buttons--empty{gap:0;margin:0;padding:0;display:inline-block}.account-address-form-wrapper__buttons button{min-width:142px}.account-change-password .dropin-card__content{gap:0}.account-change-password__title,.account-change-password .account-change-password__notification,.account-change-password .account-change-password__fields .account-change-password__fields-item{margin-bottom:var(--spacing-medium)}.account-change-password .account-change-password__fields .account-change-password__fields-item:last-child{margin-bottom:0}.account-change-password .account-change-password__actions{display:flex;justify-content:right;align-items:center;gap:0 var(--grid-3-gutters);margin-top:var(--spacing-xlarge)}.account-change-password .account-change-password__actions button{min-width:144px}.account-edit-customer-information__title{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .dropin-card__content{gap:0}.account-edit-customer-information .account-edit-customer-information__notification{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .account-edit-customer-information-form__field:nth-child(n+3),.account-edit-customer-information .account-edit-customer-information__password{grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions{display:flex;justify-content:end;align-items:center;gap:0 var(--grid-2-gutters);grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions button{min-width:144px}.customer-information__title{margin-bottom:var(--spacing-medium)}.account-customer-information-card-short{margin-bottom:var(--spacing-small)}.account-customer-information-card .dropin-card__content{gap:0}.account-customer-information-card__wrapper{display:grid;grid-template-columns:1fr auto;align-items:start}.account-customer-information-card .account-customer-information-card__actions{display:flex;justify-content:space-between;align-items:center;gap:0 var(--grid-2-gutters)}.account-customer-information-card .account-customer-information-card__actions button{cursor:pointer;margin:0;padding:0}.account-customer-information-card__content p{font:var(--type-body-1-default-font);margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-xbig);padding:0}.account-customer-information-card__content p:nth-child(1),.account-customer-information-card__content p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0}.account-customer-information-card__content p:nth-child(1){float:left}`,{styleId:"account"}); import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as o}from"@dropins/tools/lib.js";import{useState as n,useEffect as i}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const m={minifiedView:{CustomerInformation:{containerTitle:"Account settings",genderMale:"Male",genderFemale:"Female",changePassword:{passwordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical",incorrectCurrentPassword:"The current password you entered is incorrect. Please check and try again.",passwordUpdateMessage:"Your password has been updated"},containerTitle:"Change password",currentPassword:{placeholder:"Password",floatingLabel:"Password"},newPassword:{placeholder:"New Password",floatingLabel:"New Password"},confirmPassword:{placeholder:"Confirm new password",floatingLabel:"Confirm new password"},buttonSecondary:"Cancel",buttonPrimary:"Save"},customerInformationCard:{buttonSecondary:"Change password",buttonPrimary:"Edit",accountCreation:"Account creation date"},editCustomerInformation:{containerTitle:"Edit details",buttonSecondary:"Cancel",buttonPrimary:"Save",accountSuccess:"Your account information has been updated.",accountError:"Your account information has not been updated.",passwordField:{placeholder:"Password",floatingLabel:"Password"}}},Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",viewAllAddressesButton:"View address list",differentAddressButton:"Use a different address",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Recent orders",viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},fullSizeView:{Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",newAddressFormTitle:"Add address",addNewAddressButton:"Create new",differentAddressButton:"Use a different address",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Your orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},AddressForm:{formText:{secondaryButton:"Cancel",primaryButton:"Save",defaultShippingLabel:"Set as default shipping address",defaultBillingLabel:"Set as default billing address",saveAddressBook:"Save in address book"}},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",urlError:"Please enter a valid URL, e.g., http://www.adobe.com.",lengthTextError:"Text length must be between {min} and {max} characters."}},u={Account:m},w={default:u},p=({children:a})=>{const[s,t]=n("en_US");return i(()=>{const e=c.on("locale",d=>{t(d)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:s,langDefinitions:w,children:a})},L=new o(r(p,{}));export{L as render}; diff --git a/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts b/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts index c373f4955a..501fb4f10a 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts @@ -9,7 +9,6 @@ export interface getCustomerShortResponse { lastname: string; email: string; date_of_birth: string; - dob: string; gender: 1 | 2; middlename: string; prefix: string; diff --git a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts index 4efa9bc01d..cc57850f6e 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts @@ -4,6 +4,10 @@ export type RegionProps = { region_id: string | number; }; export interface UserAddressesProps { + middlename: string; + fax: string; + prefix: string; + suffix: string; firstname: string; lastname: string; city: string; diff --git a/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts index ae72c8c484..56dd9f4dec 100644 --- a/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts @@ -1,4 +1,5 @@ export interface StoreConfigProps { + base_media_url: string; minimum_password_length: number; required_character_classes_number: string; } diff --git a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts index e4fd484f5a..3609bc9598 100644 --- a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts @@ -32,6 +32,7 @@ export interface OrdersListProps extends HTMLAttributes { export interface OrdersListWrapperProps extends OrdersListProps { } export interface OrdersListCardProps extends HTMLAttributes { + placeholderImage: string; minifiedView: boolean; item: OrderDetails; withThumbnails: boolean; diff --git a/scripts/__dropins__/storefront-auth/api.js b/scripts/__dropins__/storefront-auth/api.js index 8a2c1509f8..960a560c6b 100644 --- a/scripts/__dropins__/storefront-auth/api.js +++ b/scripts/__dropins__/storefront-auth/api.js @@ -1 +1,3 @@ -import{c as p,a as f,g}from"./chunks/createCustomerAddress.js";import{g as c,a as x}from"./chunks/getCustomerToken.js";import{g as h}from"./chunks/getStoreConfig.js";import{r as C}from"./chunks/requestPasswordResetEmail.js";import{r as E}from"./chunks/resetPassword.js";import{r as G}from"./chunks/revokeCustomerToken.js";import{c as k}from"./chunks/confirmEmail.js";import{r as b}from"./chunks/resendConfirmationEmail.js";import{c as w,i as A}from"./chunks/initialize.js";import{f as T,g as q,r as z,s as D,a as R,b as S}from"./chunks/network-error.js";import"./chunks/setReCaptchaToken.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";export{w as config,k as confirmEmail,p as createCustomer,f as createCustomerAddress,T as fetchGraphQl,g as getAttributesForm,q as getConfig,c as getCustomerData,x as getCustomerToken,h as getStoreConfig,A as initialize,z as removeFetchGraphQlHeader,C as requestPasswordResetEmail,b as resendConfirmationEmail,E as resetPassword,G as revokeCustomerToken,D as setEndpoint,R as setFetchGraphQlHeader,S as setFetchGraphQlHeaders}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{c as f,a as g,g as n}from"./chunks/createCustomerAddress.js";import{g as x,a as d}from"./chunks/getCustomerToken.js";import{g as l}from"./chunks/getStoreConfig.js";import{r as u}from"./chunks/requestPasswordResetEmail.js";import{r as F}from"./chunks/resetPassword.js";import{r as Q}from"./chunks/revokeCustomerToken.js";import{c as H}from"./chunks/confirmEmail.js";import{r as v}from"./chunks/resendConfirmationEmail.js";import{c as A,i as P}from"./chunks/initialize.js";import{f as q,g as z,r as D,s as R,a as S,b as j}from"./chunks/network-error.js";import"./fragments.js";import"./chunks/setReCaptchaToken.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/fetch-graphql.js";export{A as config,H as confirmEmail,f as createCustomer,g as createCustomerAddress,q as fetchGraphQl,n as getAttributesForm,z as getConfig,x as getCustomerData,d as getCustomerToken,l as getStoreConfig,P as initialize,D as removeFetchGraphQlHeader,u as requestPasswordResetEmail,v as resendConfirmationEmail,F as resetPassword,Q as revokeCustomerToken,R as setEndpoint,S as setFetchGraphQlHeader,j as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts index 510361027a..cd22d3a02c 100644 --- a/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CONFIRM_EMAIL = "\n mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) {\n confirmEmail(input: {\n email: $email,\n confirmation_key: $confirmation_key\n }) {\n customer {\n email\n }\n }\n }\n"; +export declare const CONFIRM_EMAIL = "\n mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) {\n confirmEmail(\n input: { email: $email, confirmation_key: $confirmation_key }\n ) {\n customer {\n email\n }\n }\n }\n"; //# sourceMappingURL=confirmEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts index 304d6fcd70..fc641b3605 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts @@ -1,4 +1,5 @@ -import { CreateCustomerDataResponse, Customer } from '../../types'; +import { Customer } from '../../types'; +import { CustomerModel } from '../../data/models'; -export declare const createCustomer: (forms: Customer, apiVersion2: boolean) => Promise; +export declare const createCustomer: (forms: Customer, apiVersion2: boolean) => Promise; //# sourceMappingURL=createCustomer.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts index 124881eb75..38b05c9335 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER = "\n mutation CREATE_CUSTOMER($input: CustomerInput!) {\n createCustomer(input: $input) {\n customer {\n firstname\n lastname\n email\n is_subscribed\n }\n }\n }\n"; +export declare const CREATE_CUSTOMER: string; //# sourceMappingURL=createCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts index fbc15f282c..4495aeef1e 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER_V2 = "\n mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) {\n createCustomerV2(input: $input) {\n customer {\n firstname\n lastname\n email\n is_subscribed\n }\n }\n }\n"; +export declare const CREATE_CUSTOMER_V2: string; //# sourceMappingURL=createCustomerV2.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts index 670c2ea98c..ce704ced84 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input:$input) {\n firstname\n }\n }\n"; +export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\n }\n }\n"; //# sourceMappingURL=createCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/fragments.d.ts b/scripts/__dropins__/storefront-auth/api/fragments.d.ts new file mode 100644 index 0000000000..7f396f1d5a --- /dev/null +++ b/scripts/__dropins__/storefront-auth/api/fragments.d.ts @@ -0,0 +1,2 @@ +export { CUSTOMER_INFORMATION_FRAGMENT } from './graphql/CustomerFragment.graphql'; +//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts b/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts index 0fd1706b17..323e619944 100644 --- a/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts +++ b/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts @@ -1,4 +1,4 @@ -import { CustomerDataModel } from '../../data/models'; +import { CustomerModel } from '../../data/models'; -export declare const getCustomerData: (user_token: string) => Promise; +export declare const getCustomerData: (user_token: string) => Promise; //# sourceMappingURL=getCustomerData.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts index 312aff8592..2628990282 100644 --- a/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER_DATA = "\n query GET_CUSTOMER_DATA {\n customer {\n firstname\n lastname\n email\n }\n }\n"; +export declare const GET_CUSTOMER_DATA: string; //# sourceMappingURL=getCustomerData.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts new file mode 100644 index 0000000000..4070778a61 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const CUSTOMER_INFORMATION_FRAGMENT = "\n fragment CUSTOMER_INFORMATION_FRAGMENT on Customer {\n __typename\n firstname\n lastname\n email\n is_subscribed\n }\n"; +//# sourceMappingURL=CustomerFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts index 4b94607a6a..778ad190d7 100644 --- a/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts @@ -1,5 +1,6 @@ -import { Initializer } from '@dropins/tools/types/elsie/src/lib'; +import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib'; import { Lang } from '@dropins/tools/types/elsie/src/i18n'; +import { CustomerModel } from '../../data/models'; type ConfigProps = { langDefinitions?: Lang; @@ -7,6 +8,9 @@ type ConfigProps = { header: string; tokenPrefix: string; }; + models?: { + CustomerModel?: Model; + }; }; export declare const initialize: Initializer; export declare const config: import('@dropins/tools/types/elsie/src/lib').Config; diff --git a/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts index fc38a9d607..819d68bae2 100644 --- a/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const RESEND_CONFIRMATION_EMAIL = "\nmutation RESEND_CONFIRMATION_EMAIL($email: String!) {\n resendConfirmationEmail(email: $email)\n}"; +export declare const RESEND_CONFIRMATION_EMAIL = "\n mutation RESEND_CONFIRMATION_EMAIL($email: String!) {\n resendConfirmationEmail(email: $email)\n }\n"; //# sourceMappingURL=resendConfirmationEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts index 205ddbafdc..3603770846 100644 --- a/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const RESET_PASSWORD = "\n mutation RESET_PASSWORD($email: String!, $resetPasswordToken: String!, $newPassword: String!){\n resetPassword(email: $email,resetPasswordToken: $resetPasswordToken,newPassword: $newPassword)\n }\n"; +export declare const RESET_PASSWORD = "\n mutation RESET_PASSWORD(\n $email: String!\n $resetPasswordToken: String!\n $newPassword: String!\n ) {\n resetPassword(\n email: $email\n resetPasswordToken: $resetPasswordToken\n newPassword: $newPassword\n )\n }\n"; //# sourceMappingURL=resetPassword.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/chunks/Button2.js b/scripts/__dropins__/storefront-auth/chunks/Button2.js new file mode 100644 index 0000000000..800145c516 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/chunks/Button2.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as h,Fragment as Z,jsxs as U}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useCallback as L,useRef as H,useEffect as P}from"@dropins/tools/preact-hooks.js";import*as $ from"@dropins/tools/preact-compat.js";import{memo as W,useCallback as _}from"@dropins/tools/preact-compat.js";import{initReCaptcha as G}from"@dropins/tools/recaptcha.js";import{useText as j}from"@dropins/tools/i18n.js";import{classes as M}from"@dropins/tools/lib.js";import{Field as w,Picker as q,Input as X,InputDate as C,Checkbox as z,TextArea as B,Button as J}from"@dropins/tools/components.js";/* empty css */const Dr=r=>{if(!r)return null;const t=new FormData(r);if(t&&typeof t.entries=="function"){const n=t.entries();if(n&&typeof n[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(n)))||{}}return{}},xr=r=>typeof r=="function",Y=r=>$.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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)"})))),K=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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"})),Q=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),g={success:h(K,{}),warning:h(Y,{}),error:h(Q,{})},br=()=>{const[r,t]=R({}),n=L(l=>{if(!l||!l.type){t({});return}const c=g[l.type];t({...l,icon:c})},[]);return{inLineAlertProps:r,handleSetInLineAlertProps:n}};var v=(r=>(r.BOOLEAN="BOOLEAN",r.DATE="DATE",r.DATETIME="DATETIME",r.DROPDOWN="DROPDOWN",r.FILE="FILE",r.GALLERY="GALLERY",r.HIDDEN="HIDDEN",r.IMAGE="IMAGE",r.MEDIA_IMAGE="MEDIA_IMAGE",r.MULTILINE="MULTILINE",r.MULTISELECT="MULTISELECT",r.PRICE="PRICE",r.SELECT="SELECT",r.TEXT="TEXT",r.TEXTAREA="TEXTAREA",r.UNDEFINED="UNDEFINED",r.VISUAL="VISUAL",r.WEIGHT="WEIGHT",r.EMPTY="",r))(v||{});const rr=W(({loading:r,values:t,fields:n=[],errors:l,className:c="",onChange:u,onBlur:p,onFocus:A})=>{const s=`${c}__field`,f=_((e,o,a)=>{var T;const E=(T=e.options.find(N=>N.isDefault))==null?void 0:T.value;return h(w,{error:a,className:M([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(q,{name:e.customUpperCode,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:p,handleSelect:u,defaultValue:E??o??e.defaultValue,value:E??o??e.defaultValue})},e.id)},[c,r,s,p,u]),D=_((e,o,a)=>h(w,{error:a,className:M([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(X,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,onFocus:A})},e.id),[c,r,s,p,u,A]),x=_((e,o,a)=>h(w,{error:a,className:M([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(C,{type:"text",name:e.customUpperCode,value:o||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,disabled:r||e.disabled})},e.id),[c,r,s,p,u]),m=_((e,o,a)=>h(w,{error:a,className:M([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(z,{name:e.customUpperCode,checked:o||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]),b=_((e,o,a)=>h(w,{error:a,className:M([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(B,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]);return n.length?h(Z,{children:n.map(e=>{const o=l==null?void 0:l[e.customUpperCode],a=t==null?void 0:t[e.customUpperCode];switch(e.fieldType){case v.TEXT:return e.options.length?f(e,a,o):D(e,a,o);case v.MULTILINE:return D(e,a,o);case v.SELECT:return f(e,a,o);case v.DATE:return x(e,a,o);case v.BOOLEAN:return m(e,a,o);case v.TEXTAREA:return b(e,a,o);default:return null}})}):null}),er=r=>r.reduce((t,{customUpperCode:n,required:l,defaultValue:c})=>(l&&n&&(t.initialData[n]=c||"",t.errorList[n]=""),t),{initialData:{},errorList:{}}),tr=r=>r.reduce((t,n)=>({...t,[n.name]:n.value}),{}),ar=r=>/^\d+$/.test(r),nr=r=>/^[a-zA-Z0-9\s]+$/.test(r),or=r=>/^[a-zA-Z0-9]+$/.test(r),lr=r=>/^[a-zA-Z]+$/.test(r),sr=r=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(r),cr=r=>/^\d{4}-\d{2}-\d{2}$/.test(r)&&!isNaN(Date.parse(r)),dr=(r,t,n)=>{const l=new Date(r).getTime()/1e3;return!(isNaN(l)||l<0||typeof t<"u"&&ln)},k=r=>{if(!r||r.trim()==="")return"";const t=parseInt(r,10);if(!isNaN(t)){const c=new Date(t*1e3);return isNaN(c.getTime())?"":c.toISOString().split("T")[0]}const n=new Date(r);if(isNaN(n.getTime()))return"";const l=parseInt(r.split("-")[1],10);return l>12||l<1?"":n.toISOString().split("T")[0]},ur=r=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(r),ir=(r,t,n)=>{const l=r.length;return l>=t&&l<=n},O=(r,t,n,l)=>{var y,F;const{requiredFieldError:c,lengthTextError:u,numericError:p,alphaNumWithSpacesError:A,alphaNumericError:s,alphaError:f,emailError:D,dateError:x,urlError:m,dateLengthError:b,dateMaxError:e,dateMinError:o}=n,a=t==null?void 0:t.customUpperCode,E={[a]:""};if(l[a]&&delete l[a],t!=null&&t.required&&!r)return{[a]:c};if(!(t!=null&&t.required)&&!r||!((y=t==null?void 0:t.validateRules)!=null&&y.length))return E;const T=tr(t==null?void 0:t.validateRules),N=T.MIN_TEXT_LENGTH??1,I=T.MAX_TEXT_LENGTH??255,d=T.DATE_RANGE_MIN,i=T.DATE_RANGE_MAX;if(!ir(r,+N,+I)&&!(d||i))return{[a]:u.replace("{min}",N).replace("{max}",I)};if(!dr(r,+d,+i)&&(d||i)){if(d&&d)return{[a]:b.replace("{min}",k(d)).replace("{max}",k(i))};if(typeof d>"u"||typeof i>"u")return{[a]:i?e.replace("{max}",k(i)):o.replace("{min}",k(d))}}const V={numeric:{validate:ar,error:p},"alphanum-with-spaces":{validate:nr,error:A},alphanumeric:{validate:or,error:s},alpha:{validate:lr,error:f},email:{validate:sr,error:D},date:{validate:cr,error:x},url:{validate:ur,error:m}}[T.INPUT_VALIDATION];return V&&!V.validate(r)&&!((F=l[a])!=null&&F.length)?{[a]:V.error}:E},pr=({fieldsConfig:r,onSubmit:t})=>{const n=j({requiredFieldError:"Auth.FormText.requiredFieldError",lengthTextError:"Auth.FormText.lengthTextError",numericError:"Auth.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Auth.FormText.alphaNumericError",alphaError:"Auth.FormText.alphaError",emailError:"Auth.FormText.emailError",dateError:"Auth.FormText.dateError",dateLengthError:"Auth.FormText.dateLengthError",dateMaxError:"Auth.FormText.dateMaxError",dateMinError:"Auth.FormText.dateMinError",urlError:"Auth.FormText.urlError"}),l=H(null),c=H(!1),[u,p]=R({}),[A,s]=R({}),f=L(()=>{let e=!0;const o={...A};let a=null;for(const[E,T]of Object.entries(u)){const N=r==null?void 0:r.find(d=>{var i;return(i=d==null?void 0:d.customUpperCode)==null?void 0:i.includes(E)}),I=O(T.toString(),N,n,o);I[E]&&(Object.assign(o,I),e=!1),a||(a=Object.keys(o).find(d=>o[d])??null)}if(s(o),a&&l.current){const E=l.current.elements.namedItem(a);E==null||E.focus()}return e},[A,r,u,n]);P(()=>{if(r!=null&&r.length){const{initialData:e,errorList:o}=er(r);p(a=>({...e,...a})),s(o)}},[JSON.stringify(r)]);const D=L(async()=>{c.current||(await G(0),c.current=!0)},[]),x=L(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a;p(i=>({...i,[o]:N}));const I=r==null?void 0:r.find(i=>{var S;return(S=i==null?void 0:i.customUpperCode)==null?void 0:S.includes(o)});let d={...A};if(I){const i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[r,A,n]),m=L(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a,I=r==null?void 0:r.find(d=>d.customUpperCode===o);if(I){const d={...A},i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[A,r,n]),b=L(e=>{e.preventDefault();const o=f();t==null||t(e,o)},[f,t]);return{formData:u,errors:A,formRef:l,handleChange:x,handleBlur:m,handleSubmit:b,handleFocus:D}},mr=({name:r,loading:t,children:n,className:l="defaultForm",fieldsConfig:c=[],onSubmit:u,...p})=>{const{formData:A,errors:s,formRef:f,handleChange:D,handleBlur:x,handleSubmit:m,handleFocus:b}=pr({onSubmit:u,fieldsConfig:c});return U("form",{className:l,onSubmit:m,name:r,ref:f,onFocus:b,...p,children:[h(rr,{className:l,onFocus:b,fields:c,onChange:D,onBlur:x,errors:s,values:A,loading:t}),n]})},vr=({type:r,buttonText:t,variant:n,className:l="",enableLoader:c=!1,onClick:u,style:p,icon:A,...s})=>{const f=L(x=>{u==null||u(x)},[u]);return U(J,{icon:A,style:p,type:r,variant:n,className:M(["auth-button",l,c?"enableLoader":""]),onClick:f,...s,children:[h("span",{className:"auth-button__text",children:t}),c?h("div",{className:"auth-button__wrapper",children:h("span",{className:"auth-button__loader"})}):null]})};export{vr as B,mr as F,xr as c,Dr as g,br as u}; diff --git a/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js b/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js deleted file mode 100644 index c882357f8d..0000000000 --- a/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js +++ /dev/null @@ -1 +0,0 @@ -import{jsxs as c,jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{useState as C,useCallback as y}from"@dropins/tools/preact-hooks.js";import{InLineAlert as x,Header as p}from"@dropins/tools/components.js";import{B as f}from"./UpdatePasswordForm.js";/* empty css */import{r as E}from"./resendConfirmationEmail.js";import{useText as d}from"@dropins/tools/i18n.js";const _=({userEmail:r,handleSetInLineAlertProps:i})=>{const a=d({emailConfirmationMessage:"Auth.Notification.emailConfirmationMessage",technicalErrorSendEmail:"Auth.Notification.technicalErrors.technicalErrorSendEmail"}),[l,e]=C(!1);return{handleEmailConfirmation:y(async()=>{var o,m;if(e(!0),r){const t=await E(r);if(t){const u=(o=t==null?void 0:t.errors)==null?void 0:o.length,h=(m=t==null?void 0:t.data)==null?void 0:m.resendConfirmationEmail;i(u?{type:"error",text:a.technicalErrorSendEmail}:{type:h?"success":"error",text:a.emailConfirmationMessage})}}e(!1)},[i,a,r]),disabledButton:l}},$=({formSize:r,userEmail:i,inLineAlertProps:a,hideCloseBtnOnEmailConfirmation:l,handleSetInLineAlertProps:e,onPrimaryButtonClick:s})=>{const o=d({title:"Auth.EmailConfirmationForm.title",subtitle:"Auth.EmailConfirmationForm.subtitle",mainText:"Auth.EmailConfirmationForm.mainText",buttonPrimary:"Auth.EmailConfirmationForm.buttonPrimary",buttonSecondary:"Auth.EmailConfirmationForm.buttonSecondary"}),{handleEmailConfirmation:m,disabledButton:t}=_({userEmail:i,handleSetInLineAlertProps:e});return c("div",{className:b(["auth-email-confirmation-form",`auth-email-confirmation-form--${r}`]),children:[a.text?n(x,{className:"auth-signInForm__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"authInLineAlert"}):null,n(p,{title:o.title,divider:!1,className:"auth-email-confirmation-form__title"}),i!=null&&i.length?n("span",{className:"auth-email-confirmation-form__subtitle",children:`${o.subtitle} ${i}`}):null,n("span",{className:"auth-email-confirmation-form__text",children:o.mainText}),c("div",{className:"auth-email-confirmation-form__buttons",children:[n(f,{type:"button",variant:"tertiary",style:{padding:0},buttonText:o.buttonSecondary,enableLoader:!1,onClick:m,disabled:t}),l?null:n(f,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:!1,disabled:t,onClick:s})]})]})};export{$ as E}; diff --git a/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js b/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js index bb574e0fec..feb6c0e4d0 100644 --- a/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js @@ -1 +1,3 @@ -import{jsxs as w,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{g as F,c as l,u as P,F as _,B as p}from"./UpdatePasswordForm.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as b}from"./requestPasswordResetEmail.js";import{useState as x,useCallback as g}from"@dropins/tools/preact-hooks.js";import{useText as R}from"@dropins/tools/i18n.js";import{Header as v,InLineAlert as N}from"@dropins/tools/components.js";/* empty css */import{s as E,D as T}from"./simplifyTransformAttributesForm.js";import*as y from"@dropins/tools/preact-compat.js";const D=t=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},y.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),L=({routeSignIn:t,onErrorCallback:a,setActiveComponent:i,handleSetInLineAlertProps:s})=>{const c=R({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[m,e]=x(!1),d=g(async u=>{u.preventDefault(),e(!0);const r=F(u.target);if(r&&r.email){const f=await b(r.email);f.success?s==null||s({type:"success",text:c.successPasswordResetEmailNotification.replace("{email}",r.email)}):(a==null||a(f),s==null||s({type:"error",text:f.message}))}e(!1)},[s,a,c.successPasswordResetEmailNotification]),n=g(()=>{if(l(i)){i("signInForm");return}l(t)&&(window.location.href=t())},[i,t]);return{isLoading:m,submitResetPassword:d,redirectToSignInPage:n}},z=({formSize:t="default",routeSignIn:a,setActiveComponent:i,onErrorCallback:s,...c})=>{const m=R({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary"}),{inLineAlertProps:e,handleSetInLineAlertProps:d}=P(),{isLoading:n,submitResetPassword:u,redirectToSignInPage:r}=L({routeSignIn:a,setActiveComponent:i,onErrorCallback:s,handleSetInLineAlertProps:d});return w("div",{...c,className:h(["auth-reset-password-form",`auth-reset-password-form--${t}`]),"data-testid":"resetPasswordForm",children:[o(v,{title:m.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(N,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(_,{name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:u,loading:n,fieldsConfig:E(T),children:w("div",{className:"auth-reset-password-form__buttons",children:[o(p,{type:"button",variant:"tertiary",style:{padding:"0"},icon:o(D,{style:{transform:"rotate(90deg)"}}),buttonText:m.buttonSecondary,enableLoader:!1,onClick:r}),o(p,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:n})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{z as R}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as l,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";/* empty css */import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as h}from"./requestPasswordResetEmail.js";import{g as F,c as w,u as P,F as _,B as p}from"./Button2.js";import{useState as x,useCallback as g}from"@dropins/tools/preact-hooks.js";import{useText as R}from"@dropins/tools/i18n.js";import{Header as v,InLineAlert as N}from"@dropins/tools/components.js";import{s as E,D as L}from"./simplifyTransformAttributesForm.js";import*as y from"@dropins/tools/preact-compat.js";const T=t=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},y.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),D=({routeSignIn:t,onErrorCallback:a,setActiveComponent:m,handleSetInLineAlertProps:s})=>{const c=R({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[r,e]=x(!1),d=g(async u=>{u.preventDefault(),e(!0);const i=F(u.target);if(i&&i.email){const f=await h(i.email);f.success?s==null||s({type:"success",text:c.successPasswordResetEmailNotification.replace("{email}",i.email)}):(a==null||a(f),s==null||s({type:"error",text:f.message}))}e(!1)},[s,a,c.successPasswordResetEmailNotification]),n=g(()=>{if(w(m)){m("signInForm");return}w(t)&&(window.location.href=t())},[m,t]);return{isLoading:r,submitResetPassword:d,redirectToSignInPage:n}},$=({formSize:t="default",routeSignIn:a,setActiveComponent:m,onErrorCallback:s,...c})=>{const r=R({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:e,handleSetInLineAlertProps:d}=P(),{isLoading:n,submitResetPassword:u,redirectToSignInPage:i}=D({routeSignIn:a,setActiveComponent:m,onErrorCallback:s,handleSetInLineAlertProps:d});return l("div",{...c,className:b(["auth-reset-password-form",`auth-reset-password-form--${t}`]),"data-testid":"resetPasswordForm",children:[o(v,{title:r.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(N,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(_,{"aria-labelledby":r.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:u,loading:n,fieldsConfig:E(L),children:l("div",{className:"auth-reset-password-form__buttons",children:[o(p,{type:"button",variant:"tertiary",style:{padding:"0"},icon:o(T,{style:{transform:"rotate(90deg)"}}),buttonText:r.buttonSecondary,enableLoader:!1,onClick:i}),o(p,{type:"submit",buttonText:r.buttonPrimary,variant:"primary",enableLoader:n})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{$ as R}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SignInForm.js b/scripts/__dropins__/storefront-auth/chunks/SignInForm.js index 176029a77c..bdcc184eae 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SignInForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/SignInForm.js @@ -1 +1,3 @@ -import{jsx as u,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as z}from"@dropins/tools/lib.js";import{g as V,c as _,u as O,F as R,B as H}from"./UpdatePasswordForm.js";import{useState as g,useCallback as F,useEffect as J,useMemo as tt}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as at}from"./getCustomerToken.js";import{r as rt}from"./resendConfirmationEmail.js";import{s as et,a as ot}from"./simplifyTransformAttributesForm.js";import{c as it}from"./confirmEmail.js";import{useText as Q}from"@dropins/tools/i18n.js";import{Header as st,InLineAlert as nt,InputPassword as mt}from"@dropins/tools/components.js";/* empty css */import{E as ct}from"./EmailConfirmationForm.js";const ut=({emailConfirmationStatusMessage:t,translations:r,initialEmailValue:i,routeSignUp:l,routeForgotPassword:m,routeRedirectOnSignIn:E,onErrorCallback:w,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:e,routeRedirectOnEmailConfirmationClose:N})=>{const[k,P]=g(""),[L,s]=g(!1),[M,d]=g(""),[T,y]=g(!1),[S,C]=g({userName:"",status:!1}),[B,b]=g(!1),[p,x]=g([]),I=F(async n=>{e(),s(!0),y(!1),x([]),await rt(n)},[e]),v=F(n=>{n.length?y(!1):y(!0),d(n)},[]);J(()=>{t!=null&&t.text&&e({text:t.text,type:t.status?t.status:void 0})},[t,e]);const U=F(async n=>{var K;e(),b(!0);const c=V(n.target);if(c.password||(y(!0),b(!1)),c!=null&&c.email&&(c!=null&&c.password)){const{email:G,password:X}=c,o=await at({email:G,password:X,handleSetInLineAlertProps:e,onErrorCallback:w,translations:r});if((K=o==null?void 0:o.errorMessage)!=null&&K.length){P(G);const $=o.errorMessage.includes("This account isn't confirmed. Verify and try again."),Y=$?r.resendEmailInformationText:o.errorMessage;x($?[{label:r.resendEmailButtonText,onClick:()=>{I(G)}}]:[]),e({text:Y,type:"error"}),d("")}o!=null&&o.userName&&(n.target.reset(),_(E)?window.location.href=E():(f==null||f({userName:o==null?void 0:o.userName,status:!0}),C({userName:o==null?void 0:o.userName,status:!0}))),y(!1)}b(!1)},[e,w,r,I,E,f]),q=F(()=>{if(_(a)){a("resetPasswordForm");return}_(m)&&(window.location.href=m())},[m,a]),j=F(()=>{if(_(h)&&h(),_(a)){a("signUpForm");return}_(l)&&(window.location.href=l())},[h,l,a]),D=tt(()=>{const n=et(ot);return i!=null&&i.length?n==null?void 0:n.map(c=>({...c,defaultValue:i})):n},[i]),W=F(()=>{e(),_(N)?window.location.href=N():s(!1)},[e,N]);return{additionalActionsAlert:p,userEmail:k,defaultEnhancedEmailFields:D,passwordError:T,isSuccessful:S,isLoading:B,signInPasswordValue:M,showEmailConfirmationForm:L,setShowEmailConfirmationForm:s,setSignInPasswordValue:d,submitLogInUser:U,forgotPasswordCallback:q,onSignUpLinkClickCallback:j,handledOnPrimaryButtonClick:W,handleSetPassword:v}},ft=()=>{let t=new URL(window.location.href),r=t.searchParams.get("email"),i=t.searchParams.get("key");r&&i&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},dt=({enableEmailConfirmation:t})=>{const r=Q({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[i,l]=g({text:"",status:""});return J(()=>{if(t){const{search:m}=window.location;m.includes("email=")&&m.includes("key=")&&(async()=>{var f,h,e;const w=new URLSearchParams(m),a=await it({customerEmail:w.get("email"),customerConfirmationKey:w.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?r.accountConfirmationEmailSuccessMessage.replace("{email}",(e=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:e.email):r.accountConfirmMessage,status:"success"}),ft())})()}},[t,r]),{emailConfirmationStatusMessage:i}},At=({slots:t,labels:r,formSize:i="default",initialEmailValue:l="",renderSignUpLink:m=!1,enableEmailConfirmation:E=!1,hideCloseBtnOnEmailConfirmation:w=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:e,onSuccessCallback:N,setActiveComponent:k,onErrorCallback:P,onSignUpLinkClick:L})=>{const s=Q({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{emailConfirmationStatusMessage:M}=dt({enableEmailConfirmation:E}),{inLineAlertProps:d,handleSetInLineAlertProps:T}=O(),{userEmail:y,additionalActionsAlert:S,defaultEnhancedEmailFields:C,passwordError:B,isSuccessful:b,isLoading:p,signInPasswordValue:x,showEmailConfirmationForm:I,submitLogInUser:v,forgotPasswordCallback:U,onSignUpLinkClickCallback:q,handledOnPrimaryButtonClick:j,handleSetPassword:D}=ut({translations:s,emailConfirmationStatusMessage:M,initialEmailValue:l,routeSignUp:e,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:k,onErrorCallback:P,onSuccessCallback:N,onSignUpLinkClick:L,handleSetInLineAlertProps:T,routeRedirectOnEmailConfirmationClose:a});return b.status&&(t!=null&&t.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:b}}):I?u(ct,{formSize:i,userEmail:y,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:w,handleSetInLineAlertProps:T,onPrimaryButtonClick:j}):A("div",{className:z(["auth-sign-in-form",`auth-sign-in-form--${i}`]),"data-testid":"signInForm",children:[u(st,{title:(r==null?void 0:r.formTitleText)??s.title,divider:!1,className:"auth-sign-in-form__title"}),d.text?u(nt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:S}):null,A(R,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:v,loading:p,fieldsConfig:C,children:[u(mt,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:B?s.requiredFieldError:void 0,defaultValue:x,onValue:D,placeholder:s.placeholder,floatingLabel:s.floatingLabel}),A("div",{className:"auth-sign-in-form__form__buttons",children:[A("div",{className:"auth-sign-in-form__form__buttons__combine",children:[u(H,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:U,"data-testid":"switchToSignUp"}),m?u("span",{}):null,m?u(H,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:q}):null]}),u(H,{type:"submit",buttonText:(r==null?void 0:r.primaryButtonText)??s.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:p})]})]}),u("div",{id:"generateCustomerToken"})]})};export{At as S}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as c,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as z,classes as R}from"@dropins/tools/lib.js";import{c as E,g as tt,u as rt,F as at,B as K}from"./Button2.js";import{useState as y,useCallback as m,useEffect as J,useMemo as et}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as ot}from"./getCustomerToken.js";import{r as it}from"./resendConfirmationEmail.js";import{s as st,a as nt}from"./simplifyTransformAttributesForm.js";import{f as ut,E as ct}from"./focusOnEmptyPasswordField.js";import{c as mt}from"./confirmEmail.js";import{useText as O}from"@dropins/tools/i18n.js";import{Header as ft,InLineAlert as dt,InputPassword as lt}from"@dropins/tools/components.js";/* empty css */const ht=({emailConfirmationStatusMessage:t,translations:e,initialEmailValue:s,routeSignUp:l,routeForgotPassword:u,routeRedirectOnSignIn:F,onErrorCallback:_,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:i,routeRedirectOnEmailConfirmationClose:x})=>{const[S,L]=y(""),[v,n]=y(!1),[g,d]=y(""),[A,w]=y(!1),[U,j]=y({userName:"",status:!1}),[q,T]=y(!1),[P,N]=y([]),k=m(async r=>{i(),n(!0),w(!1),N([]),await it(r)},[i]),V=m(r=>{r.length?w(!1):w(!0),d(r)},[]);J(()=>{t!=null&&t.text&&i({text:t.text,type:t.status?t.status:void 0})},[t,i]);const D=m(()=>{g.length||w(!0)},[g]),p=m((r,o)=>g.length?!1:(w(!0),o&&ut(r,g,""),!0),[g]),B=m((r,o)=>{o!=null&&o.userName&&(r.target.reset(),E(F)?window.location.href=F():(f==null||f({userName:o==null?void 0:o.userName,status:!0}),j({userName:o==null?void 0:o.userName,status:!0})))},[f,F]),C=m((r,o)=>{var I;if((I=r==null?void 0:r.errorMessage)!=null&&I.length){L(o);const H=r.errorMessage.includes("This account isn't confirmed. Verify and try again."),b=H?e.resendEmailInformationText:r.errorMessage;N(H?[{label:e.resendEmailButtonText,onClick:()=>{k(o)}}]:[]),i({text:b,type:"error"}),d("")}},[k,i,e.resendEmailButtonText,e.resendEmailInformationText]),G=m(async(r,o)=>{if(i(),p(r,o))return;T(!0);const I=tt(r.target);if(Object.values(I).every(b=>b)){const{email:b,password:Z}=I,$=await ot({email:b,password:Z,handleSetInLineAlertProps:i,onErrorCallback:_,translations:e});C($,b),B(r,$),w(!1)}T(!1)},[e,_,p,C,B,i]),Q=m(()=>{if(E(a)){a("resetPasswordForm");return}E(u)&&(window.location.href=u())},[u,a]),W=m(()=>{if(E(h)&&h(),E(a)){a("signUpForm");return}E(l)&&(window.location.href=l())},[h,l,a]),X=et(()=>{const r=st(nt);return s!=null&&s.length?r==null?void 0:r.map(o=>({...o,defaultValue:s})):r},[s]),Y=m(()=>{i(),E(x)?window.location.href=x():n(!1)},[i,x]);return{additionalActionsAlert:P,userEmail:S,defaultEnhancedEmailFields:X,passwordError:A,isSuccessful:U,isLoading:q,signInPasswordValue:g,showEmailConfirmationForm:v,setShowEmailConfirmationForm:n,setSignInPasswordValue:d,submitLogInUser:G,forgotPasswordCallback:Q,onSignUpLinkClickCallback:W,handledOnPrimaryButtonClick:Y,handleSetPassword:V,onBlurPassword:D}},gt=()=>{let t=new URL(window.location.href),e=t.searchParams.get("email"),s=t.searchParams.get("key");e&&s&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},wt=({enableEmailConfirmation:t})=>{const e=O({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[s,l]=y({text:"",status:""});return J(()=>{if(t){const{search:u}=window.location;u.includes("email=")&&u.includes("key=")&&(async()=>{var f,h,i;const _=new URLSearchParams(u),a=await mt({customerEmail:_.get("email"),customerConfirmationKey:_.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?e.accountConfirmationEmailSuccessMessage.replace("{email}",(i=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:i.email):e.accountConfirmMessage,status:"success"}),gt())})()}},[t,e]),{emailConfirmationStatusMessage:s}},Ct=({slots:t,labels:e,formSize:s="default",initialEmailValue:l="",renderSignUpLink:u=!1,enableEmailConfirmation:F=!1,hideCloseBtnOnEmailConfirmation:_=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:i,onSuccessCallback:x,setActiveComponent:S,onErrorCallback:L,onSignUpLinkClick:v})=>{const n=O({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{emailConfirmationStatusMessage:g}=wt({enableEmailConfirmation:F}),{inLineAlertProps:d,handleSetInLineAlertProps:A}=rt(),{userEmail:w,additionalActionsAlert:U,defaultEnhancedEmailFields:j,passwordError:q,isSuccessful:T,isLoading:P,signInPasswordValue:N,showEmailConfirmationForm:k,submitLogInUser:V,forgotPasswordCallback:D,onSignUpLinkClickCallback:p,handledOnPrimaryButtonClick:B,handleSetPassword:C,onBlurPassword:G}=ht({translations:n,emailConfirmationStatusMessage:g,initialEmailValue:l,routeSignUp:i,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:S,onErrorCallback:L,onSuccessCallback:x,onSignUpLinkClick:v,handleSetInLineAlertProps:A,routeRedirectOnEmailConfirmationClose:a});return T.status&&(t!=null&&t.SuccessNotification)?c(z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:T}}):k?c(ct,{formSize:s,userEmail:w,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:_,handleSetInLineAlertProps:A,onPrimaryButtonClick:B}):M("div",{className:R(["auth-sign-in-form",`auth-sign-in-form--${s}`]),"data-testid":"signInForm",children:[c(ft,{title:(e==null?void 0:e.formTitleText)??n.title,divider:!1,className:"auth-sign-in-form__title"}),d.text?c(dt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:U}):null,M(at,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:V,loading:P,fieldsConfig:j,children:[c(lt,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:q?n.requiredFieldError:void 0,defaultValue:N,onValue:C,onBlur:G,placeholder:n.placeholder,floatingLabel:n.floatingLabel}),M("div",{className:"auth-sign-in-form__form__buttons",children:[M("div",{className:"auth-sign-in-form__form__buttons__combine",children:[c(K,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:D,"data-testid":"switchToSignUp"}),u?c("span",{}):null,u?c(K,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:p}):null]}),c(K,{type:"submit",buttonText:(e==null?void 0:e.primaryButtonText)??n.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:P})]})]}),c("div",{id:"generateCustomerToken"})]})};export{Ct as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js index 6a8460f92f..0d80a4963f 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js @@ -1 +1,3 @@ -import{jsx as o,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Fe,classes as _e}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Pe,c as we,a as Ne}from"./createCustomerAddress.js";import{useState as d,useEffect as Le,useCallback as q}from"@dropins/tools/preact-hooks.js";import{s as ae,b as ye}from"./simplifyTransformAttributesForm.js";import{v as Ue,u as Te,a as xe}from"./usePasswordValidationMessage.js";import{a as Ee}from"./getCustomerToken.js";import{p as me,E as ne}from"./getStoreConfig.js";import{c as I,g as Me,u as Se,F as Ce,B as ue}from"./UpdatePasswordForm.js";import{c as ve}from"./transform-attributes-form.js";import{Header as Ae,InLineAlert as qe,InputPassword as ce,Field as R,Checkbox as ee}from"@dropins/tools/components.js";/* empty css */import{S as Ke}from"./SkeletonLoader.js";import{E as Be}from"./EmailConfirmationForm.js";import{useText as je}from"@dropins/tools/i18n.js";const le=(m,e)=>e!=null&&e.length?m.map(r=>{var n;const t=(n=e.find(({code:a})=>a===r.code))==null?void 0:n.defaultValue;return t?{...r,defaultValue:t}:r}):m,Ge=({inputsDefaultValueSet:m,fieldsConfigForApiVersion1:e,apiVersion2:r})=>{const[t,n]=d([]);return Le(()=>{(async()=>{if(r){const s=await Pe("customer_account_create");if(s!=null&&s.length)if(m!=null&&m.length){const f=le(s,m);n(f)}else n(s)}else{const s=ae(ye),f=ae(e),F=le(s,m);n(e&&e.length?f:F)}})()},[r,e,m]),{fieldsListConfigs:t}},He=(m,e)=>{const r=["date_of_birth","dob","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],t=ve(m,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!e)return{...t,...t!=null&&t.gender?{gender:Number(t==null?void 0:t.gender)}:{}};const n={},a=[];return Object.keys(t).forEach(s=>{r.includes(s)?n[s]=s.includes("gender")?Number(t[s]):t[s]:a.push({attribute_code:s,value:t[s]})}),a.length>0&&(n.custom_attributes=a),n},Ie=({requireRetypePassword:m,addressesData:e,translations:r,isEmailConfirmationRequired:t,apiVersion2:n=!0,passwordConfigs:a,isAutoSignInEnabled:s,routeRedirectOnSignIn:f,routeSignIn:F,onErrorCallback:w,onSuccessCallback:c,setActiveComponent:g,handleSetInLineAlertProps:h,routeRedirectOnEmailConfirmationClose:T})=>{const[N,V]=d(""),[p,i]=d(""),[l,x]=d(""),[K,_]=d(!1),[B,E]=d({userName:"",status:!1}),[L,M]=d(""),[W,$]=d(!1),[j,P]=d(!1),[S,G]=d(!0),J=q(u=>{V(u),i(u?L===u?"":r.passwordMismatch:r.requiredFieldError)},[r,L]),O=q(({target:u})=>{G(u.checked)},[]),Q=q(()=>{if(I(g)){g("signInForm");return}I(F)&&(window.location.href=F())},[g,F]),X=q(u=>{M(u)},[]),Y=q(()=>{h(),M(""),I(T)?window.location.href=T():(_(!1),g==null||g("signInForm"))},[h,T,g]),C=()=>{$(!0),P(!1)};return{confirmPassword:N,confirmPasswordMessage:p,isKeepMeLogged:S,userEmail:l,showEmailConfirmationForm:K,isSuccessful:B,isClickSubmit:W,signUpPasswordValue:L,isLoading:j,onSubmitSignUp:async(u,k)=>{var te,ie,se;if(h(),i(""),P(!0),!k){C(),!N&&i(r.requiredFieldError);return}if(m&&(p.length||L!==N)){C(),i(N.length?r.passwordMismatch:r.requiredFieldError);return}const de=n?"createCustomerV2":"createCustomer",{confirmPasswordField:Ve,...re}=Me(u.target),{email:z,password:v,is_subscribed:fe}=re,ge=(a==null?void 0:a.requiredCharacterClasses)||0,he=(a==null?void 0:a.minLength)||1;if(!Ue(v,ge)||he>(v==null?void 0:v.length)){C();return}const pe=He({...re,is_subscribed:!!fe||!1},n),{data:y,errors:U}=await we(pe,n),H=((ie=(te=y==null?void 0:y.createCustomer)==null?void 0:te.customer)==null?void 0:ie.firstname)||"";if(U&&(U!=null&&U.length))h==null||h({type:"error",text:U[0].message}),w==null||w(U),me(ne.CREATE_ACCOUNT_EVENT,{updateProfile:!1}),x(z);else{const D={email:"",...y==null?void 0:y[de]};if(me(ne.CREATE_ACCOUNT_EVENT,{email:D==null?void 0:D.email,updateProfile:!0}),t||!s){if(c==null||c({userName:H,status:!0}),t){(se=u.target)==null||se.reset(),M(""),_(!0),x(z),P(!1);return}if(!s){P(!1),E({userName:H,status:!0});return}}const b=await Ee({email:z,password:v,translations:r,handleSetInLineAlertProps:h,onErrorCallback:w});if(b!=null&&b.userName){if(e!=null&&e.length)for(const oe of e)try{await Ne(oe)}catch(be){console.error(r.failedCreateCustomerAddress,oe,be)}I(f)?window.location.href=f():(c==null||c({userName:b==null?void 0:b.userName,status:!0}),E({userName:b==null?void 0:b.userName,status:!0}))}else c==null||c({userName:H,status:!0}),E({userName:H,status:!0})}P(!1)},signInButton:Q,handleSetSignUpPasswordValue:X,onKeepMeLoggedChange:O,handleHideEmailConfirmationForm:Y,handleConfirmPasswordChange:J}},or=({requireRetypePassword:m=!1,addressesData:e,formSize:r="default",inputsDefaultValueSet:t,fieldsConfigForApiVersion1:n,apiVersion2:a=!0,isAutoSignInEnabled:s=!0,displayTermsOfUseCheckbox:f=!1,displayNewsletterCheckbox:F=!1,hideCloseBtnOnEmailConfirmation:w=!1,routeRedirectOnEmailConfirmationClose:c,routeRedirectOnSignIn:g,routeSignIn:h,onErrorCallback:T,onSuccessCallback:N,setActiveComponent:V,slots:p})=>{const i=je({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",privacyPolicyDefaultText:"Auth.SignUpForm.privacyPolicyDefaultText",subscribedDefaultText:"Auth.SignUpForm.subscribedDefaultText",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:l,isEmailConfirmationRequired:x}=Te(),{fieldsListConfigs:K}=Ge({fieldsConfigForApiVersion1:n,apiVersion2:a,inputsDefaultValueSet:t}),{inLineAlertProps:_,handleSetInLineAlertProps:B}=Se(),{confirmPassword:E,confirmPasswordMessage:L,isKeepMeLogged:M,userEmail:W,showEmailConfirmationForm:$,isSuccessful:j,isClickSubmit:P,signUpPasswordValue:S,isLoading:G,onSubmitSignUp:J,signInButton:O,handleSetSignUpPasswordValue:Q,onKeepMeLoggedChange:X,handleHideEmailConfirmationForm:Y,handleConfirmPasswordChange:C}=Ie({requireRetypePassword:m,addressesData:e,translations:i,isEmailConfirmationRequired:x,apiVersion2:a,passwordConfigs:l,isAutoSignInEnabled:s,routeRedirectOnSignIn:g,routeSignIn:h,onErrorCallback:T,onSuccessCallback:N,setActiveComponent:V,handleSetInLineAlertProps:B,routeRedirectOnEmailConfirmationClose:c}),{isValidUniqueSymbols:Z,defaultLengthMessage:u}=xe({password:S,isClickSubmit:P,passwordConfigs:l}),k=!x&&(e==null?void 0:e.length);return!K.length&&a?o("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:o(Ke,{activeSkeleton:"signUpForm"})}):j.status&&(p!=null&&p.SuccessNotification)?o(Fe,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:p==null?void 0:p.SuccessNotification,context:{isSuccessful:j}}):$?o(Be,{formSize:r,userEmail:W,inLineAlertProps:_,hideCloseBtnOnEmailConfirmation:w,handleSetInLineAlertProps:B,onPrimaryButtonClick:Y}):A("div",{className:_e(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[o(Ae,{title:i.title,divider:!1,className:"auth-sign-up-form__title"}),_.text?o(qe,{className:"auth-sign-up-form__notification",type:_.type,variant:"secondary",heading:_.text,icon:_.icon}):null,A(Ce,{onSubmit:J,className:"auth-sign-up-form__form",loading:G,name:"signUp_form",fieldsConfig:K,children:[A(ce,{validateLengthConfig:u,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:l==null?void 0:l.minLength,errorMessage:Z==="error"||(u==null?void 0:u.status)==="error"||P&&S.length<=0?i.requiredFieldError:void 0,defaultValue:S,uniqueSymbolsStatus:Z,requiredCharacterClasses:l==null?void 0:l.requiredCharacterClasses,onValue:Q,placeholder:i.placeholder,floatingLabel:i.floatingLabel,children:[m?o("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:o(ce,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:i.confirmPasswordPlaceholder,floatingLabel:i.confirmPasswordFloatingLabel,errorMessage:L,defaultValue:E,onValue:C})}):null,k?o("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:o(R,{children:o(ee,{name:"",placeholder:i.keepMeLoggedText,label:i.keepMeLoggedText,checked:M,onChange:X})})}):null]}),F||f?A("div",{className:"auth-sign-up-form__item auth-sign-up-form__checkbox",children:[F?o(R,{children:o(ee,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:i.subscribedDefaultText,label:i.subscribedDefaultText})}):null,f?o(R,{children:o(ee,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:i.privacyPolicyDefaultText,label:i.privacyPolicyDefaultText})}):null]}):null,A("div",{className:"auth-sign-up-form-buttons",children:[o(ue,{type:"button",variant:"tertiary",style:{padding:0},buttonText:i.buttonSecondary,enableLoader:!1,onClick:O}),o(ue,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:G})]})]}),o("div",{id:"createCustomerV2"})]})};export{or as S}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as n,jsxs as I}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Ee,classes as Ne}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as ye,c as Ue,a as Le}from"./createCustomerAddress.js";import{useState as p,useEffect as Me,useCallback as x,useMemo as Te}from"@dropins/tools/preact-hooks.js";import{s as de,b as xe}from"./simplifyTransformAttributesForm.js";import{v as Se,u as ve,a as qe}from"./usePasswordValidationMessage.js";import{a as Ce}from"./getCustomerToken.js";import{p as le,E as ce}from"./getStoreConfig.js";import{c as $,g as Ae,u as Be,F as Ke,B as fe}from"./Button2.js";import{c as je}from"./transform-attributes-form.js";import{f as he,E as Ie}from"./focusOnEmptyPasswordField.js";import{Header as Ge,InLineAlert as He,InputPassword as ge,Field as te,Checkbox as se}from"@dropins/tools/components.js";/* empty css */import{S as Ve}from"./SkeletonLoader.js";import{useText as We}from"@dropins/tools/i18n.js";const pe=(u,t)=>t!=null&&t.length?u.map(e=>{var d;const s=(d=t.find(({code:m})=>m===e.code))==null?void 0:d.defaultValue;return s?{...e,defaultValue:s}:e}):u,$e=({inputsDefaultValueSet:u,fieldsConfigForApiVersion1:t,apiVersion2:e})=>{const[s,d]=p([]);return Me(()=>{(async()=>{if(e){const i=await ye("customer_account_create");if(i!=null&&i.length)if(u!=null&&u.length){const w=pe(i,u);d(w)}else d(i)}else{const i=de(xe),w=de(t),N=pe(i,u);d(t&&t.length?w:N)}})()},[e,t,u]),{fieldsListConfigs:s}},Oe=(u,t)=>{const e=["date_of_birth","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],s=je(u,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!t)return{...s,...s!=null&&s.gender?{gender:Number(s==null?void 0:s.gender)}:{}};const d={},m=[];return Object.keys(s).forEach(i=>{e.includes(i)?d[i]=i.includes("gender")?Number(s[i]):s[i]:m.push({attribute_code:i,value:s[i]})}),m.length>0&&(d.custom_attributes=m),d},Je=({requireRetypePassword:u,addressesData:t,translations:e,isEmailConfirmationRequired:s,apiVersion2:d=!0,passwordConfigs:m,isAutoSignInEnabled:i,routeRedirectOnSignIn:w,routeSignIn:N,onErrorCallback:S,onSuccessCallback:h,setActiveComponent:b,handleSetInLineAlertProps:P,routeRedirectOnEmailConfirmationClose:q})=>{const[O,C]=p(!1),[o,a]=p(""),[g,l]=p(""),[G,y]=p(""),[H,A]=p(!1),[J,B]=p({userName:"",status:!1}),[c,K]=p(""),[Q,V]=p(!1),[X,U]=p(!1),[W,Y]=p(!0),Z=x(r=>{const f=r.target.value;C(!f.length),f.length&&o.length&&f!==o&&l(e.passwordMismatch)},[o,e.passwordMismatch]),k=x(r=>{const f=r.target.value;l(f.length?"":e.requiredFieldError),f.length&&c.length&&f!==c&&l(e.passwordMismatch)},[c,e.passwordMismatch,e.requiredFieldError]),z=x(r=>{a(r),l(r?c===r?"":e.passwordMismatch:e.requiredFieldError)},[e,c]),D=x(({target:r})=>{Y(r.checked)},[]),R=x(()=>{if($(b)){b("signInForm");return}$(N)&&(window.location.href=N())},[b,N]),ee=x(r=>{K(r),C(!r.length),r===o&&l("")},[o]),re=x(()=>{P(),K(""),$(q)?window.location.href=q():(A(!1),b==null||b("signInForm"))},[P,q,b]),L=()=>{V(!0),U(!1)},_=(r,f)=>{const oe=c.length&&o.length,j=c!==o,v=()=>{C(!c.length),o||l(e.requiredFieldError),oe&&j&&l(e.passwordMismatch)},M=()=>{l(o.length?e.passwordMismatch:e.requiredFieldError),he(r,c,o)};return f?u&&(g.length||j)?(L(),M(),!0):(he(r,c,""),v(),!1):(L(),v(),!0)};return{showPasswordErrorMessage:O,confirmPassword:o,confirmPasswordMessage:g,isKeepMeLogged:W,userEmail:G,showEmailConfirmationForm:H,isSuccessful:J,isClickSubmit:Q,signUpPasswordValue:c,isLoading:X,onSubmitSignUp:async(r,f)=>{var ae,ne,me;if(P(),l(""),U(!0),_(r,f))return;const{confirmPasswordField:oe,...j}=Ae(r.target),{email:v,password:M,is_subscribed:Fe}=j,we=(m==null?void 0:m.requiredCharacterClasses)||0,be=(m==null?void 0:m.minLength)||1;if(!Se(M,we)||be>(M==null?void 0:M.length)){L();return}const Pe=Oe({...j,is_subscribed:!!Fe||!1},d),F=await Ue(Pe,d);if((ae=F==null?void 0:F.errors)!=null&&ae.length){const{errors:T}=F;P==null||P({type:"error",text:(ne=T[0])==null?void 0:ne.message}),S==null||S(T),le(ce.CREATE_ACCOUNT_EVENT,{updateProfile:!1}),y(v)}else{const T=F==null?void 0:F.firstName;if(le(ce.CREATE_ACCOUNT_EVENT,{email:F==null?void 0:F.email,updateProfile:!0}),s||!i){if(h==null||h({userName:T,status:!0}),s){(me=r.target)==null||me.reset(),K(""),A(!0),y(v),U(!1);return}if(!i){U(!1),B({userName:T,status:!0});return}}const E=await Ce({email:v,password:M,translations:e,handleSetInLineAlertProps:P,onErrorCallback:S});if(E!=null&&E.userName){if(t!=null&&t.length)for(const ue of t)try{await Le(ue)}catch(_e){console.error(e.failedCreateCustomerAddress,ue,_e)}$(w)?window.location.href=w():(h==null||h({userName:E==null?void 0:E.userName,status:!0}),B({userName:E==null?void 0:E.userName,status:!0}))}else h==null||h({userName:T,status:!0}),B({userName:T,status:!0})}U(!1)},signInButton:R,handleSetSignUpPasswordValue:ee,onKeepMeLoggedChange:D,handleHideEmailConfirmationForm:re,handleConfirmPasswordChange:z,onBlurPassword:Z,onBlurConfirmPassword:k}},ur=({requireRetypePassword:u=!1,addressesData:t,formSize:e="default",inputsDefaultValueSet:s,fieldsConfigForApiVersion1:d,apiVersion2:m=!0,isAutoSignInEnabled:i=!0,displayTermsOfUseCheckbox:w=!1,displayNewsletterCheckbox:N=!1,hideCloseBtnOnEmailConfirmation:S=!1,routeRedirectOnEmailConfirmationClose:h,routeRedirectOnSignIn:b,routeSignIn:P,onErrorCallback:q,onSuccessCallback:O,setActiveComponent:C,slots:o})=>{const a=We({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",privacyPolicyDefaultText:"Auth.SignUpForm.privacyPolicyDefaultText",subscribedDefaultText:"Auth.SignUpForm.subscribedDefaultText",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:g,isEmailConfirmationRequired:l}=ve(),{fieldsListConfigs:G}=$e({fieldsConfigForApiVersion1:d,apiVersion2:m,inputsDefaultValueSet:s}),{inLineAlertProps:y,handleSetInLineAlertProps:H}=Be(),{showPasswordErrorMessage:A,confirmPassword:J,confirmPasswordMessage:B,isKeepMeLogged:c,userEmail:K,showEmailConfirmationForm:Q,isSuccessful:V,isClickSubmit:X,signUpPasswordValue:U,isLoading:W,onSubmitSignUp:Y,signInButton:Z,handleSetSignUpPasswordValue:k,onKeepMeLoggedChange:z,handleHideEmailConfirmationForm:D,handleConfirmPasswordChange:R,onBlurPassword:ee,onBlurConfirmPassword:re}=Je({requireRetypePassword:u,addressesData:t,translations:a,isEmailConfirmationRequired:l,apiVersion2:m,passwordConfigs:g,isAutoSignInEnabled:i,routeRedirectOnSignIn:b,routeSignIn:P,onErrorCallback:q,onSuccessCallback:O,setActiveComponent:C,handleSetInLineAlertProps:H,routeRedirectOnEmailConfirmationClose:h}),{isValidUniqueSymbols:L,defaultLengthMessage:_}=qe({password:U,isClickSubmit:X,passwordConfigs:g}),ie=Te(()=>A?a.requiredFieldError:L==="error"||(_==null?void 0:_.status)==="error"?" ":"",[_==null?void 0:_.status,L,A,a.requiredFieldError]),r=!l&&(t==null?void 0:t.length);return!G.length&&m?n("div",{className:`auth-sign-up-form auth-sign-up-form--${e} skeleton-loader`,"data-testid":"SignUpForm",children:n(Ve,{activeSkeleton:"signUpForm"})}):V.status&&(o!=null&&o.SuccessNotification)?n(Ee,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:o==null?void 0:o.SuccessNotification,context:{isSuccessful:V}}):Q?n(Ie,{formSize:e,userEmail:K,inLineAlertProps:y,hideCloseBtnOnEmailConfirmation:S,handleSetInLineAlertProps:H,onPrimaryButtonClick:D}):I("div",{className:Ne(["auth-sign-up-form",`auth-sign-up-form--${e}`]),"data-testid":"SignUpForm",children:[n(Ge,{title:a.title,divider:!1,className:"auth-sign-up-form__title"}),y.text?n(He,{className:"auth-sign-up-form__notification",type:y.type,variant:"secondary",heading:y.text,icon:y.icon}):null,I(Ke,{onSubmit:Y,className:"auth-sign-up-form__form",loading:W,name:"signUp_form",fieldsConfig:G,children:[I(ge,{validateLengthConfig:_,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:g==null?void 0:g.minLength,errorMessage:ie,defaultValue:U,uniqueSymbolsStatus:L,requiredCharacterClasses:g==null?void 0:g.requiredCharacterClasses,onValue:k,placeholder:a.placeholder,floatingLabel:a.floatingLabel,onBlur:ee,children:[u?n("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:n(ge,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:a.confirmPasswordPlaceholder,floatingLabel:a.confirmPasswordFloatingLabel,errorMessage:B,defaultValue:J,onValue:R,onBlur:re})}):null,r?n("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:n(te,{children:n(se,{name:"",placeholder:a.keepMeLoggedText,label:a.keepMeLoggedText,checked:c,onChange:z})})}):null]}),N||w?I("div",{className:"auth-sign-up-form__item auth-sign-up-form__checkbox",children:[N?n(te,{children:n(se,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:a.subscribedDefaultText,label:a.subscribedDefaultText})}):null,w?n(te,{children:n(se,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:a.privacyPolicyDefaultText,label:a.privacyPolicyDefaultText})}):null]}):null,I("div",{className:"auth-sign-up-form-buttons",children:[n(fe,{type:"button",variant:"tertiary",style:{padding:0},buttonText:a.buttonSecondary,enableLoader:!1,onClick:Z}),n(fe,{type:"submit",buttonText:a.buttonPrimary,variant:"primary",enableLoader:W})]})]}),n("div",{id:"createCustomerV2"})]})};export{ur as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js b/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js index efe1f36240..6bdfef8665 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js +++ b/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsxs as l,jsx as e,Fragment as r}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as s}from"@dropins/tools/preact-hooks.js";import{Skeleton as a,SkeletonRow as i}from"@dropins/tools/components.js";const d=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),h=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),u=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),o=({activeSkeleton:n})=>{const t=s(()=>({signInForm:e(h,{}),signUpForm:e(d,{}),resetPasswordForm:e(u,{})}),[]);return e(r,{children:t[n]})};export{o as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js b/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js deleted file mode 100644 index e26482daa9..0000000000 --- a/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js +++ /dev/null @@ -1 +0,0 @@ -import{jsx as h,Fragment as Z,jsxs as U}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useCallback as v,useRef as H,useEffect as P}from"@dropins/tools/preact-hooks.js";import*as $ from"@dropins/tools/preact-compat.js";import{memo as W,useCallback as _}from"@dropins/tools/preact-compat.js";import{initReCaptcha as G}from"@dropins/tools/recaptcha.js";import{useText as j}from"@dropins/tools/i18n.js";import{classes as L}from"@dropins/tools/lib.js";import{Field as w,Picker as q,Input as X,InputDate as C,Checkbox as z,TextArea as B,Button as J}from"@dropins/tools/components.js";const Ir=r=>{if(!r)return null;const t=new FormData(r);if(t&&typeof t.entries=="function"){const n=t.entries();if(n&&typeof n[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(n)))||{}}return{}},Dr=r=>typeof r=="function",Y=r=>$.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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)"})))),K=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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"})),Q=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),g={success:h(K,{}),warning:h(Y,{}),error:h(Q,{})},xr=()=>{const[r,t]=R({}),n=v(l=>{if(!l||!l.type){t({});return}const c=g[l.type];t({...l,icon:c})},[]);return{inLineAlertProps:r,handleSetInLineAlertProps:n}};var m=(r=>(r.BOOLEAN="BOOLEAN",r.DATE="DATE",r.DATETIME="DATETIME",r.DROPDOWN="DROPDOWN",r.FILE="FILE",r.GALLERY="GALLERY",r.HIDDEN="HIDDEN",r.IMAGE="IMAGE",r.MEDIA_IMAGE="MEDIA_IMAGE",r.MULTILINE="MULTILINE",r.MULTISELECT="MULTISELECT",r.PRICE="PRICE",r.SELECT="SELECT",r.TEXT="TEXT",r.TEXTAREA="TEXTAREA",r.UNDEFINED="UNDEFINED",r.VISUAL="VISUAL",r.WEIGHT="WEIGHT",r.EMPTY="",r))(m||{});const rr=W(({loading:r,values:t,fields:n=[],errors:l,className:c="",onChange:u,onBlur:p,onFocus:A})=>{const s=`${c}__field`,f=_((e,o,a)=>{var T;const E=(T=e.options.find(N=>N.isDefault))==null?void 0:T.value;return h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(q,{name:e.customUpperCode,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:p,handleSelect:u,defaultValue:E??o??e.defaultValue,value:E??o??e.defaultValue})},e.id)},[c,r,s,p,u]),D=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(X,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,onFocus:A})},e.id),[c,r,s,p,u,A]),x=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(C,{type:"text",name:e.customUpperCode,value:o||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,disabled:r||e.disabled})},e.id),[c,r,s,p,u]),b=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(z,{name:e.customUpperCode,checked:o||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]),M=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(B,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]);return n.length?h(Z,{children:n.map(e=>{const o=l==null?void 0:l[e.customUpperCode],a=t==null?void 0:t[e.customUpperCode];switch(e.fieldType){case m.TEXT:return e.options.length?f(e,a,o):D(e,a,o);case m.MULTILINE:return D(e,a,o);case m.SELECT:return f(e,a,o);case m.DATE:return x(e,a,o);case m.BOOLEAN:return b(e,a,o);case m.TEXTAREA:return M(e,a,o);default:return null}})}):null}),er=r=>r.reduce((t,{customUpperCode:n,required:l,defaultValue:c})=>(l&&n&&(t.initialData[n]=c||"",t.errorList[n]=""),t),{initialData:{},errorList:{}}),tr=r=>r.reduce((t,n)=>({...t,[n.name]:n.value}),{}),ar=r=>/^\d+$/.test(r),nr=r=>/^[a-zA-Z0-9\s]+$/.test(r),or=r=>/^[a-zA-Z0-9]+$/.test(r),lr=r=>/^[a-zA-Z]+$/.test(r),sr=r=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(r),cr=r=>/^\d{4}-\d{2}-\d{2}$/.test(r)&&!isNaN(Date.parse(r)),dr=(r,t,n)=>{const l=new Date(r).getTime()/1e3;return!(isNaN(l)||l<0||typeof t<"u"&&ln)},k=r=>{if(!r||r.trim()==="")return"";const t=parseInt(r,10);if(!isNaN(t)){const c=new Date(t*1e3);return isNaN(c.getTime())?"":c.toISOString().split("T")[0]}const n=new Date(r);if(isNaN(n.getTime()))return"";const l=parseInt(r.split("-")[1],10);return l>12||l<1?"":n.toISOString().split("T")[0]},ur=r=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(r),ir=(r,t,n)=>{const l=r.length;return l>=t&&l<=n},O=(r,t,n,l)=>{var y,F;const{requiredFieldError:c,lengthTextError:u,numericError:p,alphaNumWithSpacesError:A,alphaNumericError:s,alphaError:f,emailError:D,dateError:x,urlError:b,dateLengthError:M,dateMaxError:e,dateMinError:o}=n,a=t==null?void 0:t.customUpperCode,E={[a]:""};if(l[a]&&delete l[a],t!=null&&t.required&&!r)return{[a]:c};if(!(t!=null&&t.required)&&!r||!((y=t==null?void 0:t.validateRules)!=null&&y.length))return E;const T=tr(t==null?void 0:t.validateRules),N=T.MIN_TEXT_LENGTH??1,I=T.MAX_TEXT_LENGTH??255,d=T.DATE_RANGE_MIN,i=T.DATE_RANGE_MAX;if(!ir(r,+N,+I)&&!(d||i))return{[a]:u.replace("{min}",N).replace("{max}",I)};if(!dr(r,+d,+i)&&(d||i)){if(d&&d)return{[a]:M.replace("{min}",k(d)).replace("{max}",k(i))};if(typeof d>"u"||typeof i>"u")return{[a]:i?e.replace("{max}",k(i)):o.replace("{min}",k(d))}}const V={numeric:{validate:ar,error:p},"alphanum-with-spaces":{validate:nr,error:A},alphanumeric:{validate:or,error:s},alpha:{validate:lr,error:f},email:{validate:sr,error:D},date:{validate:cr,error:x},url:{validate:ur,error:b}}[T.INPUT_VALIDATION];return V&&!V.validate(r)&&!((F=l[a])!=null&&F.length)?{[a]:V.error}:E},pr=({fieldsConfig:r,onSubmit:t})=>{const n=j({requiredFieldError:"Auth.FormText.requiredFieldError",lengthTextError:"Auth.FormText.lengthTextError",numericError:"Auth.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Auth.FormText.alphaNumericError",alphaError:"Auth.FormText.alphaError",emailError:"Auth.FormText.emailError",dateError:"Auth.FormText.dateError",dateLengthError:"Auth.FormText.dateLengthError",dateMaxError:"Auth.FormText.dateMaxError",dateMinError:"Auth.FormText.dateMinError",urlError:"Auth.FormText.urlError"}),l=H(null),c=H(!1),[u,p]=R({}),[A,s]=R({}),f=v(()=>{let e=!0;const o={...A};let a=null;for(const[E,T]of Object.entries(u)){const N=r==null?void 0:r.find(d=>{var i;return(i=d==null?void 0:d.customUpperCode)==null?void 0:i.includes(E)}),I=O(T.toString(),N,n,o);I[E]&&(Object.assign(o,I),e=!1),a||(a=Object.keys(o).find(d=>o[d])||null)}if(s(o),a&&l.current){const E=l.current.elements.namedItem(a);E==null||E.focus()}return e},[A,r,u,n]);P(()=>{if(r!=null&&r.length){const{initialData:e,errorList:o}=er(r);p(a=>({...e,...a})),s(o)}},[JSON.stringify(r)]);const D=v(async()=>{c.current||(await G(0),c.current=!0)},[]),x=v(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a;p(i=>({...i,[o]:N}));const I=r==null?void 0:r.find(i=>{var S;return(S=i==null?void 0:i.customUpperCode)==null?void 0:S.includes(o)});let d={...A};if(I){const i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[r,A,n]),b=v(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a,I=r==null?void 0:r.find(d=>d.customUpperCode===o);if(I){const d={...A},i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[A,r,n]),M=v(e=>{e.preventDefault();const o=f();t==null||t(e,o)},[f,t]);return{formData:u,errors:A,formRef:l,handleChange:x,handleBlur:b,handleSubmit:M,handleFocus:D}},br=({name:r,loading:t,children:n,className:l="defaultForm",fieldsConfig:c=[],onSubmit:u})=>{const{formData:p,errors:A,formRef:s,handleChange:f,handleBlur:D,handleSubmit:x,handleFocus:b}=pr({onSubmit:u,fieldsConfig:c});return U("form",{className:l,onSubmit:x,name:r,ref:s,onFocus:b,children:[h(rr,{className:l,onFocus:b,fields:c,onChange:f,onBlur:D,errors:A,values:p,loading:t}),n]})},mr=({type:r,buttonText:t,variant:n,className:l="",enableLoader:c=!1,onClick:u,style:p,icon:A,...s})=>{const f=v(x=>{u==null||u(x)},[u]);return U(J,{icon:A,style:p,type:r,variant:n,className:L(["auth-button",l,c?"enableLoader":""]),onClick:f,...s,children:[h("span",{className:"auth-button__text",children:t}),c?h("div",{className:"auth-button__wrapper",children:h("span",{className:"auth-button__loader"})}):null]})};export{mr as B,br as F,Dr as c,Ir as g,xr as u}; diff --git a/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js b/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js index e4872b447c..c422fff4b9 100644 --- a/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js @@ -1,9 +1,10 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as o,h as r}from"./network-error.js";const t=` mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) { - confirmEmail(input: { - email: $email, - confirmation_key: $confirmation_key - }) { + confirmEmail( + input: { email: $email, confirmation_key: $confirmation_key } + ) { customer { email } diff --git a/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js b/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js index de04a0fab1..dcbc8606a1 100644 --- a/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js +++ b/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js @@ -1,26 +1,24 @@ -import{f as a,h as s}from"./network-error.js";import{s as n}from"./setReCaptchaToken.js";import{t as u}from"./transform-attributes-form.js";import{h as o}from"./getStoreConfig.js";const i=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{CUSTOMER_INFORMATION_FRAGMENT as N}from"../fragments.js";import{f as m,h as u}from"./network-error.js";import{s as I}from"./setReCaptchaToken.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{merge as U}from"@dropins/tools/lib.js";import{c as g}from"./initialize.js";import{t as $}from"./transform-attributes-form.js";import{h as F}from"./getStoreConfig.js";const v=` mutation CREATE_CUSTOMER($input: CustomerInput!) { createCustomer(input: $input) { customer { - firstname - lastname - email - is_subscribed + ...CUSTOMER_INFORMATION_FRAGMENT } } } -`,m=` + ${N} +`,y=` mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) { createCustomerV2(input: $input) { customer { - firstname - lastname - email - is_subscribed + ...CUSTOMER_INFORMATION_FRAGMENT } } } -`,T=async(r,t)=>(await n(),await a(t?m:i,{method:"POST",variables:{input:{...r}}}).catch(s)),c=` + ${N} +`,G=(r,e)=>{var i,a,c,n,C,l,f,E,T,_,R,A,h,S,b,M,O,d,s,p;let o;if(e){const{data:t}=r;o={firstName:((a=(i=t==null?void 0:t.createCustomerV2)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((n=(c=t==null?void 0:t.createCustomerV2)==null?void 0:c.customer)==null?void 0:n.lastname)??"",email:((l=(C=t==null?void 0:t.createCustomerV2)==null?void 0:C.customer)==null?void 0:l.email)??"",isSubscribed:((E=(f=t==null?void 0:t.createCustomerV2)==null?void 0:f.customer)==null?void 0:E.is_subscribed)??!1,customAttributes:((T=t==null?void 0:t.createCustomerV2)==null?void 0:T.custom_attributes)??[],errors:(r==null?void 0:r.errors)??[]}}else{const{data:t}=r;o={firstName:((R=(_=t==null?void 0:t.createCustomer)==null?void 0:_.customer)==null?void 0:R.firstname)??"",lastName:((h=(A=t==null?void 0:t.createCustomer)==null?void 0:A.customer)==null?void 0:h.lastname)??"",email:((b=(S=t==null?void 0:t.createCustomer)==null?void 0:S.customer)==null?void 0:b.email)??"",isSubscribed:((O=(M=t==null?void 0:t.createCustomer)==null?void 0:M.customer)==null?void 0:O.is_subscribed)??!1,errors:(r==null?void 0:r.errors)??[]}}return U(o,(p=(s=(d=g.getConfig().models)==null?void 0:d.CustomerModel)==null?void 0:s.transformer)==null?void 0:p.call(s,r))},H=async(r,e)=>{await I();const o=await m(e?y:v,{method:"POST",variables:{input:{...r}}}).catch(u);return G(o,e)},V=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -52,10 +50,10 @@ import{f as a,h as s}from"./network-error.js";import{s as n}from"./setReCaptchaT } } } -`,p=async r=>await a(c,{method:"GET",cache:"force-cache",variables:{formCode:r}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?o(t.errors):u(t)}).catch(s),d=` +`,J=async r=>await m(V,{method:"GET",cache:"force-cache",variables:{formCode:r}}).then(e=>{var o;return(o=e.errors)!=null&&o.length?F(e.errors):$(e)}).catch(u),w=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { - createCustomerAddress(input:$input) { + createCustomerAddress(input: $input) { firstname - } + } } -`,f=async r=>await a(d,{method:"POST",variables:{input:r}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?o(t.errors):t.data.createCustomerAddress.firstname||""}).catch(s);export{f as a,T as c,p as g}; +`,K=async r=>await m(w,{method:"POST",variables:{input:r}}).then(e=>{var o;return(o=e.errors)!=null&&o.length?F(e.errors):e.data.createCustomerAddress.firstname||""}).catch(u);export{K as a,H as c,J as g}; diff --git a/scripts/__dropins__/storefront-auth/chunks/focusOnEmptyPasswordField.js b/scripts/__dropins__/storefront-auth/chunks/focusOnEmptyPasswordField.js new file mode 100644 index 0000000000..ac90985b60 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/chunks/focusOnEmptyPasswordField.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as c,jsx as m}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import{InLineAlert as y,Header as p}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as C}from"./resendConfirmationEmail.js";import{useState as x,useCallback as E}from"@dropins/tools/preact-hooks.js";import{useText as u}from"@dropins/tools/i18n.js";/* empty css */import{B as f}from"./Button2.js";const g=({userEmail:o,handleSetInLineAlertProps:t})=>{const a=u({emailConfirmationMessage:"Auth.Notification.emailConfirmationMessage",technicalErrorSendEmail:"Auth.Notification.technicalErrors.technicalErrorSendEmail"}),[r,e]=x(!1);return{handleEmailConfirmation:E(async()=>{var n,s;if(e(!0),o){const i=await C(o);if(i){const d=(n=i==null?void 0:i.errors)==null?void 0:n.length,h=(s=i==null?void 0:i.data)==null?void 0:s.resendConfirmationEmail;t(d?{type:"error",text:a.technicalErrorSendEmail}:{type:h?"success":"error",text:a.emailConfirmationMessage})}}e(!1)},[t,a,o]),disabledButton:r}},I=({formSize:o,userEmail:t,inLineAlertProps:a,hideCloseBtnOnEmailConfirmation:r,handleSetInLineAlertProps:e,onPrimaryButtonClick:l})=>{const n=u({title:"Auth.EmailConfirmationForm.title",subtitle:"Auth.EmailConfirmationForm.subtitle",mainText:"Auth.EmailConfirmationForm.mainText",buttonPrimary:"Auth.EmailConfirmationForm.buttonPrimary",buttonSecondary:"Auth.EmailConfirmationForm.buttonSecondary"}),{handleEmailConfirmation:s,disabledButton:i}=g({userEmail:t,handleSetInLineAlertProps:e});return c("div",{className:b(["auth-email-confirmation-form",`auth-email-confirmation-form--${o}`]),children:[a.text?m(y,{className:"auth-signInForm__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"authInLineAlert"}):null,m(p,{title:n.title,divider:!1,className:"auth-email-confirmation-form__title"}),t!=null&&t.length?m("span",{className:"auth-email-confirmation-form__subtitle",children:`${n.subtitle} ${t}`}):null,m("span",{className:"auth-email-confirmation-form__text",children:n.mainText}),c("div",{className:"auth-email-confirmation-form__buttons",children:[m(f,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonSecondary,enableLoader:!1,onClick:s,disabled:i}),r?null:m(f,{type:"submit",buttonText:n.buttonPrimary,variant:"primary",enableLoader:!1,disabled:i,onClick:l})]})]})},M=(o,t,a)=>{const r=o.target.querySelector('input[name="password"]'),e=o.target.querySelector('input[name="confirmPasswordField"]');r&&!t.length?r.focus():e&&!a.length&&e.focus()};export{I as E,M as f}; diff --git a/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js b/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js index cada7215c0..1a249bbf30 100644 --- a/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js @@ -1,15 +1,16 @@ -import{a as y,f as k,h as x}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{h as R,p as T,E as g,a as v,C as O}from"./getStoreConfig.js";import{events as D}from"@dropins/tools/event-bus.js";import{c as U}from"./initialize.js";import{s as K}from"./setReCaptchaToken.js";const F=t=>{var m,r,e,c,a,f;return{email:((r=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:r.email)||"",firstname:((c=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:c.firstname)||"",lastname:((f=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:f.lastname)||""}},H=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{a as U,f as w,h as k}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as x}from"@dropins/tools/event-bus.js";import{merge as y}from"@dropins/tools/lib.js";import{c as C}from"./initialize.js";import{CUSTOMER_INFORMATION_FRAGMENT as F}from"../fragments.js";import{p as E,E as O,a as S,C as R}from"./getStoreConfig.js";import{s as v}from"./setReCaptchaToken.js";const D=t=>{var f,e,i,a,r,o,u,T,s,g,N,c,_;const m={email:((e=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:e.email)??"",firstName:((a=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.lastname)??"",isSubscribed:((T=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:T.is_subscribed)??!1};return y(m,(_=(c=(N=(g=(s=C)==null?void 0:s.getConfig())==null?void 0:g.models)==null?void 0:N.CustomerModel)==null?void 0:c.transformer)==null?void 0:_.call(c,t.data))},K=` query GET_CUSTOMER_DATA { customer { - firstname - lastname - email + ...CUSTOMER_INFORMATION_FRAGMENT } } -`,Q=async t=>{if(t){const{authHeaderConfig:m}=U.getConfig();y(m.header,m.tokenPrefix?`${m.tokenPrefix} ${t}`:t)}return await k(H,{method:"GET",cache:"force-cache"}).then(m=>{var r;return(r=m.errors)!=null&&r.length?R(m.errors):F(m)}).catch(x)},S=` + ${F} +`,H=async t=>{if(t){const{authHeaderConfig:m}=C.getConfig();U(m.header,m.tokenPrefix?`${m.tokenPrefix} ${t}`:t)}return await w(K,{method:"GET",cache:"force-cache"}).then(m=>D(m)).catch(k)},I=` mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) { generateCustomerToken(email: $email, password: $password) { token } } -`,J=async({email:t,password:m,translations:r,onErrorCallback:e,handleSetInLineAlertProps:c})=>{var E,N,d,$,M,G,w;await K();const a=await k(S,{method:"POST",variables:{email:t,password:m}}).catch(x);if(!((N=(E=a==null?void 0:a.data)==null?void 0:E.generateCustomerToken)!=null&&N.token)){const o=r.customerTokenErrorMessage,u=a!=null&&a.errors?a.errors[0].message:o;return e==null||e(u),c==null||c({type:"error",text:u}),T((d=g)==null?void 0:d.SIGN_IN,{}),{errorMessage:u,userName:""}}const f=(M=($=a==null?void 0:a.data)==null?void 0:$.generateCustomerToken)==null?void 0:M.token,i=await Q(f);if(!(i!=null&&i.firstname)||!(i!=null&&i.email)){const o=r.customerTokenErrorMessage;return e==null||e(o),c==null||c({type:"error",text:o}),T((G=g)==null?void 0:G.SIGN_IN,{}),{errorMessage:o,userName:""}}const h=i==null?void 0:i.firstname,s=i==null?void 0:i.email,_=await v();return document.cookie=`${O.auth_dropin_firstname}=${h}; path=/; ${_}; `,document.cookie=`${O.auth_dropin_user_token}=${f}; path=/; ${_}; `,D.emit("authenticated",!!f),T((w=g)==null?void 0:w.SIGN_IN,s?{email:s}:{}),{errorMessage:"",userName:h}};export{J as a,Q as g}; +`,W=async({email:t,password:m,translations:f,onErrorCallback:e,handleSetInLineAlertProps:i})=>{var g,N,c,_,h,$,G;await v();const a=await w(I,{method:"POST",variables:{email:t,password:m}}).catch(k);if(!((N=(g=a==null?void 0:a.data)==null?void 0:g.generateCustomerToken)!=null&&N.token)){const d=f.customerTokenErrorMessage,M=a!=null&&a.errors?a.errors[0].message:d;return e==null||e(M),i==null||i({type:"error",text:M}),E((c=O)==null?void 0:c.SIGN_IN,{}),{errorMessage:M,userName:""}}const r=(h=(_=a==null?void 0:a.data)==null?void 0:_.generateCustomerToken)==null?void 0:h.token,o=await H(r),u=o==null?void 0:o.firstName,T=o==null?void 0:o.email;if(!u||!T){const d=f.customerTokenErrorMessage;return e==null||e(d),i==null||i({type:"error",text:d}),E(($=O)==null?void 0:$.SIGN_IN,{}),{errorMessage:d,userName:""}}const s=await S();return document.cookie=`${R.auth_dropin_firstname}=${u}; path=/; ${s}; `,document.cookie=`${R.auth_dropin_user_token}=${r}; path=/; ${s}; `,x.emit("authenticated",!!r),E((G=O)==null?void 0:G.SIGN_IN,{email:T}),{errorMessage:"",userName:u}};export{W as a,H as g}; diff --git a/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js index bf7f59943c..4023c8da2a 100644 --- a/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{f as l,h as E}from"./network-error.js";const T=e=>({personalEmail:{address:(e==null?void 0:e.email)||""},userAccount:{login:!0},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),S=e=>({userAccount:{logout:!0},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),N=e=>({personalEmail:{address:(e==null?void 0:e.email)||""},userAccount:{updateProfile:e==null?void 0:e.updateProfile},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),D={auth_dropin_user_token:"auth_dropin_user_token",auth_dropin_firstname:"auth_dropin_firstname"},c=3600,I=e=>{var t,o,r,a,m,_,f,g,d,C;return{autocompleteOnStorefront:((o=(t=e==null?void 0:e.data)==null?void 0:t.storeConfig)==null?void 0:o.autocomplete_on_storefront)||!1,minLength:((a=(r=e==null?void 0:e.data)==null?void 0:r.storeConfig)==null?void 0:a.minimum_password_length)||3,requiredCharacterClasses:+((_=(m=e==null?void 0:e.data)==null?void 0:m.storeConfig)==null?void 0:_.required_character_classes_number)||0,createAccountConfirmation:((g=(f=e==null?void 0:e.data)==null?void 0:f.storeConfig)==null?void 0:g.create_account_confirmation)||!1,customerAccessTokenLifetime:((C=(d=e==null?void 0:e.data)==null?void 0:d.storeConfig)==null?void 0:C.customer_access_token_lifetime)*c||c}},O=e=>{const t=e.map(o=>o.message).join(" ");throw Error(t)},U=e=>{document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`},R=async()=>{try{const e=sessionStorage.getItem("storeConfig");let o=(e?JSON.parse(e):{}).customerAccessTokenLifetime;if(!o){const r=await b();sessionStorage.setItem("storeConfig",JSON.stringify(r)),o=(r==null?void 0:r.customerAccessTokenLifetime)||c}return`Max-Age=${o}`}catch(e){return console.error("getCookiesLifetime() Error:",e),`Max-Age=${c}`}};var A=(e=>(e.CREATE_ACCOUNT_EVENT="create-account",e.SIGN_IN="sign-in",e.SIGN_OUT="sign-out",e))(A||{});const s="authContext",h="shopperContext",i={CREATE_ACCOUNT:"create-account",SIGN_IN:"sign-in",SIGN_OUT:"sign-out"};function n(e,t){const o=window.adobeDataLayer||[];o.push({[e]:null}),o.push({[e]:t})}function u(e){(window.adobeDataLayer||[]).push(o=>{const r=o.getState?o.getState():{};o.push({event:e,eventInfo:{...r}})})}function k(e){const t=N(e);n(s,t),u(i.CREATE_ACCOUNT)}function p(e){const t=T(e);n(s,t),n(h,{shopperId:"logged-in"}),u(i.SIGN_IN)}function w(e){const t=S(e);n(s,t),n(h,{shopperId:"guest"}),u(i.SIGN_OUT)}const M=(e,t)=>{const o=sessionStorage.getItem("storeConfig"),a={...o?JSON.parse(o):{},...t};switch(e){case"create-account":k(a);break;case"sign-in":p(a);break;case"sign-out":w(a);break;default:return null}},G=` query GET_STORE_CONFIG { storeConfig { diff --git a/scripts/__dropins__/storefront-auth/chunks/index.js b/scripts/__dropins__/storefront-auth/chunks/index.js index 24ff0945c9..a3a388aecd 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index.js +++ b/scripts/__dropins__/storefront-auth/chunks/index.js @@ -1 +1,3 @@ -import{R as b,R as c}from"./ResetPasswordForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"./requestPasswordResetEmail.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";/* empty css */import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";export{b as ResetPasswordForm,c as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{R as b,R as c}from"./ResetPasswordForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";/* empty css */import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./requestPasswordResetEmail.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./Button2.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";export{b as ResetPasswordForm,c as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/index2.js b/scripts/__dropins__/storefront-auth/chunks/index2.js index 00bfd0a9af..f2a9e92fd8 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index2.js +++ b/scripts/__dropins__/storefront-auth/chunks/index2.js @@ -1 +1,3 @@ -import{S as k,S as q}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./getStoreConfig.js";import"./initialize.js";import"./setReCaptchaToken.js";import"./resendConfirmationEmail.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";import"./confirmEmail.js";/* empty css */import"./EmailConfirmationForm.js";export{k as SignInForm,q as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{S as q,S as v}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./Button2.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./initialize.js";import"../fragments.js";import"./getStoreConfig.js";import"./setReCaptchaToken.js";import"./resendConfirmationEmail.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";import"./focusOnEmptyPasswordField.js";import"./confirmEmail.js";export{q as SignInForm,v as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/index3.js b/scripts/__dropins__/storefront-auth/chunks/index3.js index a952dfc42d..765ff19c9d 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index3.js +++ b/scripts/__dropins__/storefront-auth/chunks/index3.js @@ -1 +1,3 @@ -import{S as v,S as w}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./transform-attributes-form.js";import"./getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"./simplifyTransformAttributesForm.js";import"./usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"./getCustomerToken.js";import"./initialize.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"./SkeletonLoader.js";import"./EmailConfirmationForm.js";import"./resendConfirmationEmail.js";export{v as SignUpForm,w as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{S as w,S as y}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"../fragments.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./initialize.js";import"./transform-attributes-form.js";import"./getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"./simplifyTransformAttributesForm.js";import"./usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"./getCustomerToken.js";import"./Button2.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"./focusOnEmptyPasswordField.js";import"./resendConfirmationEmail.js";import"./SkeletonLoader.js";export{w as SignUpForm,y as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/initialize.js b/scripts/__dropins__/storefront-auth/chunks/initialize.js index 4694336287..48b5b4b6df 100644 --- a/scripts/__dropins__/storefront-auth/chunks/initialize.js +++ b/scripts/__dropins__/storefront-auth/chunks/initialize.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{Initializer as o}from"@dropins/tools/lib.js";const i=new o({init:async n=>{const e={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};i.config.setConfig({...e,...n})},listeners:()=>[]}),a=i.config;export{a as c,i}; diff --git a/scripts/__dropins__/storefront-auth/chunks/network-error.js b/scripts/__dropins__/storefront-auth/chunks/network-error.js index f2d0406a8c..b42c878118 100644 --- a/scripts/__dropins__/storefront-auth/chunks/network-error.js +++ b/scripts/__dropins__/storefront-auth/chunks/network-error.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{FetchGraphQL as e}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";const{setEndpoint:h,setFetchGraphQlHeader:n,removeFetchGraphQlHeader:c,setFetchGraphQlHeaders:p,fetchGraphQl:i,getConfig:f}=new e().getMethods(),m=t=>{throw t instanceof DOMException&&t.name==="AbortError"||r.emit("auth/error",{source:"auth",type:"network",error:t}),t};export{n as a,p as b,i as f,f as g,m as h,c as r,h as s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js b/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js index 0a42afb41c..bc522e0e36 100644 --- a/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as E,h as l}from"./network-error.js";import{s as e}from"./setReCaptchaToken.js";const R=a=>{var r,m,i;let t="";return(r=a==null?void 0:a.errors)!=null&&r.length&&(t=(m=a==null?void 0:a.errors[0])==null?void 0:m.message),{message:t,success:!!((i=a==null?void 0:a.data)!=null&&i.requestPasswordResetEmail)}},c=` mutation REQUEST_PASSWORD_RESET_EMAIL($email: String!) { requestPasswordResetEmail(email: $email) diff --git a/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js b/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js index 745cd5dcf0..bee8145f76 100644 --- a/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js @@ -1,4 +1,7 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as r,h as e}from"./network-error.js";const i=` -mutation RESEND_CONFIRMATION_EMAIL($email: String!) { - resendConfirmationEmail(email: $email) -}`,n=async a=>await r(i,{method:"POST",variables:{email:a}}).catch(e);export{n as r}; + mutation RESEND_CONFIRMATION_EMAIL($email: String!) { + resendConfirmationEmail(email: $email) + } +`,n=async a=>await r(i,{method:"POST",variables:{email:a}}).catch(e);export{n as r}; diff --git a/scripts/__dropins__/storefront-auth/chunks/resetPassword.js b/scripts/__dropins__/storefront-auth/chunks/resetPassword.js index 119699aa02..1584ee7812 100644 --- a/scripts/__dropins__/storefront-auth/chunks/resetPassword.js +++ b/scripts/__dropins__/storefront-auth/chunks/resetPassword.js @@ -1,5 +1,15 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as o,h as w}from"./network-error.js";import{s as d}from"./setReCaptchaToken.js";const i=` - mutation RESET_PASSWORD($email: String!, $resetPasswordToken: String!, $newPassword: String!){ - resetPassword(email: $email,resetPasswordToken: $resetPasswordToken,newPassword: $newPassword) + mutation RESET_PASSWORD( + $email: String! + $resetPasswordToken: String! + $newPassword: String! + ) { + resetPassword( + email: $email + resetPasswordToken: $resetPasswordToken + newPassword: $newPassword + ) } `,P=a=>{var r,s,e;let t="";return(r=a==null?void 0:a.errors)!=null&&r.length&&(t=(s=a==null?void 0:a.errors[0])==null?void 0:s.message),{message:t,success:!!((e=a==null?void 0:a.data)!=null&&e.resetPassword)}},S=async(a,t,r)=>(await d(),await o(i,{method:"POST",variables:{email:a,resetPasswordToken:t,newPassword:r}}).then(s=>P(s)).catch(w));export{S as r}; diff --git a/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js b/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js index e8033febf4..4b64ef7150 100644 --- a/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as u,h as n}from"./network-error.js";import{C as m,d as s,p as c,E}from"./getStoreConfig.js";import{events as i}from"@dropins/tools/event-bus.js";const k=t=>{var r,o,a;let e="";return(r=t==null?void 0:t.errors)!=null&&r.length&&(e=((o=t==null?void 0:t.errors[0])==null?void 0:o.message)||"Unknown error"),{message:e,success:!!((a=t==null?void 0:t.data)!=null&&a.revokeCustomerToken)}},h=` mutation REVOKE_CUSTOMER_TOKEN { revokeCustomerToken { diff --git a/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js b/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js index ffad115ea0..7c2f91394c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{verifyReCaptcha as t}from"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import{a as e}from"./network-error.js";const s=async()=>{const a=await t();a&&e("X-ReCaptcha",a)};export{s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js b/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js index 0854d46240..aaefa753f9 100644 --- a/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js @@ -1 +1,3 @@ -import{t}from"./transform-attributes-form.js";const s=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-sign-in-form__form__email",frontend_input:"TEXT",is_required:!0,multiline_count:1,sort_order:1,is_unique:!1,label:"Email",options:[]}],n=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-reset-password-form__form__item",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",options:[]}],_=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",multiline_count:1,sort_order:1,options:[]},{customUpperCode:"firstname",code:"firstname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"First name",multiline_count:1,sort_order:2,options:[]},{customUpperCode:"lastname",code:"lastname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!1,is_unique:!1,label:"Last name",multiline_count:1,sort_order:3,options:[]}],a=e=>e!=null&&e.length?t({data:{attributesForm:{items:e}}}):[];export{n as D,s as a,_ as b,a as s}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{t}from"./transform-attributes-form.js";const s=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-sign-in-form__form__email",frontend_input:"TEXT",is_required:!0,multiline_count:1,sort_order:1,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}]}],o=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-reset-password-form__form__item",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}]}],n=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",multiline_count:1,sort_order:1,options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}]},{customUpperCode:"firstname",code:"firstname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"First name",multiline_count:1,sort_order:2,options:[]},{customUpperCode:"lastname",code:"lastname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!1,is_unique:!1,label:"Last name",multiline_count:1,sort_order:3,options:[]}],i=e=>e!=null&&e.length?t({data:{attributesForm:{items:e}}}):[];export{o as D,s as a,n as b,i as s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js b/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js index fe968f794f..1e6a358e67 100644 --- a/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js +++ b/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ const _=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),m=(t,n,e)=>{const s=["string","boolean","number"],a=n==="camelCase"?_:p;return Array.isArray(t)?t.map(o=>s.includes(typeof o)||o===null?o:typeof o=="object"?m(o,n,e):o):t!==null&&typeof t=="object"?Object.entries(t).reduce((o,[i,c])=>{const r=e&&e[i]?e[i]:a(i);return o[r]=s.includes(typeof c)||c===null?c:m(c,n,e),o},{}):t},b=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let s=2;s<=e.multiline_count;s++){const a={...e,is_required:!1,name:`${e.code}_multiline_${s}`,code:`${e.code}_multiline_${s}`,id:`${e.code}_multiline_${s}`};n.push(a)}return n},C=t=>{var o,i,c;const n=((i=(o=t==null?void 0:t.data)==null?void 0:o.attributesForm)==null?void 0:i.items)||[];if(!n.length)return[];const e=(c=n.filter(r=>{var u;return!((u=r.frontend_input)!=null&&u.includes("HIDDEN"))}))==null?void 0:c.map(({code:r,...u})=>{const l=r!=="country_id"?r:"country_code";return{...u,name:l,id:l,code:l}}),s=b(e);return e.concat(s).map(r=>{var d;const u=r.code==="firstname"?"firstName":r.code==="lastname"?"lastName":_(r.code),l=(d=r.options)==null?void 0:d.map(f=>({isDefault:f.is_default,text:f.label,value:f.value}));return m({...r,options:l,customUpperCode:u},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((r,u)=>r.orderNumber-u.orderNumber)};export{m as c,C as t}; diff --git a/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js b/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js index 7068e90f82..ef6ef183ab 100644 --- a/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js +++ b/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as m}from"./getStoreConfig.js";import{useState as c,useEffect as u,useMemo as h}from"@dropins/tools/preact-hooks.js";import{useText as f}from"@dropins/tools/i18n.js";const A=()=>{const[e,n]=c(!1),[t,i]=c(null);return u(()=>{const a=sessionStorage.getItem("storeConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:o,requiredCharacterClasses:s,createAccountConfirmation:g}=r;i({minLength:o,requiredCharacterClasses:s}),n(g)}else m().then(o=>{if(o){const{minLength:s,requiredCharacterClasses:g,createAccountConfirmation:l}=o;sessionStorage.setItem("storeConfig",JSON.stringify(o)),i({minLength:s,requiredCharacterClasses:g}),n(l)}})},[]),{passwordConfigs:t,isEmailConfirmationRequired:e}},L=(e,n)=>{if(n<=1)return!0;const t=/[0-9]/.test(e)?1:0,i=/[a-z]/.test(e)?1:0,a=/[A-Z]/.test(e)?1:0,r=/[^a-zA-Z0-9\s]/.test(e)?1:0;return t+i+a+r>=n},M=({passwordConfigs:e,isClickSubmit:n,password:t})=>{const i=f({messageLengthPassword:"Auth.PasswordValidationMessage.messageLengthPassword"}),[a,r]=c("pending");u(()=>{if(!e)return;const s=L(t,e.requiredCharacterClasses);n&&t.length>0?r(s?"success":"error"):n&&t.length===0?r("pending"):r(s?"success":"pending")},[n,e,t]);const o=h(()=>{var g;if(!e)return;const s={status:"pending",icon:"pending",message:(g=i.messageLengthPassword)==null?void 0:g.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...s,icon:"success",status:"success"}:t.length&&t.length import("preact").JSX.Element; +export declare const Form: ({ name, loading, children, className, fieldsConfig, onSubmit, ...props }: FormProps) => import("preact").JSX.Element; //# sourceMappingURL=Form.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/components/index.d.ts b/scripts/__dropins__/storefront-auth/components/index.d.ts index 7a21d6be60..e2f27b1c16 100644 --- a/scripts/__dropins__/storefront-auth/components/index.d.ts +++ b/scripts/__dropins__/storefront-auth/components/index.d.ts @@ -1,3 +1,4 @@ +export * from './EmailConfirmationForm'; export * from './UpdatePasswordForm'; export * from './SuccessNotificationForm'; export * from './SignUpForm'; diff --git a/scripts/__dropins__/storefront-auth/configs/defaultCreateUserConfigs.d.ts b/scripts/__dropins__/storefront-auth/configs/defaultCreateUserConfigs.d.ts index 3ad955d1b1..71a9983674 100644 --- a/scripts/__dropins__/storefront-auth/configs/defaultCreateUserConfigs.d.ts +++ b/scripts/__dropins__/storefront-auth/configs/defaultCreateUserConfigs.d.ts @@ -11,9 +11,13 @@ export declare const DEFAULT__SIGN_IN_EMAIL_FIELD: { is_unique: boolean; label: string; options: never[]; + validateRules: { + name: string; + value: string; + }[]; }[]; export declare const DEFAULT__RESET_PASSWORD_EMAIL_FIELD: Record[]; -export declare const DEFAULT_SIGN_UP_FIELDS: { +export declare const DEFAULT_SIGN_UP_FIELDS: ({ customUpperCode: string; code: string; default_value: string; @@ -26,6 +30,24 @@ export declare const DEFAULT_SIGN_UP_FIELDS: { multiline_count: number; sort_order: number; options: never[]; -}[]; + validateRules: { + name: string; + value: string; + }[]; +} | { + customUpperCode: string; + code: string; + default_value: string; + entity_type: string; + frontend_class: string; + frontend_input: string; + is_required: boolean; + is_unique: boolean; + label: string; + multiline_count: number; + sort_order: number; + options: never[]; + validateRules?: undefined; +})[]; export declare const DEFAULT_INPUTS_PROPS: Record; //# sourceMappingURL=defaultCreateUserConfigs.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/containers/AuthCombine.js b/scripts/__dropins__/storefront-auth/containers/AuthCombine.js index 7a2fa79c69..14123d4b51 100644 --- a/scripts/__dropins__/storefront-auth/containers/AuthCombine.js +++ b/scripts/__dropins__/storefront-auth/containers/AuthCombine.js @@ -1 +1,3 @@ -import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{lazy as u,Suspense as v}from"@dropins/tools/preact-compat.js";import{useState as E,useMemo as S}from"@dropins/tools/preact-hooks.js";import{S as y}from"../chunks/SkeletonLoader.js";import"@dropins/tools/components.js";const L=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),P=function(c){return"/"+c},p={},d=function(t,i,a){let l=Promise.resolve();if(i&&i.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),r=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));l=Promise.all(i.map(o=>{if(o=P(o),o in p)return;p[o]=!0;const m=o.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const n=document.createElement("link");if(n.rel=m?"stylesheet":L,m||(n.as="script",n.crossOrigin=""),n.href=o,r&&n.setAttribute("nonce",r),document.head.appendChild(n),m)return new Promise((h,_)=>{n.addEventListener("load",h),n.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}return l.then(()=>t()).catch(e=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=e,window.dispatchEvent(r),!r.defaultPrevented)throw e})},k=u(()=>d(()=>import("../chunks/index.js"),[])),b=u(()=>d(()=>import("../chunks/index2.js"),[])),w=u(()=>d(()=>import("../chunks/index3.js"),[])),F=({defaultView:c="signInForm",signInFormConfig:t,signUpFormConfig:i,resetPasswordFormConfig:a})=>{const[l,e]=E(c),r=S(()=>({signInForm:s(b,{setActiveComponent:e,...t}),signUpForm:s(w,{setActiveComponent:e,...i}),resetPasswordForm:s(k,{setActiveComponent:e,...a})}),[a,t,i,e]);return s("div",{children:s(v,{fallback:s(y,{activeSkeleton:l}),children:s("div",{className:"auth-combine",children:r[l]})})})};export{F as AuthCombine,F as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import{lazy as d,Suspense as E}from"@dropins/tools/preact-compat.js";import{useState as S,useMemo as P}from"@dropins/tools/preact-hooks.js";import{S as y}from"../chunks/SkeletonLoader.js";import"@dropins/tools/components.js";const L=function(){const r=typeof document<"u"&&document.createElement("link").relList;return r&&r.supports&&r.supports("modulepreload")?"modulepreload":"preload"}(),k=function(l){return"/"+l},f={},p=function(r,c,u){let a=Promise.resolve();if(c&&c.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),t=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));a=Promise.allSettled(c.map(o=>{if(o=k(o),o in f)return;f[o]=!0;const m=o.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${h}`))return;const n=document.createElement("link");if(n.rel=m?"stylesheet":L,m||(n.as="script"),n.crossOrigin="",n.href=o,t&&n.setAttribute("nonce",t),document.head.appendChild(n),m)return new Promise((_,v)=>{n.addEventListener("load",_),n.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${o}`)))})}))}function s(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return a.then(e=>{for(const t of e||[])t.status==="rejected"&&s(t.reason);return r().catch(s)})},b=d(()=>p(()=>import("../chunks/index.js"),[])),w=d(()=>p(()=>import("../chunks/index2.js"),[])),A=d(()=>p(()=>import("../chunks/index3.js"),[])),O=({defaultView:l="signInForm",signInFormConfig:r,signUpFormConfig:c,resetPasswordFormConfig:u})=>{const[a,s]=S(l),e=P(()=>({signInForm:i(w,{setActiveComponent:s,...r}),signUpForm:i(A,{setActiveComponent:s,...c}),resetPasswordForm:i(b,{setActiveComponent:s,...u})}),[u,r,c,s]);return i("div",{children:i(E,{fallback:i(y,{activeSkeleton:a}),children:i("div",{className:"auth-combine",children:e[a]})})})};export{O as AuthCombine,O as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/ResetPassword.js b/scripts/__dropins__/storefront-auth/containers/ResetPassword.js index 702f474f33..db511ae674 100644 --- a/scripts/__dropins__/storefront-auth/containers/ResetPassword.js +++ b/scripts/__dropins__/storefront-auth/containers/ResetPassword.js @@ -1 +1,3 @@ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{R as i}from"../chunks/ResetPasswordForm.js";import"@dropins/tools/lib.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/requestPasswordResetEmail.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";/* empty css */import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";const F=({formSize:o,routeSignIn:t,onErrorCallback:m})=>r("div",{className:"auth-reset-password",children:r(i,{formSize:o,routeSignIn:t,onErrorCallback:m})});export{F as ResetPassword,F as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";/* empty css */import{R as i}from"../chunks/ResetPasswordForm.js";import"../chunks/requestPasswordResetEmail.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/Button2.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/i18n.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";const F=({formSize:o,routeSignIn:t,onErrorCallback:m})=>r("div",{className:"auth-reset-password",children:r(i,{formSize:o,routeSignIn:t,onErrorCallback:m})});export{F as ResetPassword,F as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/SignIn.js b/scripts/__dropins__/storefront-auth/containers/SignIn.js index 154ff81df8..439560d0ec 100644 --- a/scripts/__dropins__/storefront-auth/containers/SignIn.js +++ b/scripts/__dropins__/storefront-auth/containers/SignIn.js @@ -1 +1,3 @@ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as u}from"../chunks/SignInForm.js";import"@dropins/tools/lib.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";import"../chunks/initialize.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/confirmEmail.js";/* empty css */import"../chunks/EmailConfirmationForm.js";const K=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l})=>r("div",{className:"auth-sign-in",children:r(u,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e})});export{K as SignIn,K as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";/* empty css */import{S as u}from"../chunks/SignInForm.js";import"../chunks/Button2.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/i18n.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../fragments.js";import"../chunks/getStoreConfig.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/confirmEmail.js";const L=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l})=>r("div",{className:"auth-sign-in",children:r(u,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e})});export{L as SignIn,L as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/SignUp.js b/scripts/__dropins__/storefront-auth/containers/SignUp.js index 2e8cc6b5ff..37ee48fd3f 100644 --- a/scripts/__dropins__/storefront-auth/containers/SignUp.js +++ b/scripts/__dropins__/storefront-auth/containers/SignUp.js @@ -1 +1,3 @@ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as h}from"../chunks/SignUpForm.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"../chunks/createCustomerAddress.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"../chunks/getCustomerToken.js";import"../chunks/initialize.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/SkeletonLoader.js";import"../chunks/EmailConfirmationForm.js";import"../chunks/resendConfirmationEmail.js";const O=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,fieldsConfigForApiVersion1:u,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,onSuccessCallback:g,onErrorCallback:l,routeSignIn:S})=>r("div",{className:"auth-sign-up",children:r(h,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:u,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,routeSignIn:S,slots:i,onErrorCallback:l,onSuccessCallback:g})});export{O as SignUp,O as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";/* empty css */import{S as h}from"../chunks/SignUpForm.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/initialize.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"../chunks/getCustomerToken.js";import"../chunks/Button2.js";import"@dropins/tools/preact-compat.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/SkeletonLoader.js";const P=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,fieldsConfigForApiVersion1:u,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,onSuccessCallback:g,onErrorCallback:l,routeSignIn:S})=>r("div",{className:"auth-sign-up",children:r(h,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:u,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,routeSignIn:S,slots:i,onErrorCallback:l,onSuccessCallback:g})});export{P as SignUp,P as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js b/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js index 8fd6c7cff4..7d09fd07ac 100644 --- a/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js +++ b/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js @@ -1 +1,3 @@ -import{jsxs as a,jsx as o,Fragment as r}from"@dropins/tools/preact-jsx-runtime.js";import{classes as u,Slot as m}from"@dropins/tools/lib.js";/* empty css */import{Button as s}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as f}from"../chunks/revokeCustomerToken.js";import{useText as d}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";const h=({formSize:n="default",className:e="",slots:t,labels:i})=>{const c=d({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return a("div",{className:u(["auth-success-notification-form",`auth-success-notification-form--${n}`,e]),children:[o("p",{className:"auth-success-notification-form__title","data-testid":"notification-title",children:(i==null?void 0:i.headingText)||c.headingText}),o("p",{className:"auth-success-notification-form__content-text","data-testid":"notification-content",children:(i==null?void 0:i.messageText)||c.messageText}),t!=null&&t.SuccessNotificationActions?o(m,{"data-testid":"successNotificationActions",name:"SuccessNotificationActions",slot:t==null?void 0:t.SuccessNotificationActions,context:{}}):a(r,{children:[o(s,{"data-testid":"primaryButton",type:"button",className:"auth-success-notification-form__button auth-success-notification-form__button--top",onClick:()=>window.location.href="/",children:c.primaryButtonText}),o(s,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await f(),window.location.href="/"},children:c.secondaryButtonText})]})]})},k=({formSize:n="default",slots:e,className:t,labels:i})=>o("div",{className:"auth-success-notification",children:o(h,{formSize:n,className:t,slots:e,labels:i})});export{k as SuccessNotification,k as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as a,jsx as e,Fragment as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as u,Slot as m}from"@dropins/tools/lib.js";import{Button as r}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";/* empty css */import{r as d}from"../chunks/revokeCustomerToken.js";import{useText as f}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";const h=({formSize:c="default",className:n="",slots:i,labels:t})=>{const o=f({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return a("div",{className:u(["auth-success-notification-form",`auth-success-notification-form--${c}`,n]),id:"welcome-message",role:"alert","aria-live":"assertive","aria-labelledby":(t==null?void 0:t.headingText)??o.headingText,"aria-describedby":(t==null?void 0:t.messageText)??o.messageText,"tab-index":"-1",children:[e("p",{id:"welcome-heading",className:"auth-success-notification-form__title","data-testid":"notification-title",children:(t==null?void 0:t.headingText)??o.headingText}),e("p",{id:"welcome-details",className:"auth-success-notification-form__content-text","data-testid":"notification-content",children:(t==null?void 0:t.messageText)??o.messageText}),i!=null&&i.SuccessNotificationActions?e(m,{"data-testid":"successNotificationActions",name:"SuccessNotificationActions",slot:i==null?void 0:i.SuccessNotificationActions,context:{}}):a(s,{children:[e(r,{"data-testid":"primaryButton",type:"button",className:"auth-success-notification-form__button auth-success-notification-form__button--top",onClick:()=>window.location.href="/",children:o.primaryButtonText}),e(r,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await d(),window.location.href="/"},children:o.secondaryButtonText})]})]})},k=({formSize:c="default",slots:n,className:i,labels:t})=>e("div",{className:"auth-success-notification",children:e(h,{formSize:c,className:i,slots:n,labels:t})});export{k as SuccessNotification,k as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js b/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js index 4d9cd26da6..812f95a9bf 100644 --- a/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js +++ b/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js @@ -1 +1,3 @@ -import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as $}from"@dropins/tools/lib.js";import{v as k,u as S,a as W}from"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as O}from"../chunks/getCustomerToken.js";import{r as g}from"../chunks/resetPassword.js";import{c as j,g as R,u as C,F as tt,B as et}from"../chunks/UpdatePasswordForm.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";import{useText as K}from"@dropins/tools/i18n.js";import{Header as at,InLineAlert as st,InputPassword as rt}from"@dropins/tools/components.js";/* empty css */import"../chunks/getStoreConfig.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../chunks/setReCaptchaToken.js";import"@dropins/tools/preact-compat.js";const J=(d,p)=>d.split("&").filter(r=>r.includes(p)).map(r=>r.split("=")[1])[0],it=({isEmailConfirmationRequired:d,signInOnSuccess:p,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:w,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:m,routeRedirectOnPasswordUpdate:N,routeSignInPage:o})=>{const s=K({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,n]=h({userName:"",status:!1}),[x,F]=h(""),[v,A]=h(!1),[P,L]=h(""),[y,M]=h(""),[T,c]=h(!1),[_,q]=h(!1),[b,B]=h([]);z(()=>{v&&!b.length&&(x.length?q(!1):q(!0))},[v,x,b]),z(()=>{const{search:f}=window.location;!f.includes("token=")&&!f.includes("email=")&&j(w)&&(window.location.href=w());const e=decodeURIComponent(f),V=J(e,"token"),E=J(e,"email");L(E),M(V)},[w]);const Q=I(async f=>{f.preventDefault(),c(!0),B([]);const e=R(f.target),V=(e==null?void 0:e.password)&&P&&y;e!=null&&e.password||(q(!0),c(!1));const E=(t==null?void 0:t.requiredCharacterClasses)??0,Y=(t==null?void 0:t.minLength)??0;if(!k(e==null?void 0:e.password,E)||e.password.length<+Y){A(!0),c(!1);return}if(!V){m({type:"error",text:s.errorNotification}),c(!1);return}const{message:D,success:G}=await g(P,y,e.password);if(G){if(d||!d&&!p){i==null||i(),j(N)&&(window.location.href=N()),A(!0),c(!1),q(!1),F(""),B([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=o==null?void 0:o()}}]),m({type:"success",text:s.updatePasswordMessage});return}const l=await O({email:P,password:e.password,handleSetInLineAlertProps:m,onErrorCallback:a,translations:s});l!=null&&l.userName&&(i==null||i(l==null?void 0:l.userName),j(r)?window.location.href=r():n({userName:l==null?void 0:l.userName,status:!0}))}else m({type:"error",text:D}),a==null||a({message:D,success:G});c(!1)},[P,y,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,d,p,o,a,i,r,m,N]),X=I(f=>{F(f)},[]);return{additionalActionsAlert:b,passwordError:_,isSuccessful:U,updatePasswordValue:x,isClickSubmit:v,isLoading:T,submitUpdatePassword:Q,handleSetUpdatePasswordValue:X,setIsClickSubmit:A}},ot=({signInOnSuccess:d=!0,formSize:p="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:w,slots:a,onErrorCallback:i,onSuccessCallback:m,routeRedirectOnPasswordUpdate:N})=>{const o=K({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=S(),{inLineAlertProps:n,handleSetInLineAlertProps:x}=C(),{additionalActionsAlert:F,passwordError:v,isSuccessful:A,updatePasswordValue:P,isClickSubmit:L,isLoading:y,submitUpdatePassword:M,handleSetUpdatePasswordValue:T}=it({isEmailConfirmationRequired:U,signInOnSuccess:d,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:m,handleSetInLineAlertProps:x,routeRedirectOnPasswordUpdate:N,routeSignInPage:w}),{isValidUniqueSymbols:c,defaultLengthMessage:_}=W({password:P,isClickSubmit:L,passwordConfigs:s});return A.status&&(a!=null&&a.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:A}}):H("div",{className:$(["auth-update-password-form",`auth-update-password-form--${p}`]),children:[u(at,{title:o.title,divider:!1,className:"auth-update-password-form__title"}),u(st,{className:$(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(n!=null&&n.text)]]),variant:"secondary",heading:n==null?void 0:n.text,icon:n.icon,additionalActions:F}),H(tt,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:M,loading:y,fieldsConfig:[],children:[u("div",{style:"display: none;",children:u("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),u(rt,{defaultValue:P,onValue:T,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:v||c==="error"||(_==null?void 0:_.status)==="error"?o.requiredFieldError:void 0,minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:c,validateLengthConfig:_,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:o.placeholder,floatingLabel:o.floatingLabel}),u("div",{className:"auth-update-password-form__button",children:u(et,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:y})})]})]})},qt=({slots:d,formSize:p,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:w,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N})=>u("div",{className:"auth-update-password",children:u(ot,{formSize:p,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:w,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N,slots:d,routeRedirectOnPasswordUpdate:r})});export{qt as UpdatePassword,qt as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as $}from"@dropins/tools/lib.js";import{Header as k,InLineAlert as S,InputPassword as W}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";/* empty css */import{v as O,u as g,a as R}from"../chunks/usePasswordValidationMessage.js";import{a as C}from"../chunks/getCustomerToken.js";import{r as tt}from"../chunks/resetPassword.js";import{c as j,g as et,u as at,F as st,B as rt}from"../chunks/Button2.js";import{useText as K}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../fragments.js";import"../chunks/setReCaptchaToken.js";import"@dropins/tools/preact-compat.js";const J=(d,p)=>d.split("&").filter(r=>r.includes(p)).map(r=>r.split("=")[1])[0],it=({isEmailConfirmationRequired:d,signInOnSuccess:p,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:w,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:m,routeRedirectOnPasswordUpdate:N,routeSignInPage:o})=>{const s=K({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,n]=h({userName:"",status:!1}),[x,F]=h(""),[v,A]=h(!1),[P,L]=h(""),[y,M]=h(""),[T,c]=h(!1),[_,q]=h(!1),[b,B]=h([]);z(()=>{v&&!b.length&&(x.length?q(!1):q(!0))},[v,x,b]),z(()=>{const{search:f}=window.location;!f.includes("token=")&&!f.includes("email=")&&j(w)&&(window.location.href=w());const e=decodeURIComponent(f),V=J(e,"token"),E=J(e,"email");L(E),M(V)},[w]);const Q=I(async f=>{f.preventDefault(),c(!0),B([]);const e=et(f.target),V=(e==null?void 0:e.password)&&P&&y;e!=null&&e.password||(q(!0),c(!1));const E=(t==null?void 0:t.requiredCharacterClasses)??0,Y=(t==null?void 0:t.minLength)??0;if(!O(e==null?void 0:e.password,E)||e.password.length<+Y){A(!0),c(!1);return}if(!V){m({type:"error",text:s.errorNotification}),c(!1);return}const{message:D,success:G}=await tt(P,y,e.password);if(G){if(d||!d&&!p){i==null||i(),j(N)&&(window.location.href=N()),A(!0),c(!1),q(!1),F(""),B([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=o==null?void 0:o()}}]),m({type:"success",text:s.updatePasswordMessage});return}const l=await C({email:P,password:e.password,handleSetInLineAlertProps:m,onErrorCallback:a,translations:s});l!=null&&l.userName&&(i==null||i(l==null?void 0:l.userName),j(r)?window.location.href=r():n({userName:l==null?void 0:l.userName,status:!0}))}else m({type:"error",text:D}),a==null||a({message:D,success:G});c(!1)},[P,y,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,d,p,o,a,i,r,m,N]),X=I(f=>{F(f)},[]);return{additionalActionsAlert:b,passwordError:_,isSuccessful:U,updatePasswordValue:x,isClickSubmit:v,isLoading:T,submitUpdatePassword:Q,handleSetUpdatePasswordValue:X,setIsClickSubmit:A}},ot=({signInOnSuccess:d=!0,formSize:p="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:w,slots:a,onErrorCallback:i,onSuccessCallback:m,routeRedirectOnPasswordUpdate:N})=>{const o=K({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=g(),{inLineAlertProps:n,handleSetInLineAlertProps:x}=at(),{additionalActionsAlert:F,passwordError:v,isSuccessful:A,updatePasswordValue:P,isClickSubmit:L,isLoading:y,submitUpdatePassword:M,handleSetUpdatePasswordValue:T}=it({isEmailConfirmationRequired:U,signInOnSuccess:d,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:m,handleSetInLineAlertProps:x,routeRedirectOnPasswordUpdate:N,routeSignInPage:w}),{isValidUniqueSymbols:c,defaultLengthMessage:_}=R({password:P,isClickSubmit:L,passwordConfigs:s});return A.status&&(a!=null&&a.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:A}}):H("div",{className:$(["auth-update-password-form",`auth-update-password-form--${p}`]),children:[u(k,{title:o.title,divider:!1,className:"auth-update-password-form__title"}),u(S,{className:$(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(n!=null&&n.text)]]),variant:"secondary",heading:n==null?void 0:n.text,icon:n.icon,additionalActions:F}),H(st,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:M,loading:y,fieldsConfig:[],children:[u("div",{style:"display: none;",children:u("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),u(W,{defaultValue:P,onValue:T,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:v||c==="error"||(_==null?void 0:_.status)==="error"?o.requiredFieldError:void 0,minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:c,validateLengthConfig:_,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:o.placeholder,floatingLabel:o.floatingLabel}),u("div",{className:"auth-update-password-form__button",children:u(rt,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:y})})]})]})},Ut=({slots:d,formSize:p,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:w,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N})=>u("div",{className:"auth-update-password",children:u(ot,{formSize:p,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:w,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N,slots:d,routeRedirectOnPasswordUpdate:r})});export{Ut as UpdatePassword,Ut as default}; diff --git a/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts b/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts index c72d4d5aa2..6afa4e7dca 100644 --- a/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts +++ b/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts @@ -1,6 +1,11 @@ -export interface CustomerDataModel { - firstname: string; - lastname: string; +export interface CustomerModel { + firstName: string; + lastName: string; email: string; + isSubscribed: boolean; + customAttributes?: Record[]; + errors?: { + message: string; + }[]; } //# sourceMappingURL=customer-data.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts index 1db615bd3e..9c77cdfb90 100644 --- a/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts +++ b/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts @@ -4,4 +4,5 @@ export * from './transform-password-reset-email'; export * from './transform-revoke-customer-token'; export * from './transform-customer-data'; export * from './transform-attributes-form'; +export * from './transform-create-customer'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts new file mode 100644 index 0000000000..88ef279d24 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts @@ -0,0 +1,7 @@ +import { DataCreateCustomerV2, DataCreateCustomer } from '../../types'; +import { CustomerModel } from '../models'; + +type ApiResponse = T extends true ? DataCreateCustomerV2 : DataCreateCustomer; +export declare const transformCreateCustomer: (response: ApiResponse, apiVersion2: T) => CustomerModel; +export {}; +//# sourceMappingURL=transform-create-customer.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts index 5d30914b4a..5233ce10bf 100644 --- a/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts +++ b/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts @@ -1,5 +1,5 @@ import { getCustomerDataResponse } from '../../types'; -import { CustomerDataModel } from '../models'; +import { CustomerModel } from '../models'; -export declare const transformCustomerData: (response: getCustomerDataResponse) => CustomerDataModel; +export declare const transformCustomerData: (response: getCustomerDataResponse) => CustomerModel; //# sourceMappingURL=transform-customer-data.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/fragments.d.ts b/scripts/__dropins__/storefront-auth/fragments.d.ts new file mode 100644 index 0000000000..4d0b3af3f9 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/fragments.d.ts @@ -0,0 +1 @@ +export * from './api/fragments' diff --git a/scripts/__dropins__/storefront-auth/fragments.js b/scripts/__dropins__/storefront-auth/fragments.js new file mode 100644 index 0000000000..4bcbe599f7 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/fragments.js @@ -0,0 +1,11 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const e=` + fragment CUSTOMER_INFORMATION_FRAGMENT on Customer { + __typename + firstname + lastname + email + is_subscribed + } +`;export{e as CUSTOMER_INFORMATION_FRAGMENT}; diff --git a/scripts/__dropins__/storefront-auth/hooks/components/useSignInForm.d.ts b/scripts/__dropins__/storefront-auth/hooks/components/useSignInForm.d.ts index 77277072fa..fb18b8513d 100644 --- a/scripts/__dropins__/storefront-auth/hooks/components/useSignInForm.d.ts +++ b/scripts/__dropins__/storefront-auth/hooks/components/useSignInForm.d.ts @@ -14,10 +14,11 @@ export declare const useSignInForm: ({ emailConfirmationStatusMessage, translati showEmailConfirmationForm: boolean; setShowEmailConfirmationForm: import('preact/hooks').Dispatch>; setSignInPasswordValue: import('preact/hooks').Dispatch>; - submitLogInUser: (event: any) => Promise; + submitLogInUser: (event: SubmitEvent, isValid: boolean) => Promise; forgotPasswordCallback: () => void; onSignUpLinkClickCallback: () => void; handledOnPrimaryButtonClick: () => void; handleSetPassword: (value: string) => void; + onBlurPassword: () => void; }; //# sourceMappingURL=useSignInForm.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts b/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts index 28a34ae2cd..afc0e6d5ef 100644 --- a/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts +++ b/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts @@ -1,6 +1,7 @@ import { UseSingUpFormProps } from '../../types'; export declare const useSignUpForm: ({ requireRetypePassword, addressesData, translations, isEmailConfirmationRequired, apiVersion2, passwordConfigs, isAutoSignInEnabled, routeRedirectOnSignIn, routeSignIn, onErrorCallback, onSuccessCallback, setActiveComponent, handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose, }: UseSingUpFormProps) => { + showPasswordErrorMessage: boolean; confirmPassword: string; confirmPasswordMessage: string; isKeepMeLogged: boolean; @@ -19,5 +20,7 @@ export declare const useSignUpForm: ({ requireRetypePassword, addressesData, tra onKeepMeLoggedChange: ({ target }: any) => void; handleHideEmailConfirmationForm: () => void; handleConfirmPasswordChange: (value: string) => void; + onBlurPassword: (event: Event) => void; + onBlurConfirmPassword: (event: Event) => void; }; //# sourceMappingURL=useSignUpForm.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts index bc5282b2e9..466616129a 100644 --- a/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts @@ -9,7 +9,8 @@ declare const _default: { "ResetPasswordForm": { "title": "Reset your password", "buttonPrimary": "Reset password", - "buttonSecondary": "Back to sign in" + "buttonSecondary": "Back to sign in", + "formAriaLabel": "Reset your password form" }, "SignInForm": { "title": "Sign in", diff --git a/scripts/__dropins__/storefront-auth/lib/focusOnEmptyPasswordField.d.ts b/scripts/__dropins__/storefront-auth/lib/focusOnEmptyPasswordField.d.ts new file mode 100644 index 0000000000..bd748730ac --- /dev/null +++ b/scripts/__dropins__/storefront-auth/lib/focusOnEmptyPasswordField.d.ts @@ -0,0 +1,2 @@ +export declare const focusOnEmptyPasswordField: (event: Event, signUpPasswordValue: string, confirmPassword: string) => void; +//# sourceMappingURL=focusOnEmptyPasswordField.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/render.js b/scripts/__dropins__/storefront-auth/render.js index 36f3496487..4b973ea874 100644 --- a/scripts/__dropins__/storefront-auth/render.js +++ b/scripts/__dropins__/storefront-auth/render.js @@ -1,4 +1,4 @@ -(function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(`.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)} -.auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}} -.auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__checkbox{margin-bottom:12px}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}`,{styleId:"Auth"}); -import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as f}from"@dropins/tools/preact-hooks.js";import{UIProvider as h}from"@dropins/tools/components.js";import{events as p}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as g}from"./chunks/initialize.js";const w={PasswordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long"},ResetPasswordForm:{title:"Reset your password",buttonPrimary:"Reset password",buttonSecondary:"Back to sign in"},SignInForm:{title:"Sign in",buttonPrimary:"Sign in",buttonSecondary:"Sign up",buttonTertiary:"Forgot password?"},SignUpForm:{title:"Sign up",buttonPrimary:"Create account",buttonSecondary:"Already a member? Sign in",privacyPolicyDefaultText:"I’ve read and accept the Terms of Use and Privacy Policy.",subscribedDefaultText:"Subscribe to our newsletter and be the first to know about new arrivals, sales and exclusive offers.",keepMeLoggedText:"Keep me logged in after account creation",failedCreateCustomerAddress:"Failed to create customer addresses:",confirmPassword:{placeholder:"Confirm password",floatingLabel:"Confirm password *",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical."}},UpdatePasswordForm:{title:"Update password",buttonPrimary:"Update password"},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",dateMaxError:"Date must be less than or equal to {max}.",dateMinError:"Date must be greater than or equal to {min}.",urlError:"Please enter a valid URL, e.g., https://www.website.com.",lengthTextError:"Text length must be between {min} and {max} characters."},EmailConfirmationForm:{title:"Verify your email address",subtitle:"We`ve sent an email to",mainText:"Check your inbox and click on the link we just send you to confirm your email address and activate your account.",buttonSecondary:"Resend email",buttonPrimary:"Close",accountConfirmMessage:"Account confirmed",accountConfirmationEmailSuccessMessage:"Congratulations! Your account at {email} email has been successfully confirmed."},Notification:{errorNotification:"Your password update failed due to validation errors. Please check your information and try again.",updatePasswordMessage:"The password has been updated.",updatePasswordActionMessage:"Sign in",successPasswordResetEmailNotification:"If there is an account associated with {email} you will receive an email with a link to reset your password.",resendEmailNotification:{informationText:"This account is not confirmed.",buttonText:"Resend confirmation email"},emailConfirmationMessage:"Please check your email for confirmation link.",technicalErrors:{technicalErrorSendEmail:"A technical error occurred while trying to send the email. Please try again later."}},SuccessNotification:{headingText:"Welcome!",messageText:"We are glad to see you!",primaryButtonText:"Continue shopping",secondaryButtonText:"Logout"},Api:{customerTokenErrorMessage:"Unable to log in. Please try again later or contact support if the issue persists."},InputPassword:{placeholder:"Password",floatingLabel:"Password *"}},b={Auth:w},y={default:b},P=({children:n})=>{var r,t;const[e,i]=u("en_US"),c=(t=(r=g)==null?void 0:r.getConfig())==null?void 0:t.langDefinitions;f(()=>{const a=p.on("locale",o=>{o!==e&&i(o)},{eager:!0});return()=>{a==null||a.off()}},[e]);const l=d(y,c??{});return s(h,{lang:e,langDefinitions:l,children:n})},k=new m(s(P,{}));export{k as render}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +(function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})('.auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)}.auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__checkbox{margin-bottom:12px}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}',{styleId:"Auth"}); +import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as f}from"@dropins/tools/preact-hooks.js";import{UIProvider as h}from"@dropins/tools/components.js";import{events as p}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as g}from"./chunks/initialize.js";const w={PasswordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long"},ResetPasswordForm:{title:"Reset your password",buttonPrimary:"Reset password",buttonSecondary:"Back to sign in",formAriaLabel:"Reset your password form"},SignInForm:{title:"Sign in",buttonPrimary:"Sign in",buttonSecondary:"Sign up",buttonTertiary:"Forgot password?"},SignUpForm:{title:"Sign up",buttonPrimary:"Create account",buttonSecondary:"Already a member? Sign in",privacyPolicyDefaultText:"I’ve read and accept the Terms of Use and Privacy Policy.",subscribedDefaultText:"Subscribe to our newsletter and be the first to know about new arrivals, sales and exclusive offers.",keepMeLoggedText:"Keep me logged in after account creation",failedCreateCustomerAddress:"Failed to create customer addresses:",confirmPassword:{placeholder:"Confirm password",floatingLabel:"Confirm password *",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical."}},UpdatePasswordForm:{title:"Update password",buttonPrimary:"Update password"},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",dateMaxError:"Date must be less than or equal to {max}.",dateMinError:"Date must be greater than or equal to {min}.",urlError:"Please enter a valid URL, e.g., https://www.website.com.",lengthTextError:"Text length must be between {min} and {max} characters."},EmailConfirmationForm:{title:"Verify your email address",subtitle:"We`ve sent an email to",mainText:"Check your inbox and click on the link we just send you to confirm your email address and activate your account.",buttonSecondary:"Resend email",buttonPrimary:"Close",accountConfirmMessage:"Account confirmed",accountConfirmationEmailSuccessMessage:"Congratulations! Your account at {email} email has been successfully confirmed."},Notification:{errorNotification:"Your password update failed due to validation errors. Please check your information and try again.",updatePasswordMessage:"The password has been updated.",updatePasswordActionMessage:"Sign in",successPasswordResetEmailNotification:"If there is an account associated with {email} you will receive an email with a link to reset your password.",resendEmailNotification:{informationText:"This account is not confirmed.",buttonText:"Resend confirmation email"},emailConfirmationMessage:"Please check your email for confirmation link.",technicalErrors:{technicalErrorSendEmail:"A technical error occurred while trying to send the email. Please try again later."}},SuccessNotification:{headingText:"Welcome!",messageText:"We are glad to see you!",primaryButtonText:"Continue shopping",secondaryButtonText:"Logout"},Api:{customerTokenErrorMessage:"Unable to log in. Please try again later or contact support if the issue persists."},InputPassword:{placeholder:"Password",floatingLabel:"Password *"}},b={Auth:w},y={default:b},P=({children:n})=>{var r,t;const[e,i]=u("en_US"),c=(t=(r=g)==null?void 0:r.getConfig())==null?void 0:t.langDefinitions;f(()=>{const a=p.on("locale",o=>{o!==e&&i(o)},{eager:!0});return()=>{a==null||a.off()}},[e]);const l=d(y,c??{});return s(h,{lang:e,langDefinitions:l,children:n})},k=new m(s(P,{}));export{k as render}; diff --git a/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts b/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts index a202edda15..975c4122b3 100644 --- a/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts +++ b/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts @@ -1,24 +1,29 @@ +type customAttributesProps = { + custom_attributes: Record[]; +}; +type errorProps = { + message: string; +}; export interface Customer { firstname: string; lastname: string; email: string; is_subscribed: boolean; - custom_attributes?: Record[]; } interface CreateCustomerResponse { customer: Customer; } -interface DataCreateCustomerV2 { - createCustomer: CreateCustomerResponse; +export interface DataCreateCustomerV2 { + data: { + createCustomerV2: CreateCustomerResponse & customAttributesProps; + }; + errors?: errorProps[]; } -interface DataCreateCustomer { - createCustomer: CreateCustomerResponse; -} -export interface CreateCustomerDataResponse { - data: DataCreateCustomerV2 | DataCreateCustomer | null; - errors?: { - message: string; - }[]; +export interface DataCreateCustomer { + data: { + createCustomer: CreateCustomerResponse; + }; + errors?: errorProps[]; } export {}; //# sourceMappingURL=createCustomer.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts b/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts index 6dc5f63de2..25122c40b1 100644 --- a/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts +++ b/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts @@ -4,6 +4,7 @@ export interface getCustomerDataResponse { firstname: string; lastname: string; email: string; + is_subscribed: boolean; }; }; errors?: { diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 2a5966305a..4ecab87f4c 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,44 +1,22 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{Initializer as I}from"@dropins/tools/lib.js";import{events as o}from"@dropins/tools/event-bus.js";import{f as n,h as m}from"./chunks/fetch-graphql.js";import{g as q,r as U,s as Y,a as Q,b as H}from"./chunks/fetch-graphql.js";import{h as l}from"./chunks/network-error.js";import{P as u,a as _,G as p,O as c,B as D,R as O,c as b}from"./chunks/transform-order-details.js";import{O as R,A as h}from"./chunks/getGuestOrder.graphql.js";import{t as G}from"./chunks/getCustomer.js";import{g as j,a as J}from"./chunks/getCustomer.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as Z}from"./chunks/getStoreConfig.js";import{g as re}from"./chunks/getCustomerOrdersReturn.js";import{g as ae,r as se}from"./chunks/requestReturn.js";import{c as oe,r as ie}from"./chunks/requestGuestOrderCancel.js";import{r as me}from"./chunks/reorderItems.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";import"./chunks/transform-attributes-form.js";const T=` -query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { - customer { - orders( - filter: { number: { eq: $orderNumber } } - ) { - items { +import{c as H,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as _,h as T}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as tt,r as et}from"./chunks/requestReturn.js";import{g as at,a as ot}from"./chunks/getGuestOrder.js";import{g as st}from"./chunks/getCustomerOrdersReturn.js";import{c as m,P as R,a as A,G as D,O as g,B as O,b as h,A as C}from"./chunks/initialize.js";import{e as pt,g as ct,d as ut,i as dt}from"./chunks/initialize.js";import{g as Et}from"./chunks/getStoreConfig.js";import{h as f}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{r as Tt}from"./chunks/reorderItems.js";import"./chunks/GurestOrderFragment.graphql.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const M=(e,r)=>({id:e,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(t=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:t.id,quantity:t.totalQuantity,product:{canonicalUrl:((a=t.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=t.product)==null?void 0:o.image)??"",name:((n=t.product)==null?void 0:n.name)??"",productId:0,productType:(s=t.product)==null?void 0:s.productType,sku:((i=t.product)==null?void 0:i.sku)??""},prices:{price:{value:t.price.value,currency:t.price.currency}},configurableOptions:((p=t.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),G=e=>{var a,o,n;const r=e.coupons[0],t=(a=e.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:e.email,grandTotal:e.grandTotal.value,orderId:e.number,orderType:"checkout",otherTax:0,salesTax:e.totalTax.value,shipping:{shippingMethod:((o=e.shipping)==null?void 0:o.code)??"",shippingAmount:((n=e.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:e.subtotal.value,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:e.grandTotal.value}]:[]}},N=e=>{var t,a;const r=(a=(t=e==null?void 0:e.data)==null?void 0:t.placeOrder)==null?void 0:a.orderV2;return r?m(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(e,r){const t=E();t.push({[e]:null}),t.push({[e]:r})}function I(e,r){E().push(a=>{const o=a.getState?a.getState():{};a.push({event:e,eventInfo:{...o,...r}})})}function L(e,r){const t=G(r),a=M(e,r);l(d.ORDER_CONTEXT,{...t}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` + mutation PLACE_ORDER_MUTATION($cartId: String!) { + placeOrder(input: { cart_id: $cartId }) { + errors { + code + message + } + orderV2 { email available_actions status number id order_date - order_status_change_date carrier shipping_method is_virtual - returns(pageSize: $pageSize) { - ...OrderReturns - } - items_eligible_for_return { - ...OrderItemDetails - ... on BundleOrderItem { - ...BundleOrderItemDetails - } - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } applied_coupons { code } @@ -58,13 +36,12 @@ query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { id product_sku product_name - quantity_shipped order_item { - ...OrderItemDetails + ...ORDER_ITEM_DETAILS_FRAGMENT ... on GiftCardOrderItem { - ...GiftCardDetails + ...GIFT_CARD_DETAILS_FRAGMENT product { - ...ProductDetails + ...PRODUCT_DETAILS_FRAGMENT } } } @@ -75,20 +52,20 @@ query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { type } shipping_address { - ...AddressesList + ...ADDRESS_FRAGMENT } billing_address { - ...AddressesList + ...ADDRESS_FRAGMENT } items { - ...OrderItemDetails + ...ORDER_ITEM_DETAILS_FRAGMENT ... on BundleOrderItem { - ...BundleOrderItemDetails + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT } ... on GiftCardOrderItem { - ...GiftCardDetails + ...GIFT_CARD_DETAILS_FRAGMENT product { - ...ProductDetails + ...PRODUCT_DETAILS_FRAGMENT } } ... on DownloadableOrderItem { @@ -100,115 +77,16 @@ query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { } } total { - ...OrderSummary + ...ORDER_SUMMARY_FRAGMENT } } } } -} -${u} -${_} -${p} -${c} -${D} -${R} -${h} -${O} -`,y=async({orderId:e,returnRef:r,queryType:t,returnsPageSize:a=50})=>await n(T,{method:"GET",cache:"force-cache",variables:{orderNumber:e,pageSize:a}}).then(s=>{var d;return(d=s.errors)!=null&&d.length?m(s.errors):b(t??"orderData",s,r)}).catch(l),f=` -query ORDER_BY_TOKEN($token: String!) { - guestOrderByToken(input: { token: $token }) { - email - id - number - order_date - order_status_change_date - status - token - carrier - shipping_method - printed_card_included - gift_receipt_included - available_actions - is_virtual - items_eligible_for_return { - ...OrderItemDetails - } - returns(pageSize: 50) { - ...OrderReturns - } - payment_methods { - name - type - } - applied_coupons { - code - } - shipments { - id - tracking { - title - number - carrier - } - comments { - message - timestamp - } - items { - id - product_sku - product_name - order_item { - ...OrderItemDetails - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - } - } - } - payment_methods { - name - type - } - shipping_address { - ...AddressesList - } - billing_address { - ...AddressesList - } - items { - ...OrderItemDetails - ... on BundleOrderItem { - ...BundleOrderItemDetails - } - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } - total { - ...OrderSummary - } - } -} -${u} -${_} -${p} -${c} -${D} -${R} -${h} -${O} -`,$=async(e,r)=>await n(f,{method:"GET",cache:"no-cache",variables:{token:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?m(t.errors):G(t,r)}).catch(l),A="orderData",C=async e=>{var i;const r=typeof(e==null?void 0:e.orderRef)=="string"?e==null?void 0:e.orderRef:"",t=typeof(e==null?void 0:e.returnRef)=="string"?e==null?void 0:e.returnRef:"",a=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((i=e==null?void 0:e.orderRef)==null?void 0:i.length)>20,s=(e==null?void 0:e.orderData)??null;if(s){o.emit("order/data",{...s,returnNumber:t});return}if(!r)return;const d=a?await $(r,t):await y({orderId:r,returnRef:t,queryType:A});d?o.emit("order/data",{...d,returnNumber:t}):o.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},E=new I({init:async e=>{const r={};E.config.setConfig({...r,...e}),C(e).catch(console.error)},listeners:()=>[]}),x=E.config;export{oe as cancelOrder,x as config,n as fetchGraphQl,W as getAttributesForm,ae as getAttributesList,q as getConfig,j as getCustomer,re as getCustomerOrdersReturn,J as getGuestOrder,y as getOrderDetailsById,Z as getStoreConfig,$ as guestOrderByToken,E as initialize,U as removeFetchGraphQlHeader,me as reorderItems,ie as requestGuestOrderCancel,se as requestReturn,Y as setEndpoint,Q as setFetchGraphQlHeader,H as setFetchGraphQlHeaders}; + ${R} + ${A} + ${D} + ${g} + ${O} + ${h} + ${C} +`,k=async e=>{if(!e)throw new Error("No cart ID found");return _(S,{variables:{cartId:e}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&T(r.errors);const t=N(r);return t&&(u.emit("order/placed",t),u.emit("cart/reset",void 0),L(e,t)),t}).catch(f)};export{H as cancelOrder,pt as config,_ as fetchGraphQl,W as getAttributesForm,tt as getAttributesList,V as getConfig,at as getCustomer,st as getCustomerOrdersReturn,ot as getGuestOrder,ct as getOrderDetailsById,Et as getStoreConfig,ut as guestOrderByToken,dt as initialize,k as placeOrder,Y as removeFetchGraphQlHeader,Tt as reorderItems,X as requestGuestOrderCancel,et as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/fragment.d.ts b/scripts/__dropins__/storefront-order/api/fragment.d.ts new file mode 100644 index 0000000000..9275ced8a6 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/fragment.d.ts @@ -0,0 +1,7 @@ +export { REQUEST_RETURN_ORDER_FRAGMENT } from './graphql/RequestReturnOrderFragment.graphql'; +export { ADDRESS_FRAGMENT } from './graphql/CustomerAddressFragment.graphql'; +export { PRODUCT_DETAILS_FRAGMENT, PRICE_DETAILS_FRAGMENT, GIFT_CARD_DETAILS_FRAGMENT, ORDER_ITEM_DETAILS_FRAGMENT, BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT, } from './graphql/OrderItemsFragment.graphql'; +export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql'; +export { RETURNS_FRAGMENT } from './graphql/ReturnsFragment.graphql'; +export { GUEST_ORDER_FRAGMENT } from './graphql/GurestOrderFragment.graphql'; +//# sourceMappingURL=fragment.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts index e210426503..de5037a870 100644 --- a/scripts/__dropins__/storefront-order/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts @@ -1,3 +1,3 @@ export declare const GET_ATTRIBUTES_FORM = "\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\n }\n }\n"; -export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n"; +export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n"; //# sourceMappingURL=getAttributesForm.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getCustomer/graphql/getCustomer.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getCustomer/graphql/getCustomer.graphql.d.ts index ba5cc6e262..c7eb0fa664 100644 --- a/scripts/__dropins__/storefront-order/api/getCustomer/graphql/getCustomer.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/getCustomer/graphql/getCustomer.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER = "\n query GET_CUSTOMER {\n customer {\n firstname\n lastname\n email\n }\n }\n"; +export declare const GET_CUSTOMER = "\n query GET_CUSTOMER {\n customer {\n firstname\n lastname\n email\n }\n }\n"; //# sourceMappingURL=getCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts b/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts index 7c1c1f422a..3aae328671 100644 --- a/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts +++ b/scripts/__dropins__/storefront-order/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts @@ -1,4 +1,4 @@ import { CustomerOrdersReturnModel } from '../../data/models'; -export declare const getCustomerOrdersReturn: (pageSize?: number) => Promise; +export declare const getCustomerOrdersReturn: (pageSize?: number, currentPage?: number) => Promise; //# sourceMappingURL=getCustomerOrdersReturn.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getGuestOrder/graphql/getGuestOrder.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getGuestOrder/graphql/getGuestOrder.graphql.d.ts index 767e397160..0970dc5aff 100644 --- a/scripts/__dropins__/storefront-order/api/getGuestOrder/graphql/getGuestOrder.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/getGuestOrder/graphql/getGuestOrder.graphql.d.ts @@ -1,3 +1,2 @@ -export declare const GUEST_ORDER_FRAGMENT: string; export declare const GET_GUEST_ORDER: string; //# sourceMappingURL=getGuestOrder.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/customerAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/customerAddressFragment.graphql.d.ts deleted file mode 100644 index fe3f1ab4c0..0000000000 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/customerAddressFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const ADDRESS = "\nfragment AddressesList on OrderAddress {\n city\n company\n country_code\n fax\n firstname\n lastname\n middlename\n postcode\n prefix\n region\n region_id\n street\n suffix\n telephone\n vat_id\n}"; -//# sourceMappingURL=customerAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/index.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/index.d.ts deleted file mode 100644 index ffe4a7baff..0000000000 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './orderSummaryFragment.graphql'; -export * from './orderByNumber.graphql'; -export * from './customerAddressFragment.graphql'; -export * from './orderItemsFragment.graphql'; -export * from './returnsFragment.graphql'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts deleted file mode 100644 index f77179d486..0000000000 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare const PRODUCT_DETAILS_FRAGMENT = "\n fragment ProductDetails on ProductInterface {\n __typename\n canonical_url\n url_key\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n"; -export declare const PRICE_DETAILS_FRAGMENT = "\n fragment PriceDetails on OrderItemInterface {\n prices {\n price_including_tax {\n value\n currency\n }\n original_price {\n value\n currency\n }\n original_price_including_tax {\n value\n currency\n }\n price {\n value\n currency\n }\n }\n }\n"; -export declare const GIFT_CARD_DETAILS_FRAGMENT = "\n fragment GiftCardDetails on GiftCardOrderItem {\n ...PriceDetails\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n"; -export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment OrderItemDetails on OrderItemInterface {\n __typename\n status\n product_sku\n eligible_for_return\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_return_requested\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...ProductDetails\n }\n ...PriceDetails\n }\n"; -export declare const BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment BundleOrderItemDetails on BundleOrderItem {\n ...PriceDetails\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n"; -//# sourceMappingURL=orderItemsFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderSummaryFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderSummaryFragment.graphql.d.ts deleted file mode 100644 index 2771a8ebdf..0000000000 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/orderSummaryFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const ORDER_SUMMARY = "\nfragment OrderSummary on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n}"; -//# sourceMappingURL=orderSummaryFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts deleted file mode 100644 index 32e34d1e89..0000000000 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const RETURNS_FRAGMENT = "\n fragment OrderReturns on Returns {\n __typename\n items {\n number\n status\n created_at\n shipping {\n tracking {\n status {\n text\n type\n }\n carrier {\n uid\n label\n }\n tracking_number\n }\n }\n order {\n number\n token\n }\n items {\n uid\n quantity\n status\n request_quantity\n order_item {\n ...OrderItemDetails\n ... on GiftCardOrderItem {\n ...GiftCardDetails\n product {\n ...ProductDetails\n }\n }\n }\n }\n }\n }\n"; -//# sourceMappingURL=returnsFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/getStoreConfig/graphql/StoreConfigQuery.d.ts b/scripts/__dropins__/storefront-order/api/getStoreConfig/graphql/StoreConfigQuery.d.ts index 2ac0a81be9..4ffb839df6 100644 --- a/scripts/__dropins__/storefront-order/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +++ b/scripts/__dropins__/storefront-order/api/getStoreConfig/graphql/StoreConfigQuery.d.ts @@ -1,2 +1,2 @@ -export declare const STORE_CONFIG_QUERY = "\nquery STORE_CONFIG_QUERY {\n storeConfig {\n order_cancellation_enabled\n order_cancellation_reasons {\n description\n }\n orders_invoices_credit_memos_display_price\n orders_invoices_credit_memos_display_shipping_amount\n orders_invoices_credit_memos_display_subtotal\n orders_invoices_credit_memos_display_grandtotal\n orders_invoices_credit_memos_display_full_summary\n orders_invoices_credit_memos_display_zero_tax\n }\n}\n"; +export declare const STORE_CONFIG_QUERY = "\n query STORE_CONFIG_QUERY {\n storeConfig {\n order_cancellation_enabled\n order_cancellation_reasons {\n description\n }\n base_media_url\n orders_invoices_credit_memos_display_price\n orders_invoices_credit_memos_display_shipping_amount\n orders_invoices_credit_memos_display_subtotal\n orders_invoices_credit_memos_display_grandtotal\n orders_invoices_credit_memos_display_full_summary\n orders_invoices_credit_memos_display_zero_tax\n }\n }\n"; //# sourceMappingURL=StoreConfigQuery.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/CustomerAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/CustomerAddressFragment.graphql.d.ts new file mode 100644 index 0000000000..33dd3d63a5 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/CustomerAddressFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const ADDRESS_FRAGMENT = "\n fragment ADDRESS_FRAGMENT on OrderAddress {\n city\n company\n country_code\n fax\n firstname\n lastname\n middlename\n postcode\n prefix\n region\n region_id\n street\n suffix\n telephone\n vat_id\n }\n"; +//# sourceMappingURL=CustomerAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts new file mode 100644 index 0000000000..6e9b547df1 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const GUEST_ORDER_FRAGMENT: string; +//# sourceMappingURL=GurestOrderFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts new file mode 100644 index 0000000000..46518c21b1 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts @@ -0,0 +1,6 @@ +export declare const PRODUCT_DETAILS_FRAGMENT = "\n fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface {\n __typename\n canonical_url\n url_key\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n"; +export declare const PRICE_DETAILS_FRAGMENT = "\n fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface {\n prices {\n price_including_tax {\n value\n currency\n }\n original_price {\n value\n currency\n }\n original_price_including_tax {\n value\n currency\n }\n price {\n value\n currency\n }\n }\n }\n"; +export declare const GIFT_CARD_DETAILS_FRAGMENT = "\n fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem {\n ...PRICE_DETAILS_FRAGMENT\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n"; +export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface {\n __typename\n status\n product_sku\n eligible_for_return\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_return_requested\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...PRODUCT_DETAILS_FRAGMENT\n }\n ...PRICE_DETAILS_FRAGMENT\n }\n"; +export declare const BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem {\n ...PRICE_DETAILS_FRAGMENT\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n"; +//# sourceMappingURL=OrderItemsFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts new file mode 100644 index 0000000000..94c708b81c --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; +//# sourceMappingURL=OrderSummaryFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/RequestReturnOrderFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/RequestReturnOrderFragment.graphql.d.ts new file mode 100644 index 0000000000..3266d431f6 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/RequestReturnOrderFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const REQUEST_RETURN_ORDER_FRAGMENT = "\n fragment REQUEST_RETURN_ORDER_FRAGMENT on Return {\n __typename\n uid\n status\n number\n created_at\n }\n"; +//# sourceMappingURL=RequestReturnOrderFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/ReturnsFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/ReturnsFragment.graphql.d.ts new file mode 100644 index 0000000000..02bf061131 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/graphql/ReturnsFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const RETURNS_FRAGMENT = "\n fragment RETURNS_FRAGMENT on Returns {\n __typename\n items {\n number\n status\n created_at\n shipping {\n tracking {\n status {\n text\n type\n }\n carrier {\n uid\n label\n }\n tracking_number\n }\n }\n order {\n number\n token\n }\n items {\n uid\n quantity\n status\n request_quantity\n order_item {\n ...ORDER_ITEM_DETAILS_FRAGMENT\n ... on GiftCardOrderItem {\n ...GIFT_CARD_DETAILS_FRAGMENT\n product {\n ...PRODUCT_DETAILS_FRAGMENT\n }\n }\n }\n }\n }\n }\n"; +//# sourceMappingURL=ReturnsFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/index.d.ts b/scripts/__dropins__/storefront-order/api/index.d.ts index 73b1a3e4db..0b19030217 100644 --- a/scripts/__dropins__/storefront-order/api/index.d.ts +++ b/scripts/__dropins__/storefront-order/api/index.d.ts @@ -1,15 +1,16 @@ -export * from './initialize'; +export * from './cancelOrder'; export * from './fetch-graphql'; -export * from './getOrderDetailsById'; -export * from './getGuestOrder'; -export * from './guestOrderByToken'; export * from './getAttributesForm'; +export * from './getAttributesList'; export * from './getCustomer'; -export * from './getStoreConfig'; export * from './getCustomerOrdersReturn'; -export * from './getAttributesList'; -export * from './requestReturn'; -export * from './cancelOrder'; -export * from './requestGuestOrderCancel'; +export * from './getGuestOrder'; +export * from './getOrderDetailsById'; +export * from './getStoreConfig'; +export * from './guestOrderByToken'; +export * from './initialize'; +export * from './placeOrder'; export * from './reorderItems'; +export * from './requestGuestOrderCancel'; +export * from './requestReturn'; //# sourceMappingURL=index.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 fc29428e5f..c5ac724da0 100644 --- a/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-order/api/initialize/initialize.d.ts @@ -1,8 +1,14 @@ -import { Initializer } from '@dropins/tools/types/elsie/src/lib'; +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 = { langDefinitions?: Lang; + models?: { + OrderDataModel?: Model; + CustomerOrdersReturnModel?: Model; + RequestReturnModel?: Model; + }; }; export declare const initialize: Initializer; export declare const config: import('@dropins/tools/types/elsie/src/lib').Config; diff --git a/scripts/__dropins__/storefront-order/api/placeOrder/graphql/placeOrderMutation.d.ts b/scripts/__dropins__/storefront-order/api/placeOrder/graphql/placeOrderMutation.d.ts new file mode 100644 index 0000000000..b4b1eddb62 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/placeOrder/graphql/placeOrderMutation.d.ts @@ -0,0 +1,2 @@ +export declare const PLACE_ORDER_MUTATION: string; +//# sourceMappingURL=placeOrderMutation.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/placeOrder/index.d.ts b/scripts/__dropins__/storefront-order/api/placeOrder/index.d.ts new file mode 100644 index 0000000000..65c2281404 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/placeOrder/index.d.ts @@ -0,0 +1,2 @@ +export * from './placeOrder'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/placeOrder/placeOrder.d.ts b/scripts/__dropins__/storefront-order/api/placeOrder/placeOrder.d.ts new file mode 100644 index 0000000000..4826b6a8d9 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/placeOrder/placeOrder.d.ts @@ -0,0 +1,4 @@ +import { OrderDataModel } from '../../data/models'; + +export declare const placeOrder: (cartId: string) => Promise; +//# sourceMappingURL=placeOrder.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/reorderItems/graphql/reorderItems.graphql.d.ts b/scripts/__dropins__/storefront-order/api/reorderItems/graphql/reorderItems.graphql.d.ts index d1743c1dca..b99af32348 100644 --- a/scripts/__dropins__/storefront-order/api/reorderItems/graphql/reorderItems.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/reorderItems/graphql/reorderItems.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const REORDER_ITEMS_MUTATION = "\nmutation REORDER_ITEMS_MUTATION($orderNumber: String!) {\n reorderItems(orderNumber: $orderNumber) {\n cart {\n itemsV2 {\n items {\n uid\n }\n }\n }\n userInputErrors{\n code\n message\n path\n }\n }\n}\n"; +export declare const REORDER_ITEMS_MUTATION = "\n mutation REORDER_ITEMS_MUTATION($orderNumber: String!) {\n reorderItems(orderNumber: $orderNumber) {\n cart {\n itemsV2 {\n items {\n uid\n }\n }\n }\n userInputErrors {\n code\n message\n path\n }\n }\n }\n"; //# sourceMappingURL=reorderItems.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/requestReturn/graphql/fragments.d.ts b/scripts/__dropins__/storefront-order/api/requestReturn/graphql/fragments.d.ts deleted file mode 100644 index 1a06f4fcf8..0000000000 --- a/scripts/__dropins__/storefront-order/api/requestReturn/graphql/fragments.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare const REQUEST_RETURN_ORDER_FRAGMENT = "\n fragment OrderReturn on Return {\n __typename\n uid\n status\n number\n created_at\n }\n"; -//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/requestReturn/requestReturn.d.ts b/scripts/__dropins__/storefront-order/api/requestReturn/requestReturn.d.ts index 8f385843e8..1d09d04e35 100644 --- a/scripts/__dropins__/storefront-order/api/requestReturn/requestReturn.d.ts +++ b/scripts/__dropins__/storefront-order/api/requestReturn/requestReturn.d.ts @@ -1,9 +1,5 @@ import { RequestReturnProps } from '../../types'; +import { RequestReturnModel } from '../../data/models'; -export declare const requestReturn: (form: RequestReturnProps) => Promise<{ - uid: string; - number: string; - status: string; - createdAt: string; -}>; +export declare const requestReturn: (form: RequestReturnProps) => Promise; //# sourceMappingURL=requestReturn.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 43382f95c4..97f5fb2f5a 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 n,jsxs as w,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{Price as u,CartItem as o,Icon as r,Image as U,Incrementer as c}from"@dropins/tools/components.js";import{useCallback as d}from"@dropins/tools/preact-hooks.js";import{classes as X}from"@dropins/tools/lib.js";import{O as p}from"./OrderLoaders.js";import*as Q from"@dropins/tools/preact-compat.js";const ee=_=>Q.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",..._},Q.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"}),Q.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"})),te=({loading:_,product:e,itemType:Y,taxConfig:D,translations:v,disabledIncrementer:C,onQuantity:k,showConfigurableOptions:N,routeProductDetails:E})=>{var M,Z,j,q,x,z,O,W,$,i,B,F,K,R,A,G,J;const{taxExcluded:V,taxIncluded:f}=D,t=d((h,T,g)=>n(u,{amount:h,currency:T,weight:"normal",...g}),[]);if(!e)return n(p,{});let b={};const L=Y==="cancelled",I=(Z=(M=e==null?void 0:e.product)==null?void 0:M.stockStatus)==null?void 0:Z.includes("IN_STOCK"),a=e==null?void 0:e.giftCard,l=(j=e==null?void 0:e.itemPrices)==null?void 0:j.priceIncludingTax,s=(q=e==null?void 0:e.itemPrices)==null?void 0:q.originalPrice,m=(x=e==null?void 0:e.itemPrices)==null?void 0:x.price,P=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),H={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...a!=null&&a.senderName?{[v.sender]:a==null?void 0:a.senderName}:{},...a!=null&&a.senderEmail?{[v.sender]:a==null?void 0:a.senderEmail}:{},...a!=null&&a.senderName?{[v.sender]:a==null?void 0:a.senderName}:{},...a!=null&&a.recipientEmail?{[v.recipient]:a==null?void 0:a.recipientEmail}:{},...a!=null&&a.message?{[v.message]:a==null?void 0:a.message}:{},...e!=null&&e.downloadableLinks?{[`${(O=e==null?void 0:e.downloadableLinks)==null?void 0:O.count} ${v.downloadableCount}`]:(W=e==null?void 0:e.downloadableLinks)==null?void 0:W.result}:{}};if(f&&V){const h=y?s==null?void 0:s.value:(l==null?void 0:l.value)*(e==null?void 0:e.totalQuantity);b={taxExcluded:!0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:w(S,{children:[t(h,s==null?void 0:s.currency,{variant:e.discounted&&(l==null?void 0:l.value)!==h?"strikethrough":"default"}),e.discounted&&(l==null?void 0:l.value)!==h?t(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((m==null?void 0:m.value)*e.totalQuantity,m==null?void 0:m.currency)}}else if(!f&&V)b={taxExcluded:void 0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:w(S,{children:[t((s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),l==null?void 0:l.currency,{variant:y?"strikethrough":"default"}),y?t(($=e.price)==null?void 0:$.value,(i=e.price)==null?void 0:i.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((m==null?void 0:m.value)*(e==null?void 0:e.totalQuantity),m==null?void 0:m.currency)};else if(f&&!V){const h=y?s.value:l.value*e.totalQuantity;b={taxExcluded:void 0,taxIncluded:!0,price:t(l==null?void 0:l.value,l==null?void 0:l.currency),total:w(S,{children:[t(h,l==null?void 0:l.currency,{variant:y?"strikethrough":"default",weight:"bold"}),y?t(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]})}}return n(o,{loading:_,alert:L&&I?w("span",{children:[n(r,{source:ee}),v.outOfStock]}):n(S,{}),configurations:(N==null?void 0:N(H))??H,title:E?n("a",{"data-testid":"product-name",className:X(["cart-summary-item__title",["cart-summary-item__title--strikethrough",L]]),href:E(e),children:(B=e==null?void 0:e.product)==null?void 0:B.name}):n("div",{"data-testid":"product-name",className:X(["cart-summary-item__title",["cart-summary-item__title--strikethrough",L]]),children:(F=e==null?void 0:e.product)==null?void 0:F.name}),sku:n("div",{children:(K=e==null?void 0:e.product)==null?void 0:K.sku}),...P,image:E?n("a",{href:E(e),children:n(U,{src:(R=e==null?void 0:e.product)==null?void 0:R.thumbnail.url,alt:(A=e==null?void 0:e.product)==null?void 0:A.thumbnail.label,loading:"lazy",width:"90",height:"120"})}):n(U,{src:(G=e==null?void 0:e.product)==null?void 0:G.thumbnail.url,alt:(J=e==null?void 0:e.product)==null?void 0:J.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...b,footer:k&&!C?n(c,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:h=>k==null?void 0:k(Number(h)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0})};export{te as C,ee as S}; +import{jsx as v,jsxs as S,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{Price as P,Image as T,CartItem as g,Icon as u,Incrementer as o}from"@dropins/tools/components.js";import{useCallback as G}from"@dropins/tools/preact-hooks.js";import{classes as J}from"@dropins/tools/lib.js";import{O as r}from"./OrderLoaders.js";import*as M from"@dropins/tools/preact-compat.js";const c=k=>M.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...k},M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),se=({placeholderImage:k="",loading:X,product:e,itemType:Y,taxConfig:D,translations:h,disabledIncrementer:i,onQuantity:E,showConfigurableOptions:V,routeProductDetails:w})=>{var q,x,O,W,$,z,B,F,K,R,U;const{taxExcluded:f,taxIncluded:L}=D,t=G((m,H,b)=>v(P,{amount:m,currency:H,weight:"normal",...b}),[]),Z=G(m=>{var b,A;const H=(b=m==null?void 0:m.product)!=null&&b.thumbnail.url.length?(A=m==null?void 0:m.product)==null?void 0:A.thumbnail.url:k;return v(T,{src:H,alt:m==null?void 0:m.productName,loading:"lazy",width:"90",height:"120"})},[k]);if(!e)return v(r,{});let N={};const Q=Y==="cancelled",C=(x=(q=e==null?void 0:e.product)==null?void 0:q.stockStatus)==null?void 0:x.includes("IN_STOCK"),l=e==null?void 0:e.giftCard,a=(O=e==null?void 0:e.itemPrices)==null?void 0:O.priceIncludingTax,s=(W=e==null?void 0:e.itemPrices)==null?void 0:W.originalPrice,n=($=e==null?void 0:e.itemPrices)==null?void 0:$.price,I=e.totalQuantity>1?{quantity:e.totalQuantity}:{},y=e.discounted&&((z=e.price)==null?void 0:z.value)!==(s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),j={...(e==null?void 0:e.configurableOptions)||{},...(e==null?void 0:e.bundleOptions)||{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.senderEmail?{[h.sender]:l==null?void 0:l.senderEmail}:{},...l!=null&&l.senderName?{[h.sender]:l==null?void 0:l.senderName}:{},...l!=null&&l.recipientEmail?{[h.recipient]:l==null?void 0:l.recipientEmail}:{},...l!=null&&l.message?{[h.message]:l==null?void 0:l.message}:{},...e!=null&&e.downloadableLinks?{[`${(B=e==null?void 0:e.downloadableLinks)==null?void 0:B.count} ${h.downloadableCount}`]:(F=e==null?void 0:e.downloadableLinks)==null?void 0:F.result}:{}};if(L&&f){const m=y?s==null?void 0:s.value:(a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity);N={taxExcluded:!0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t(m,s==null?void 0:s.currency,{variant:e.discounted&&(a==null?void 0:a.value)!==m?"strikethrough":"default"}),e.discounted&&(a==null?void 0:a.value)!==m?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*e.totalQuantity,n==null?void 0:n.currency)}}else if(!L&&f)N={taxExcluded:void 0,taxIncluded:void 0,price:t(s==null?void 0:s.value,s==null?void 0:s.currency),total:S(_,{children:[t((s==null?void 0:s.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency,{variant:y?"strikethrough":"default"}),y?t((K=e.price)==null?void 0:K.value,(R=e.price)==null?void 0:R.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:t((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),n==null?void 0:n.currency)};else if(L&&!f){const m=y?s.value:a.value*e.totalQuantity;N={taxExcluded:void 0,taxIncluded:!0,price:t(a==null?void 0:a.value,a==null?void 0:a.currency),total:S(_,{children:[t(m,a==null?void 0:a.currency,{variant:y?"strikethrough":"default",weight:"bold"}),y?t(a==null?void 0:a.value,a==null?void 0:a.currency,{sale:!0,weight:"bold"}):null]})}}return v(g,{loading:X,alert:Q&&C?S("span",{children:[v(u,{source:c}),h.outOfStock]}):v(_,{}),configurations:(V==null?void 0:V(j))??j,title:w?v("a",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),href:w(e),children:e==null?void 0:e.productName}):v("div",{"data-testid":"product-name",className:J(["cart-summary-item__title",["cart-summary-item__title--strikethrough",Q]]),children:e==null?void 0:e.productName}),sku:v("div",{children:(U=e==null?void 0:e.product)==null?void 0:U.sku}),...I,image:w?v("a",{href:w(e),children:Z(e)}):Z(e),...N,footer:E&&!i?v(o,{value:1,min:1,max:e==null?void 0:e.totalQuantity,onValue:m=>E==null?void 0:E(Number(m)),name:"quantity","data-testid":"returnIncrementer",readonly:!0}):void 0})};export{se as C,c as S}; diff --git a/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js new file mode 100644 index 0000000000..b3f1d975cb --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js @@ -0,0 +1,99 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{P as _,a as e,G as E,O as R,B as t,b as r,A as T,R as a}from"./initialize.js";const d=` + fragment GUEST_ORDER_FRAGMENT on CustomerOrder { + email + id + number + order_date + order_status_change_date + status + token + carrier + shipping_method + printed_card_included + gift_receipt_included + available_actions + is_virtual + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + } + returns { + ...RETURNS_FRAGMENT + } + payment_methods { + name + type + } + applied_coupons { + code + } + shipments { + id + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + __typename + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + ${_} + ${e} + ${E} + ${R} + ${t} + ${r} + ${T} + ${a} +`;export{d as G}; diff --git a/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js b/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js index 0f693b9b21..10df655718 100644 --- a/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsxs as g,jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{InLineAlert as v,Picker as x,Button as F}from"@dropins/tools/components.js";import{F as S}from"./OrderCancel.js";import"@dropins/tools/lib.js";import{useState as n}from"@dropins/tools/preact-hooks.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-compat.js";import{r as E,c as _}from"./requestGuestOrderCancel.js";import{useText as D,Text as l}from"@dropins/tools/i18n.js";const k=({orderRef:a,pickerProps:m,submitButtonProps:u,cancelReasons:t})=>{const o=D({ErrorHeading:"Order.OrderCancelForm.errorHeading",ErrorDescription:"Order.OrderCancelForm.errorDescription",orderCancellationLabel:"Order.OrderCancelForm.label"}),[i,p]=n(0),[f,O]=n(!1),[b,h]=n(!1);d.on("authenticated",e=>{e&&h(!0)},{eager:!0});const C=e=>{e.preventDefault();const s=Number(e.target.value);p(s)};return g(S,{onSubmit:async e=>(e.preventDefault(),(a.length>20?E:_)(a,t[i].text,c=>{b||(c.status="guest order cancellation requested"),d.emit("order/data",c)},()=>{O(!0)})),"data-testid":"order-order-cancel-reasons-form__text",children:[f&&r(v,{heading:o.ErrorHeading,description:o.ErrorDescription}),r("div",{className:"order-order-cancel-reasons-form__text",children:r(l,{id:"Order.OrderCancelForm.description"})}),r(x,{name:"cancellationReasons",floatingLabel:o.orderCancellationLabel,defaultOption:t[0],variant:"primary",options:t,value:String(i),handleSelect:C,required:!0,"data-testid":"order-cancellation-reasons-selector",...m}),r("div",{className:"order-order-cancel-reasons-form__button-container",children:r(F,{variant:"primary","data-testid":"order-cancel-submit-button",...u,children:r(l,{id:"Order.OrderCancelForm.button"})})})]})};export{k as O}; +import{jsxs as g,jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{InLineAlert as v,Picker as x,Button as F}from"@dropins/tools/components.js";import{F as S}from"./ShippingStatusCard.js";import"@dropins/tools/lib.js";import{useState as n}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as d}from"@dropins/tools/event-bus.js";import{r as E,c as _}from"./requestGuestOrderCancel.js";import{useText as D,Text as l}from"@dropins/tools/i18n.js";const k=({orderRef:a,pickerProps:m,submitButtonProps:u,cancelReasons:t})=>{const o=D({ErrorHeading:"Order.OrderCancelForm.errorHeading",ErrorDescription:"Order.OrderCancelForm.errorDescription",orderCancellationLabel:"Order.OrderCancelForm.label"}),[i,p]=n(0),[f,O]=n(!1),[b,h]=n(!1);d.on("authenticated",e=>{e&&h(!0)},{eager:!0});const C=e=>{e.preventDefault();const s=Number(e.target.value);p(s)};return g(S,{onSubmit:async e=>(e.preventDefault(),(a.length>20?E:_)(a,t[i].text,c=>{b||(c.status="guest order cancellation requested"),d.emit("order/data",c)},()=>{O(!0)})),"data-testid":"order-order-cancel-reasons-form__text",children:[f&&r(v,{heading:o.ErrorHeading,description:o.ErrorDescription}),r("div",{className:"order-order-cancel-reasons-form__text",children:r(l,{id:"Order.OrderCancelForm.description"})}),r(x,{name:"cancellationReasons",floatingLabel:o.orderCancellationLabel,defaultOption:t[0],variant:"primary",options:t,value:String(i),handleSelect:C,required:!0,"data-testid":"order-cancellation-reasons-selector",...m}),r("div",{className:"order-order-cancel-reasons-form__button-container",children:r(F,{variant:"primary","data-testid":"order-cancel-submit-button",...u,children:r(l,{id:"Order.OrderCancelForm.button"})})})]})};export{k as O}; diff --git a/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js b/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js index b7f31ec61f..cf9eb06f10 100644 --- a/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js +++ b/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as e,jsxs as a}from"@dropins/tools/preact-jsx-runtime.js";import{Card as n,Skeleton as i,SkeletonRow as r,CartItemSkeleton as t}from"@dropins/tools/components.js";import"./OrderCancel.js";import{classes as o}from"@dropins/tools/lib.js";const z=({testId:s,withCard:d=!0})=>{const l=a(i,{"data-testid":s??"skeletonLoader",children:[e(r,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return d?l:e(n,{variant:"secondary",className:o(["order-order-loaders","order-order-loaders--card-loader"]),children:l})},g=s=>e(n,{variant:"secondary",...s,children:a(i,{"data-testid":"order-details-skeleton",children:[e(r,{variant:"heading",size:"medium",fullWidth:!0}),e(r,{size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"})]})}),f=()=>a(i,{"data-testid":"order-product-list-skeleton",style:{gridTemplateColumns:"1fr"},children:[e(r,{variant:"heading",fullWidth:!0,size:"medium"}),e(t,{}),e(t,{}),e(t,{}),e(t,{}),e(t,{})]}),v=()=>a(i,{"data-testid":"order-cost-summary-content-skeleton",className:"order-cost-summary-content",children:[e(r,{variant:"heading",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"heading",size:"small",fullWidth:!0,lines:3})]});export{z as C,g as D,v as O,f as a}; +import{jsx as e,jsxs as a}from"@dropins/tools/preact-jsx-runtime.js";import"./ShippingStatusCard.js";import{Card as d,Skeleton as i,SkeletonRow as r,CartItemSkeleton as t}from"@dropins/tools/components.js";import{classes as m}from"@dropins/tools/lib.js";const z=({testId:s,withCard:n=!0})=>{const l=a(i,{"data-testid":s??"skeletonLoader",children:[e(r,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return n?l:e(d,{variant:"secondary",className:m(["order-order-loaders","order-order-loaders--card-loader"]),children:l})},v=s=>e(d,{variant:"secondary",...s,children:a(i,{"data-testid":"order-details-skeleton",children:[e(r,{variant:"heading",size:"medium",fullWidth:!0}),e(r,{size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"})]})}),g=()=>a(i,{"data-testid":"order-product-list-skeleton",style:{gridTemplateColumns:"1fr"},children:[e(r,{variant:"heading",fullWidth:!0,size:"medium"}),e(t,{}),e(t,{}),e(t,{}),e(t,{}),e(t,{})]}),p=()=>a(i,{"data-testid":"order-cost-summary-content-skeleton",className:"order-cost-summary-content",children:[e(r,{variant:"heading",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"empty",size:"small"}),e(r,{variant:"heading",size:"small",fullWidth:!0,lines:3})]}),f=()=>a(i,{"data-testid":"order-header-skeleton",className:"order-header",children:[e(r,{variant:"empty",size:"xlarge",fullWidth:!0}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"small",fullWidth:!0}),e(r,{variant:"heading",size:"xsmall",fullWidth:!0})]});export{z as C,v as D,p as O,g as a,f as b}; diff --git a/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js index e0bd981972..0e8cf12c0c 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 i,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as w}from"@dropins/tools/preact-hooks.js";import{classes as X,Slot as q}from"@dropins/tools/lib.js";import{IllustratedMessage as D,Icon as V,Card as O,ContentGrid as r1,Image as e1,Header as P,Pagination as t1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as n1}from"@dropins/tools/preact-compat.js";import"./OrderCancel.js";import{f as a1}from"./returnOrdersHelper.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import{C as Q}from"./OrderLoaders.js";import{Text as U}from"@dropins/tools/i18n.js";const J=c=>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",...c},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"})))),c1=c=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},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"})),T=({typeList:c,isEmpty:p,minifiedView:N,message:t})=>{const a=n1(()=>{switch(c){case"orders":return{icon:c1,text:r("p",{children:t}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[c,t]);return!p||!c||!a.text?null:r(D,{className:X(["order-empty-list",a.className,N?"order-empty-list--minified":""]),message:a.text,icon:r(V,{source:a.icon}),"data-testid":"emptyList"})},W={size:"32",stroke:"2"},_1=({minifiedViewKey:c,withReturnNumber:p=!1,withOrderNumber:N=!1,slots:t,pageInfo:a,withReturnsListButton:A=!0,isMobile:E=!1,returnsInMinifiedView:Y=1,translations:L={},orderReturns:s=[],minifiedView:h=!1,withHeader:g=!0,withThumbnails:B=!0,selectedPage:S=1,handleSetSelectPage:k,routeReturnDetails:d,routeOrderDetails:f,routeTracking:v,routeReturnsList:b,routeProductDetails:m,loading:x})=>{const z=h?Y:s.length,j=m!=null&&m()?"a":"span",y=w(()=>s.slice(0,z).map((e,R)=>{var F,G;const $=((e==null?void 0:e.items)??[]).reduce((n,C)=>(C.requestQuantity??0)+n,0);return r(O,{variant:"secondary",className:"order-returns-list-content__cards-list",children:i("div",{className:"order-returns-list-content__cards-grid",children:[i("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(U,{id:`Order.Returns.${c}.returnsList.returnStatus.${a1(e.returnStatus)}`})}),p?i("p",{children:[L.returnNumber," ",r("a",{href:(d==null?void 0:d({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,N?i("p",{children:[L.orderNumber," ",r("a",{href:(f==null?void 0:f({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(F=e==null?void 0:e.tracking)==null?void 0:F.map((n,C)=>{var Z,u;const M={title:"",number:(n==null?void 0:n.trackingNumber)??"",carrier:((Z=n==null?void 0:n.carrier)==null?void 0:Z.label)??""},H=v==null?void 0:v(M),o=`${M.number}_${C}`;return i("p",{children:[`${L.carrier} `,`${(u=M.carrier)==null?void 0:u.toLocaleUpperCase()} | `,H?r("a",{href:H,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?i("p",{children:[$," ",r(U,{id:`Order.Returns.${c}.returnsList.itemText`,plural:$,fields:{count:$}})]}):null]}),B?r(r1,{maxColumns:E?3:9,emptyGridContent:r(_,{}),className:X(["order-returns-list-content__images",["order-returns-list-content__images-3",E]]),children:(G=e==null?void 0:e.items)==null?void 0:G.map((n,C)=>{var Z,u;const M=(Z=n.thumbnail)==null?void 0:Z.label,H=(u=n.thumbnail)==null?void 0:u.url,o=`key_${C}_${n.uid}`;return r(j,{"data-testid":o,href:(m==null?void 0:m(n))??"#",children:r(e1,{alt:M,src:H,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(V,{source:J,...W})})]})},R)}),[s,z,c,p,L,d,N,f,t,B,E,m,v,j]),I=w(()=>i(_,{children:[g?r(P,{title:L.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,x?r(Q,{withCard:!1}):i(_,{children:[y,r(T,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:L.emptyOrdersListMessage}),A?r("a",{className:"order-returns-list-content__actions",href:(b==null?void 0:b())??"#",children:r(O,{variant:"secondary",className:"order-returns-list-content__card",children:i("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:L.viewAllOrdersButton}),r(V,{source:J,...W})]})})}):null]})]}),[b,A,g,L,y,h,s.length,x]),K=w(()=>i(_,{children:[g?r(P,{title:L.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,x?r(Q,{withCard:!1}):i(_,{children:[r(T,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:L.emptyOrdersListMessage}),y,(a==null?void 0:a.totalPages)>1?r(t1,{totalPages:a==null?void 0:a.totalPages,currentPage:S,onChange:k}):null]})]}),[y,h,s,L,a==null?void 0:a.totalPages,S,k,x,g]);return r("div",{className:"order-returns-list-content",children:h?I:K})};export{_1 as R}; +import{jsx as r,jsxs as L,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as V}from"@dropins/tools/preact-hooks.js";import{classes as I,Slot as Q}from"@dropins/tools/lib.js";import{IllustratedMessage as t1,Icon as A,Card as U,ContentGrid as n1,Image as a1,Header as J,Pagination as L1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as c1}from"@dropins/tools/preact-compat.js";import"./ShippingStatusCard.js";import{f as i1}from"./returnOrdersHelper.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{C as T}from"./OrderLoaders.js";import{Text as W}from"@dropins/tools/i18n.js";const X=c=>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",...c},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"})))),s1=c=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},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"})),Y=({typeList:c,isEmpty:C,minifiedView:g,message:M})=>{const t=c1(()=>{switch(c){case"orders":return{icon:s1,text:r("p",{children:M}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[c,M]);return!C||!c||!t.text?null:r(t1,{className:I(["order-empty-list",t.className,g?"order-empty-list--minified":""]),message:t.text,icon:r(A,{source:t.icon}),"data-testid":"emptyList"})},K={size:"32",stroke:"2"},g1=({placeholderImage:c,minifiedViewKey:C,withReturnNumber:g=!1,withOrderNumber:M=!1,slots:t,pageInfo:i,withReturnsListButton:B=!0,isMobile:$=!1,returnsInMinifiedView:R=1,translations:a={},orderReturns:s=[],minifiedView:h=!1,withHeader:f=!0,withThumbnails:S=!0,selectedPage:k=1,handleSetSelectPage:z,routeReturnDetails:d,routeOrderDetails:v,routeTracking:b,routeReturnsList:x,routeProductDetails:m,loading:y})=>{const j=h?R:s.length,F=m!=null&&m()?"a":"span",H=V(()=>s.slice(0,j).map((e,e1)=>{var G,q;const w=((e==null?void 0:e.items)??[]).reduce((n,Z)=>(Z.requestQuantity??0)+n,0);return r(U,{variant:"secondary",className:"order-returns-list-content__cards-list",children:L("div",{className:"order-returns-list-content__cards-grid",children:[L("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(W,{id:`Order.Returns.${C}.returnsList.returnStatus.${i1(e.returnStatus)}`})}),g?L("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?L("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,Z)=>{var _,p;const u={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(u),o=`${u.number}_${Z}`;return L("p",{children:[`${a.carrier} `,`${(p=u.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?L("p",{children:[w," ",r(W,{id:`Order.Returns.${C}.returnsList.itemText`,plural:w,fields:{count:w}})]}):null]}),S?r(n1,{maxColumns:$?3:9,emptyGridContent:r(N,{}),className:I(["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,Z)=>{var _,p,O,P;const u=(_=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:c,o=`key_${Z}_${n.uid}`;return r(F,{"data-testid":o,href:(m==null?void 0:m(n))??"#",children:r(a1,{alt:u,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(A,{source:X,...K})})]})},e1)}),[s,j,C,g,a,M,t,S,$,c,F,b,m,d,v]),D=V(()=>L(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,y?r(T,{withCard:!1}):L(N,{children:[H,r(Y,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),B?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:L("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:a.viewAllOrdersButton}),r(A,{source:X,...K})]})})}):null]})]}),[x,B,f,a,H,h,s.length,y]),r1=V(()=>L(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,y?r(T,{withCard:!1}):L(N,{children:[r(Y,{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?D:r1})};export{g1 as R}; diff --git a/scripts/__dropins__/storefront-order/chunks/OrderCancel.js b/scripts/__dropins__/storefront-order/chunks/ShippingStatusCard.js similarity index 100% rename from scripts/__dropins__/storefront-order/chunks/OrderCancel.js rename to scripts/__dropins__/storefront-order/chunks/ShippingStatusCard.js diff --git a/scripts/__dropins__/storefront-order/chunks/convertCase.js b/scripts/__dropins__/storefront-order/chunks/convertCase.js deleted file mode 100644 index 9edffe763d..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/convertCase.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -const l=r=>r.replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),C=r=>r.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),u=(r,n,s)=>{const c=["string","boolean","number"],p=n==="camelCase"?l:C;return Array.isArray(r)?r.map(e=>c.includes(typeof e)||e===null?e:typeof e=="object"?u(e,n,s):e):r!==null&&typeof r=="object"?Object.entries(r).reduce((e,[t,o])=>{const f=s&&s[t]?s[t]:p(t);return e[f]=c.includes(typeof o)||o===null?o:u(o,n,s),e},{}):r};export{u as a,l as c}; diff --git a/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js b/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js index 4798180f90..0600701db6 100644 --- a/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js +++ b/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js @@ -34,7 +34,7 @@ import{h as i}from"./network-error.js";import{f as u,h as s}from"./fetch-graphql } `,_=` query GET_ATTRIBUTES_FORM_SHORT { - attributesForm(formCode: "customer_register_address") { + attributesForm(formCode: "customer_register_address") { items { frontend_input label diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomer.js b/scripts/__dropins__/storefront-order/chunks/getCustomer.js deleted file mode 100644 index b6bcf17289..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/getCustomer.js +++ /dev/null @@ -1,11 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{h}from"./network-error.js";import{f,h as i}from"./fetch-graphql.js";import{a as O}from"./getGuestOrder.graphql.js";import{b as l}from"./transform-order-details.js";const T=(t,a)=>{var u,c;if(!((u=t==null?void 0:t.data)!=null&&u.guestOrder))return null;const r=(c=t==null?void 0:t.data)==null?void 0:c.guestOrder;return l(r,a)},k=(t,a)=>{var u,c;if(!((u=t==null?void 0:t.data)!=null&&u.guestOrderByToken))return null;const r=(c=t==null?void 0:t.data)==null?void 0:c.guestOrderByToken;return l(r,a)},g=t=>{var a,r,u,c,m,d;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:c.firstname)||"",lastname:((d=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:d.lastname)||""}},B=async t=>await f(O,{method:"GET",cache:"no-cache",variables:{input:t}}).then(a=>{var r;return(r=a.errors)!=null&&r.length?i(a.errors):T(a)}).catch(h),E=` - query GET_CUSTOMER { - customer { - firstname - lastname - email - } - } -`,C=async()=>await f(E,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?i(t.errors):g(t)}).catch(h);export{B as a,C as g,k as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js index 413fdd1530..2d67bd0baf 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js @@ -1,21 +1,21 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as R}from"./network-error.js";import{f as E,h as _}from"./fetch-graphql.js";import{R as T,P as o,a as s,G as c,O as u,t as h}from"./transform-order-details.js";const n=` -query GET_CUSTOMER_ORDERS_RETURN($pageSize: Int) { - customer { - returns(pageSize: $pageSize) { - page_info { - page_size - total_pages - current_page +import{h as R}from"./network-error.js";import{R as E,P as T,a as _,G as c,O as s,t as o}from"./initialize.js";import{f as n}from"./fetch-graphql.js";const u=` + query GET_CUSTOMER_ORDERS_RETURN($currentPage: Int, $pageSize: Int) { + customer { + returns(currentPage: $currentPage, pageSize: $pageSize) { + page_info { + page_size + total_pages + current_page + } + ...RETURNS_FRAGMENT + } } - ...OrderReturns } - } -} -${T} -${o} -${s} -${c} -${u} -`,G=async(e=10)=>await E(n,{method:"GET",cache:"force-cache",variables:{pageSize:e}}).then(r=>{var t,a;return(t=r.errors)!=null&&t.length?_(r.errors):h((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{G as g}; + ${E} + ${T} + ${_} + ${c} + ${s} +`,G=async(e=10,t=1)=>await n(u,{method:"GET",cache:"force-cache",variables:{pageSize:e,currentPage:t}}).then(r=>{var a;return o((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{G as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js deleted file mode 100644 index fd7bfbcd07..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js +++ /dev/null @@ -1,160 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{P as e,a as t,G as r,O as a,B as s,R as d}from"./transform-order-details.js";const n=` -fragment OrderSummary on OrderTotal { - grand_total { - value - currency - } - total_giftcard { - currency - value - } - subtotal { - currency - value - } - taxes { - amount { - currency - value - } - rate - title - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { - currency - value - } - label - } -}`,i=` -fragment AddressesList on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id -}`,o=` - fragment guestOrderData on CustomerOrder { - email - id - number - order_date - order_status_change_date - status - token - carrier - shipping_method - printed_card_included - gift_receipt_included - available_actions - is_virtual - items_eligible_for_return { - ...OrderItemDetails - } - returns { - ...OrderReturns - } - payment_methods { - name - type - } - applied_coupons { - code - } - shipments { - id - tracking { - title - number - carrier - } - comments { - message - timestamp - } - items { - __typename - id - product_sku - product_name - order_item { - ...OrderItemDetails - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - } - } - } - payment_methods { - name - type - } - shipping_address { - ...AddressesList - } - billing_address { - ...AddressesList - } - items { - ...OrderItemDetails - ... on BundleOrderItem { - ...BundleOrderItemDetails - } - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } - total { - ...OrderSummary - } - } -${e} -${t} -${r} -${a} -${s} -${n} -${i} -${d} -`,u=` - query GET_GUEST_ORDER($input: GuestOrderInformationInput!) { - guestOrder(input:$input) { - ...guestOrderData - } - } -${o} -`;export{i as A,o as G,n as O,u as a}; diff --git a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js new file mode 100644 index 0000000000..d7d2442923 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js @@ -0,0 +1,18 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{h as E}from"./network-error.js";import{f as i,h}from"./fetch-graphql.js";import{G as n}from"./GurestOrderFragment.graphql.js";import{f as o}from"./initialize.js";const G=t=>{var a,r,m,c,u,e;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:c.firstname)||"",lastname:((e=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:e.lastname)||""}},f=` + query GET_CUSTOMER { + customer { + firstname + lastname + email + } + } +`,_=async()=>await i(f,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?h(t.errors):G(t)}).catch(E),T=` + query GET_GUEST_ORDER($input: GuestOrderInformationInput!) { + guestOrder(input: $input) { + ...GUEST_ORDER_FRAGMENT + } + } + ${n} +`,S=async t=>await i(T,{method:"GET",cache:"no-cache",variables:{input:t}}).then(a=>o(a)).catch(E);export{S as a,_ as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js index 2bde8978d2..a164a243a7 100644 --- a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js @@ -1,18 +1,19 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{f as o,h as s}from"./fetch-graphql.js";function i(e){return e?{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 _=` -query STORE_CONFIG_QUERY { - storeConfig { - order_cancellation_enabled - order_cancellation_reasons { +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 _=` + query STORE_CONFIG_QUERY { + storeConfig { + order_cancellation_enabled + order_cancellation_reasons { description + } + base_media_url + orders_invoices_credit_memos_display_price + orders_invoices_credit_memos_display_shipping_amount + orders_invoices_credit_memos_display_subtotal + orders_invoices_credit_memos_display_grandtotal + orders_invoices_credit_memos_display_full_summary + orders_invoices_credit_memos_display_zero_tax } - orders_invoices_credit_memos_display_price - orders_invoices_credit_memos_display_shipping_amount - orders_invoices_credit_memos_display_subtotal - orders_invoices_credit_memos_display_grandtotal - orders_invoices_credit_memos_display_full_summary - orders_invoices_credit_memos_display_zero_tax } -} -`,c=async()=>o(_,{method:"GET",cache:"force-cache"}).then(({errors:e,data:r})=>e?s(e):i(r.storeConfig));export{c as g}; +`,l=async()=>s(_,{method:"GET",cache:"force-cache"}).then(({errors:e,data:r})=>e?i(e):o(r.storeConfig));export{l as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js new file mode 100644 index 0000000000..2510c9abfa --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -0,0 +1,407 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as q}from"@dropins/tools/event-bus.js";import{a as ta,h as Y}from"./network-error.js";import{f as Q}from"./fetch-graphql.js";const K=` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id + } +`,j=` + fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { + __typename + canonical_url + url_key + uid + name + sku + only_x_left_in_stock + stock_status + thumbnail { + label + url + } + price_range { + maximum_price { + regular_price { + currency + value + } + } + } + } +`,H=` + fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { + prices { + price_including_tax { + value + currency + } + original_price { + value + currency + } + original_price_including_tax { + value + currency + } + price { + value + currency + } + } + } +`,J=` + fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { + ...PRICE_DETAILS_FRAGMENT + gift_message { + message + } + gift_card { + recipient_name + recipient_email + sender_name + sender_email + message + } + } +`,V=` + fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { + __typename + status + product_sku + eligible_for_return + product_name + product_url_key + id + quantity_ordered + quantity_shipped + quantity_canceled + quantity_invoiced + quantity_refunded + quantity_return_requested + product_sale_price { + value + currency + } + selected_options { + label + value + } + product { + ...PRODUCT_DETAILS_FRAGMENT + } + ...PRICE_DETAILS_FRAGMENT + } +`,W=` + fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { + ...PRICE_DETAILS_FRAGMENT + bundle_options { + uid + label + values { + uid + product_name + } + } + } +`,X=` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + grand_total { + value + currency + } + total_giftcard { + currency + value + } + subtotal { + currency + value + } + taxes { + amount { + currency + value + } + rate + title + } + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value + } + label + } + } +`,Z=` + fragment RETURNS_FRAGMENT on Returns { + __typename + items { + number + status + created_at + shipping { + tracking { + status { + text + type + } + carrier { + uid + label + } + tracking_number + } + } + order { + number + token + } + items { + uid + quantity + status + request_quantity + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + } +`,_a=a=>a||0,ua=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)||""}}},ea=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},ia=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(e=>e.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},sa=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,la=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 E,c,r,O,d,g,N,M,A,D,u,y,T,p,S,f,o,G,h,F,C,L,k,U,B,$,P,m,w,x;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R}=la(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:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((O=(r=(c=(E=n==null?void 0:n.product)==null?void 0:E.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)!==((d=n==null?void 0:n.product_sale_price)==null?void 0:d.value)*(n==null?void 0:n.quantity_ordered),total:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.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:((y=n==null?void 0:n.product_sale_price)==null?void 0:y.value)||0,currency:(T=n==null?void 0:n.product_sale_price)==null?void 0:T.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(o=(f=(S=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:S.maximum_price)==null?void 0:f.regular_price)==null?void 0:o.value,currency:(C=(F=(h=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:h.maximum_price)==null?void 0:F.regular_price)==null?void 0:C.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((k=(L=n==null?void 0:n.product)==null?void 0:L.thumbnail)==null?void 0:k.label)||"",url:((B=(U=n==null?void 0:n.product)==null?void 0:U.thumbnail)==null?void 0:B.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:(($=n.gift_card)==null?void 0:$.sender_name)||"",senderEmail:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((m=n.gift_card)==null?void 0:m.recipient_email)||"",recipientName:((w=n.gift_card)==null?void 0:w.recipient_name)||"",message:((x=n.gift_card)==null?void 0:x.message)||""}:void 0,configurableOptions:ea(n),bundleOptions:n.__typename==="BundleOrderItem"?ia(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?sa(n==null?void 0:n.downloadable_links):null}}),v=(a,n)=>{var O,d,g,N,M,A,D,u,y;const t=I(a.items),_=((O=ra(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],e=n?_.filter(T=>T.returnNumber===n):_,{total:i,...s}=ta({...a,items:t,returns:e},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(d=a==null?void 0:a.payment_methods)==null?void 0:d[0],R=(l==null?void 0:l.type)||"",E=(l==null?void 0:l.name)||"",c=(g=s==null?void 0:s.items)==null?void 0:g.reduce((T,p)=>T+(p==null?void 0:p.totalQuantity),0),r={...i,...s,totalQuantity:c,shipping:{amount:((N=i==null?void 0:i.totalShipping)==null?void 0:N.value)??0,currency:((M=i==null?void 0:i.totalShipping)==null?void 0:M.currency)||"",code:s.shippingMethod??""},payments:[{code:R,name:E}]};return z(r,(y=(u=(D=(A=b==null?void 0:b.getConfig())==null?void 0:A.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:y.call(u,a))},ca=(a,n,t)=>{var _,e,i,s,l,R,E;if((s=(i=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:i.items)!=null&&s.length&&a==="orderData"){const c=(E=(R=(l=n==null?void 0:n.data)==null?void 0:l.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return v(c,t)}return null},ra=a=>{var i,s,l,R,E;if(!((i=a==null?void 0:a.items)!=null&&i.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,e={ordersReturn:[...n].sort((c,r)=>+r.number-+c.number).map(c=>{var A,D;const{order:r,status:O,number:d,created_at:g}=c,N=((D=(A=c==null?void 0:c.shipping)==null?void 0:A.tracking)==null?void 0:D.map(u=>{const{status:y,carrier:T,tracking_number:p}=u;return{status:y,carrier:T,trackingNumber:p}}))??[],M=c.items.map(u=>{var G;const y=u==null?void 0:u.quantity,T=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,S=u==null?void 0:u.uid,f=u==null?void 0:u.order_item,o=((G=I([f]))==null?void 0:G.reduce((h,F)=>F,{}))??{};return{uid:S,quantity:y,status:T,requestQuantity:p,...o}});return{createdReturnAt:g,returnStatus:O,token:r==null?void 0:r.token,orderNumber:r==null?void 0:r.number,returnNumber:d,items:M,tracking:N}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return z(e,(E=(R=(l=(s=b==null?void 0:b.getConfig())==null?void 0:s.models)==null?void 0:l.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Ma=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrder;return v(t,n)},Ra=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrderByToken;return v(t,n)},Ea=` + query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { + customer { + orders(filter: { number: { eq: $orderNumber } }) { + items { + email + available_actions + status + number + id + order_date + order_status_change_date + carrier + shipping_method + is_virtual + returns(pageSize: $pageSize) { + ...RETURNS_FRAGMENT + } + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + applied_coupons { + code + } + shipments { + id + number + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + id + product_sku + product_name + quantity_shipped + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + } + } + } + ${j} + ${H} + ${J} + ${V} + ${W} + ${X} + ${K} + ${Z} +`,Ta=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await Q(Ea,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(e=>ca(t??"orderData",e,n)).catch(Y),pa=` + query ORDER_BY_TOKEN($token: String!) { + guestOrderByToken(input: { token: $token }) { + email + id + number + order_date + order_status_change_date + status + token + carrier + shipping_method + printed_card_included + gift_receipt_included + available_actions + is_virtual + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + } + returns(pageSize: 50) { + ...RETURNS_FRAGMENT + } + payment_methods { + name + type + } + applied_coupons { + code + } + shipments { + id + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + } + ${j} + ${H} + ${J} + ${V} + ${W} + ${X} + ${K} + ${Z} +`,ya=async(a,n)=>await Q(pa,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>Ra(t,n)).catch(Y),Aa="orderData",Da=async a=>{var s;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"&&((s=a==null?void 0:a.orderRef)==null?void 0:s.length)>20,e=(a==null?void 0:a.orderData)??null;if(e){q.emit("order/data",{...e,returnNumber:t});return}if(!n)return;const i=_?await ya(n,t):await Ta({orderId:n,returnRef:t,queryType:Aa});i?q.emit("order/data",{...i,returnNumber:t}):q.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}),Da(a).catch(console.error)},listeners:()=>[]}),b=aa.config;export{K as A,W as B,J as G,V as O,j as P,Z as R,H as a,X as b,v as c,ya as d,b as e,Ma as f,Ta as g,aa as i,ra as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/network-error.js b/scripts/__dropins__/storefront-order/chunks/network-error.js index b7780a4913..92b148ebc6 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 o}from"@dropins/tools/event-bus.js";const s=r=>{throw r instanceof DOMException&&r.name==="AbortError"||o.emit("order/error",{source:"auth",type:"network",error:r.message}),r};export{s as h}; +import{events as a}from"@dropins/tools/event-bus.js";const b=r=>r.replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),i=r=>r.replace(/([A-Z])/g,o=>`_${o.toLowerCase()}`),u=(r,o,s)=>{const c=["string","boolean","number"],p=o==="camelCase"?b:i;return Array.isArray(r)?r.map(e=>c.includes(typeof e)||e===null?e:typeof e=="object"?u(e,o,s):e):r!==null&&typeof r=="object"?Object.entries(r).reduce((e,[n,t])=>{const f=s&&s[n]?s[n]:p(n);return e[f]=c.includes(typeof t)||t===null?t:u(t,o,s),e},{}):r},C=r=>{throw r instanceof DOMException&&r.name==="AbortError"||a.emit("order/error",{source:"auth",type:"network",error:r.message}),r};export{u as a,b as c,C as h}; diff --git a/scripts/__dropins__/storefront-order/chunks/reorderItems.js b/scripts/__dropins__/storefront-order/chunks/reorderItems.js index 00cd1961a1..adcf632ac6 100644 --- a/scripts/__dropins__/storefront-order/chunks/reorderItems.js +++ b/scripts/__dropins__/storefront-order/chunks/reorderItems.js @@ -1,20 +1,20 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ import{h as i}from"./network-error.js";import{f as E,h as I}from"./fetch-graphql.js";const s=` -mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { - reorderItems(orderNumber: $orderNumber) { - cart { - itemsV2 { - items { - uid + mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { + reorderItems(orderNumber: $orderNumber) { + cart { + itemsV2 { + items { + uid + } } } - } - userInputErrors{ - code - message - path + userInputErrors { + code + message + path + } } } -} `,l=async c=>await E(s,{method:"POST",variables:{orderNumber:c}}).then(r=>{var t,e,a,m,o,u;if((t=r.errors)!=null&&t.length)return I(r.errors);const d=!!((m=(a=(e=r==null?void 0:r.data)==null?void 0:e.reorderItems)==null?void 0:a.cart)!=null&&m.itemsV2.items.length),h=((u=(o=r==null?void 0:r.data)==null?void 0:o.reorderItems)==null?void 0:u.userInputErrors)??[];return{success:d,userInputErrors:h}}).catch(i);export{l as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js index e01dd91a6e..067577d243 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,99 +1,102 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{P as c,a as u,G as l,O as E,B as m,b as d}from"./transform-order-details.js";import{O,A as D,G as R}from"./getGuestOrder.graphql.js";import{f as i,h as _}from"./fetch-graphql.js";const T=` -mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { - cancelOrder(input: { order_id: $orderId, reason: $reason }) { - error - order { - email - available_actions - status - number - id - order_date - carrier - shipping_method - is_virtual - applied_coupons { - code - } - shipments { - id +import{P as d,a as T,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize.js";import{f as s,h as R}from"./fetch-graphql.js";import{G as O}from"./GurestOrderFragment.graphql.js";const G=` + mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { + cancelOrder(input: { order_id: $orderId, reason: $reason }) { + error + order { + email + available_actions + status number - tracking { - title - number - carrier - } - comments { - message - timestamp + id + order_date + carrier + shipping_method + is_virtual + applied_coupons { + code } - items { + shipments { id - product_sku - product_name - order_item { - ...OrderItemDetails - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails + number + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } } } } } - } - payment_methods { - name - type - } - shipping_address { - ...AddressesList - } - billing_address { - ...AddressesList - } - items { - ...OrderItemDetails - ... on BundleOrderItem { - ...BundleOrderItemDetails + payment_methods { + name + type } - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } + shipping_address { + ...ADDRESS_FRAGMENT } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } } } - } - total { - ...OrderSummary + total { + ...ORDER_SUMMARY_FRAGMENT + } } } } -} -${c} -${u} -${l} -${E} -${m} -${O} -${D} -`,G=async(r,e,s,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return i(T,{variables:{orderId:r,reason:e}}).then(({errors:a,data:o})=>{if(a)return _(a);if(o.cancelOrder.error!=null){t();return}const n=d(o.cancelOrder.order);s(n)}).catch(()=>t())},A=` -mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION($token: String!, $reason: String!) { - requestGuestOrderCancel(input: { token: $token, reason: $reason }) { - error - order { - ...guestOrderData + ${d} + ${T} + ${i} + ${A} + ${D} + ${c} + ${u} +`,M=async(r,e,n,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return s(G,{variables:{orderId:r,reason:e}}).then(({errors:o,data:a})=>{if(o)return R(o);if(a.cancelOrder.error!=null){t();return}const _=E(a.cancelOrder.order);n(_)}).catch(()=>t())},l=` + mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION( + $token: String! + $reason: String! + ) { + requestGuestOrderCancel(input: { token: $token, reason: $reason }) { + error + order { + ...guestOrderData + } } } -} -${R} -`,C=async(r,e,s,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return i(A,{variables:{token:r,reason:e}}).then(({errors:a,data:o})=>{if(a)return _(a);o.requestGuestOrderCancel.error!=null&&t();const n=d(o.requestGuestOrderCancel.order);s(n)}).catch(()=>t())};export{G as c,C as r}; + ${O} +`,S=async(r,e,n,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return s(l,{variables:{token:r,reason:e}}).then(({errors:o,data:a})=>{if(o)return R(o);a.requestGuestOrderCancel.error!=null&&t();const _=E(a.requestGuestOrderCancel.order);n(_)}).catch(()=>t())};export{M as c,S as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestReturn.js index 9d1c33e47d..cdc8685819 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/requestReturn.js @@ -1,6 +1,14 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as i}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql.js";import{t as R}from"./transform-attributes-form.js";import{a as c}from"./convertCase.js";const m=` +import{h as E,a as c}from"./network-error.js";import{f as m,h as _}from"./fetch-graphql.js";import{t as T}from"./transform-attributes-form.js";import{merge as d}from"@dropins/tools/lib.js";import{e as l}from"./initialize.js";const f=` + fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { + __typename + uid + status + number + created_at + } +`,h=t=>{var u,i,R,o,n,s;if(!((i=(u=t==null?void 0:t.data)==null?void 0:u.requestReturn)!=null&&i.return))return{};const{created_at:e,...r}=t.data.requestReturn.return,a={...r,createdAt:e};return d(a,(s=(n=(o=(R=l.getConfig())==null?void 0:R.models)==null?void 0:o.RequestReturnModel)==null?void 0:n.transformer)==null?void 0:s.call(n,t.data.requestReturn.return))},y=` query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { attributesList(entityType: $entityType) { items { @@ -33,20 +41,13 @@ import{h as i}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql } } } -`,f=async n=>await s(m,{method:"GET",cache:"force-cache",variables:{entityType:n}}).then(t=>{var e,r,a;return(e=t.errors)!=null&&e.length?o(t.errors):R((a=(r=t==null?void 0:t.data)==null?void 0:r.attributesList)==null?void 0:a.items)}).catch(i),_=` - fragment OrderReturn on Return { - __typename - uid - status - number - created_at - } -`,T=` -mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { - requestReturn(input: $input) { - return { - ...OrderReturn +`,N=async t=>await m(y,{method:"GET",cache:"force-cache",variables:{entityType:t}}).then(e=>{var r,a,u;return(r=e.errors)!=null&&r.length?_(e.errors):T((u=(a=e==null?void 0:e.data)==null?void 0:a.attributesList)==null?void 0:u.items)}).catch(E),b=` + mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { + requestReturn(input: $input) { + return { + ...REQUEST_RETURN_ORDER_FRAGMENT + } } } -} -${_}`,y=async n=>{const t=c(n,"snakeCase",{});return await s(T,{method:"POST",variables:{input:t}}).then(e=>{var u;if((u=e.errors)!=null&&u.length)return o(e.errors);const{created_at:r,...a}=e.data.requestReturn.return;return{...a,createdAt:r}}).catch(i)};export{f as g,y as r}; + ${f} +`,p=async t=>{const e=c(t,"snakeCase",{});return await m(b,{method:"POST",variables:{input:e}}).then(r=>{var a;return(a=r.errors)!=null&&a.length?_(r.errors):h(r)}).catch(E)};export{N as g,p as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js b/scripts/__dropins__/storefront-order/chunks/transform-attributes-form.js index ee0f7dcf66..19aed95cc1 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"./convertCase.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}; +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}; diff --git a/scripts/__dropins__/storefront-order/chunks/transform-order-details.js b/scripts/__dropins__/storefront-order/chunks/transform-order-details.js deleted file mode 100644 index 5097738f53..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/transform-order-details.js +++ /dev/null @@ -1,142 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{a as z}from"./convertCase.js";const d=` - fragment ProductDetails on ProductInterface { - __typename - canonical_url - url_key - uid - name - sku - only_x_left_in_stock - stock_status - thumbnail { - label - url - } - price_range { - maximum_price { - regular_price { - currency - value - } - } - } - } -`,r=` - fragment PriceDetails on OrderItemInterface { - prices { - price_including_tax { - value - currency - } - original_price { - value - currency - } - original_price_including_tax { - value - currency - } - price { - value - currency - } - } - } -`,m=` - fragment GiftCardDetails on GiftCardOrderItem { - ...PriceDetails - gift_message { - message - } - gift_card { - recipient_name - recipient_email - sender_name - sender_email - message - } - } -`,I=` - fragment OrderItemDetails on OrderItemInterface { - __typename - status - product_sku - eligible_for_return - product_name - product_url_key - id - quantity_ordered - quantity_shipped - quantity_canceled - quantity_invoiced - quantity_refunded - quantity_return_requested - product_sale_price { - value - currency - } - selected_options { - label - value - } - product { - ...ProductDetails - } - ...PriceDetails - } -`,nn=` - fragment BundleOrderItemDetails on BundleOrderItem { - ...PriceDetails - bundle_options { - uid - label - values { - uid - product_name - } - } - } -`,an=` - fragment OrderReturns on Returns { - __typename - items { - number - status - created_at - shipping { - tracking { - status { - text - type - } - carrier { - uid - label - } - tracking_number - } - } - order { - number - token - } - items { - uid - quantity - status - request_quantity - order_item { - ...OrderItemDetails - ... on GiftCardOrderItem { - ...GiftCardDetails - product { - ...ProductDetails - } - } - } - } - } - } -`,H=a=>{var t;if(!((t=a==null?void 0:a.items)!=null&&t.length))return null;const n=a==null?void 0:a.items,s=a==null?void 0:a.page_info;return{ordersReturn:[...n].sort((l,u)=>+u.number-+l.number).map(l=>{var q,R;const{order:u,status:_,number:e,created_at:y}=l,b=((R=(q=l==null?void 0:l.shipping)==null?void 0:q.tracking)==null?void 0:R.map(i=>{const{status:p,carrier:g,tracking_number:f}=i;return{status:p,carrier:g,trackingNumber:f}}))??[],h=l.items.map(i=>{var E;const p=i==null?void 0:i.quantity,g=i==null?void 0:i.status,f=i==null?void 0:i.request_quantity,v=i==null?void 0:i.uid,O=i==null?void 0:i.order_item,N=((E=K([O]))==null?void 0:E.reduce((T,k)=>k,{}))??{};return{uid:v,quantity:p,status:g,requestQuantity:f,...N}});return{createdReturnAt:y,returnStatus:_,token:u==null?void 0:u.token,orderNumber:u==null?void 0:u.number,returnNumber:e,items:h,tracking:b}}),...s?{pageInfo:{pageSize:s.page_size,totalPages:s.total_pages,currentPage:s.current_page}}:{}}},J=a=>a||0,V=a=>{var n,s,c;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:((s=a==null?void 0:a.thumbnail)==null?void 0:s.label)||"",url:((c=a==null?void 0:a.thumbnail)==null?void 0:c.url)||""}}},W=a=>{if(!a||!("selected_options"in a))return;const n={};for(const s of a.selected_options)n[s.label]=s.value;return n},X=a=>{const n=a==null?void 0:a.map(c=>({uid:c.uid,label:c.label,values:c.values.map(t=>t.product_name).join(", ")})),s={};return n==null||n.forEach(c=>{s[c.label]=c.values}),Object.keys(s).length>0?s:null},Y=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,Z=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}),K=a=>a==null?void 0:a.filter(n=>n.__typename).map(n=>{var y,b,h,q,R,i,p,g,f,v,O,N,E,T,k,C,D,P,A,G,S,x,L,F,M,B,Q,U,j,w;const{quantityCanceled:s,quantityInvoiced:c,quantityOrdered:t,quantityRefunded:l,quantityReturned:u,quantityShipped:_,quantityReturnRequested:e}=Z(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:s,quantityInvoiced:c,quantityOrdered:t,quantityRefunded:l,quantityReturned:u,quantityShipped:_,quantityReturnRequested:e,id:n==null?void 0:n.id,discounted:((q=(h=(b=(y=n==null?void 0:n.product)==null?void 0:y.price_range)==null?void 0:b.maximum_price)==null?void 0:h.regular_price)==null?void 0:q.value)*(n==null?void 0:n.quantity_ordered)!==((R=n==null?void 0:n.product_sale_price)==null?void 0:R.value)*(n==null?void 0:n.quantity_ordered),total:{value:((i=n==null?void 0:n.product_sale_price)==null?void 0:i.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((p=n==null?void 0:n.product_sale_price)==null?void 0:p.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:(f=n==null?void 0:n.product_sale_price)==null?void 0:f.currency},price:{value:((v=n==null?void 0:n.product_sale_price)==null?void 0:v.value)||0,currency:(O=n==null?void 0:n.product_sale_price)==null?void 0:O.currency},priceInclTax:{value:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.value)||0,currency:(E=n==null?void 0:n.product_sale_price)==null?void 0:E.currency},totalQuantity:J(n==null?void 0:n.quantity_ordered),regularPrice:{value:(D=(C=(k=(T=n==null?void 0:n.product)==null?void 0:T.price_range)==null?void 0:k.maximum_price)==null?void 0:C.regular_price)==null?void 0:D.value,currency:(S=(G=(A=(P=n==null?void 0:n.product)==null?void 0:P.price_range)==null?void 0:A.maximum_price)==null?void 0:G.regular_price)==null?void 0:S.currency},product:V(n==null?void 0:n.product),thumbnail:{label:((L=(x=n==null?void 0:n.product)==null?void 0:x.thumbnail)==null?void 0:L.label)||"",url:((M=(F=n==null?void 0:n.product)==null?void 0:F.thumbnail)==null?void 0:M.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:((B=n.gift_card)==null?void 0:B.sender_name)||"",senderEmail:((Q=n.gift_card)==null?void 0:Q.sender_email)||"",recipientEmail:((U=n.gift_card)==null?void 0:U.recipient_email)||"",recipientName:((j=n.gift_card)==null?void 0:j.recipient_name)||"",message:((w=n.gift_card)==null?void 0:w.message)||""}:void 0,configurableOptions:W(n),bundleOptions:n.__typename==="BundleOrderItem"?X(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?Y(n==null?void 0:n.downloadable_links):null}}),$=(a,n)=>{var q,R,i,p,g,f;const s=K(a.items),c=((q=H(a==null?void 0:a.returns))==null?void 0:q.ordersReturn)??[],t=n?c.filter(v=>v.returnNumber===n):c,{total:l,...u}=z({...a,items:s,returns:t},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),_=(R=a==null?void 0:a.payment_methods)==null?void 0:R[0],e=(_==null?void 0:_.type)||"",y=(_==null?void 0:_.name)||"",b=(i=u==null?void 0:u.items)==null?void 0:i.reduce((v,O)=>v+(O==null?void 0:O.totalQuantity),0);return{...l,...u,totalQuantity:b,shipping:{amount:((p=u==null?void 0:u.total)==null?void 0:p.totalShipping.value)??0,currency:((f=(g=u.total)==null?void 0:g.totalShipping)==null?void 0:f.currency)||"",code:u.shippingMethod??""},payments:[{code:e,name:y}]}},un=(a,n,s)=>{var c,t,l,u,_,e,y;if((u=(l=(t=(c=n==null?void 0:n.data)==null?void 0:c.customer)==null?void 0:t.orders)==null?void 0:l.items)!=null&&u.length&&a==="orderData"){const b=(y=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:y.items[0];return $(b,s)}return null};export{nn as B,m as G,I as O,d as P,an as R,r as a,$ as b,un as c,H as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js b/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js new file mode 100644 index 0000000000..4398ad0c43 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/useGetStoreConfig.js @@ -0,0 +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}; diff --git a/scripts/__dropins__/storefront-order/components/OrderHeader/OrderHeader.d.ts b/scripts/__dropins__/storefront-order/components/OrderHeader/OrderHeader.d.ts new file mode 100644 index 0000000000..52b21f7f41 --- /dev/null +++ b/scripts/__dropins__/storefront-order/components/OrderHeader/OrderHeader.d.ts @@ -0,0 +1,9 @@ +import { FunctionComponent } from 'preact'; + +export interface OrderHeaderProps { + customerName?: string; + onSignUpClick?: () => void; + orderNumber: string; +} +export declare const OrderHeader: FunctionComponent; +//# sourceMappingURL=OrderHeader.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/OrderHeader/index.d.ts b/scripts/__dropins__/storefront-order/components/OrderHeader/index.d.ts new file mode 100644 index 0000000000..17a315206a --- /dev/null +++ b/scripts/__dropins__/storefront-order/components/OrderHeader/index.d.ts @@ -0,0 +1,2 @@ +export * from './OrderHeader'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/OrderLoaders/OrderLoaders.d.ts b/scripts/__dropins__/storefront-order/components/OrderLoaders/OrderLoaders.d.ts index d24057df04..18ebf55c54 100644 --- a/scripts/__dropins__/storefront-order/components/OrderLoaders/OrderLoaders.d.ts +++ b/scripts/__dropins__/storefront-order/components/OrderLoaders/OrderLoaders.d.ts @@ -6,4 +6,5 @@ export declare const CardLoader: ({ testId, withCard, }: { export declare const DetailsSkeleton: (props: any) => import("preact").JSX.Element; export declare const OrderProductListSkeleton: () => import("preact").JSX.Element; export declare const OrderSummarySkeleton: () => import("preact").JSX.Element; +export declare const OrderHeaderSkeleton: () => import("preact").JSX.Element; //# sourceMappingURL=OrderLoaders.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/index.d.ts b/scripts/__dropins__/storefront-order/components/index.d.ts index 1960b8b54f..b27b68b1a2 100644 --- a/scripts/__dropins__/storefront-order/components/index.d.ts +++ b/scripts/__dropins__/storefront-order/components/index.d.ts @@ -1,17 +1,18 @@ -export * from './OrderSearchForm'; -export * from './Form'; -export * from './OrderStatusContent'; -export * from './ShippingStatusCard'; -export * from './OrderLoaders'; -export * from './OrderActions'; export * from './CustomerDetailsContent'; export * from './EmptyList'; -export * from './ReturnsListContent'; -export * from './OrderProductListContent'; +export * from './Form'; +export * from './OrderActions'; +export * from './OrderCancel'; export * from './OrderCostSummaryContent'; -export * from './ReturnOrderProductList'; +export * from './OrderHeader'; +export * from './OrderLoaders'; +export * from './OrderProductListContent'; +export * from './OrderSearchForm'; +export * from './OrderStatusContent'; +export * from './Reorder'; export * from './ReturnOrderMessage'; +export * from './ReturnOrderProductList'; export * from './ReturnReasonForm'; -export * from './OrderCancel'; -export * from './Reorder'; +export * from './ReturnsListContent'; +export * from './ShippingStatusCard'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts index f66c00d6bb..ba35296ddc 100644 --- a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts +++ b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts @@ -405,6 +405,7 @@ export declare const transformMockOrderOutput: { availableActions: string[]; status: string; number: string; + email: string; id: string; orderDate: string; carrier: string; @@ -544,6 +545,54 @@ export declare const transformMockOrderOutput: { recipientName: string; }; id: undefined; + selectedOptions?: undefined; + } | { + type: string; + id: string; + giftCard: undefined; + discounted: boolean; + total: { + value: number; + currency: string; + }; + totalInclTax: { + value: number; + currency: string; + }; + price: { + value: number; + currency: string; + }; + priceInclTax: { + value: number; + currency: string; + }; + totalQuantity: number; + regularPrice: { + value: number; + currency: string; + }; + product: { + canonicalUrl: string; + id: string; + name: string; + sku: string; + image: string; + productType: string; + thumbnail: { + label: string; + url: string; + }; + }; + thumbnail: { + label: string; + url: string; + }; + configurableOptions: { + Size?: undefined; + Color?: undefined; + }; + selectedOptions?: undefined; } | { type: string; id: string; @@ -570,6 +619,10 @@ export declare const transformMockOrderOutput: { value: number; currency: string; }; + selectedOptions: { + label: string; + value: string; + }[]; product: { canonicalUrl: string; id: string; @@ -636,6 +689,7 @@ export declare const transformMockOrderOutput: { Size: string; Color: string; }; + selectedOptions?: undefined; })[]; totalQuantity: number; shipping: { @@ -3658,4 +3712,17 @@ export declare const customerReturnDetailsFullMock: { })[]; }; }; +export declare const storeConfigMock: { + baseMediaUrl: string; + orderCancellationEnabled: boolean; + orderCancellationReasons: { + description: string; + }[]; + shoppingCartDisplayPrice: number; + shoppingOrdersDisplaySubtotal: number; + shoppingOrdersDisplayShipping: number; + shoppingOrdersDisplayGrandTotal: boolean; + shoppingOrdersDisplayFullSummary: boolean; + shoppingOrdersDisplayZeroTax: boolean; +}; //# sourceMappingURL=mock.config.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index 69a4351032..8f7909990e 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 x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as A,Slot as q}from"@dropins/tools/lib.js";import{Icon as B,Checkbox as P,Button as Q,CartItem as H,Image as $,Header as W,InLineAlert as j}from"@dropins/tools/components.js";import{u as V,a as Z}from"../chunks/OrderCancel.js";import{useState as v,useRef as D,useEffect as T,useCallback as F}from"@dropins/tools/preact-hooks.js";import{events as z}from"@dropins/tools/event-bus.js";import{s as U}from"../chunks/setTaxStatus.js";import{createRef as G,Fragment as J}from"@dropins/tools/preact.js";import{s as K,p as X,r as Y,m as I}from"../chunks/returnOrdersHelper.js";import{g as ee,r as te}from"../chunks/requestReturn.js";import{g as ne}from"../chunks/getStoreConfig.js";import*as R from"@dropins/tools/preact-compat.js";import{S as re,C as se}from"../chunks/CartSummaryItem.js";import{a as ae}from"../chunks/OrderLoaders.js";import{useText as ie}from"@dropins/tools/i18n.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-attributes-form.js";import"../chunks/convertCase.js";const ce=s=>R.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},R.createElement("g",{clipPath:"url(#clip0_841_1324)"},R.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),R.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"})),R.createElement("defs",null,R.createElement("clipPath",{id:"clip0_841_1324"},R.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ue=s=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},R.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"}),R.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),oe=({onSuccess:s,onError:a,handleSetInLineAlert:i,orderData:h})=>{const[m,l]=v({id:"",email:"",...h}),[L,g]=v("products"),[_,f]=v(!0),[c,b]=v([]),[k,y]=v([]),[t,C]=v({taxIncluded:!1,taxExcluded:!1}),[e,u]=v([]),p=D([]);p.current.length!==c.length&&(p.current=c.map((n,o)=>p.current[o]||G())),T(()=>{const n=z.on("order/data",o=>{l(o);const O=K(o);u(O),f(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),T(()=>{ne().then(n=>{if(!n)return;const o=U(n==null?void 0:n.shoppingCartDisplayPrice);C(o)})},[]),T(()=>{ee("RMA_ITEM").then(n=>{n!=null&&n.length&&(y(n),f(!1))})},[]);const E=F(n=>{b(o=>o.findIndex(d=>(d==null?void 0:d.productSku)===(n==null?void 0:n.productSku))>-1?o.filter(d=>(d==null?void 0:d.productSku)!==(n==null?void 0:n.productSku)):[...o,n])},[]),S=F(n=>{g(n),i(),n==="products"&&b([])},[i]),N=F((n,o)=>{const O=c.map(d=>d.productSku===o?{...d,currentReturnOrderQuantity:n}:d);b(O)},[c]),w=F(async(n,o)=>{if(!o)return;f(!0);const O={orderUid:m.id,contactEmail:m.email},d=X(p);te({...O,items:d}).then(M=>{s==null||s(M),S("success"),i()}).catch(M=>{a==null||a(M.message),i({type:"error",heading:M.message})}),f(!1)},[S,a,s,i,m]);return{order:m,steps:L,loading:_,formsRef:p,taxConfig:t,attributesList:k,selectedProductList:c,itemsEligibleForReturn:e,handleSelectedProductList:E,handleSetQuantity:N,handleChangeStep:S,onSubmit:w}},le={success:ue,warning:ce,error:re},de=()=>{const[s,a]=v({type:"success",heading:""}),i=F(h=>{if(!(h!=null&&h.type)){a({type:"success",heading:""});return}const m=r(B,{source:le[h.type]});a({...h,icon:m})},[]);return{inLineAlertProps:s,handleSetInLineAlert:i}},pe=({itemsEligibleForReturn:s,slots:a,loading:i,taxConfig:h,translations:m,selectedProductList:l,handleSelectedProductList:L,showConfigurableOptions:g,handleSetQuantity:_,handleChangeStep:f})=>x("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((c,b)=>{const{quantityReturnRequested:k,quantityShipped:y,eligibleForReturn:t}=c,C=l.some(p=>(p==null?void 0:p.productSku)===c.productSku&&c.eligibleForReturn),e=y===k&&t,u=y-k===0?k:y-k;return x("li",{className:A(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(P,{"data-testid":`key_${b}`,name:`key_${b}`,checked:C,disabled:e,onChange:()=>{L({...c,currentReturnOrderQuantity:1})}}),r(se,{loading:i,product:{...c,totalQuantity:u},itemType:"",taxConfig:h,translations:m,showConfigurableOptions:g,disabledIncrementer:!C,onQuantity:u>1?p=>{_(p,c.productSku)}:void 0}),r(q,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:a==null?void 0:a.ReturnOrderItem})]},c.id)}),r("li",{className:"order-return-order-product-list__item",children:r(Q,{type:"button",onClick:()=>f("attributes"),disabled:!l.length,children:m.nextStep})})]}),he=({routeReturnSuccess:s,translations:a,orderData:i})=>x("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:a.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:a.successMessage}),r(Q,{href:(s==null?void 0:s(i))??"#",children:a.backStore})]}),me=({slots:s,formsRef:a,selectedProductList:i,loading:h,fieldsConfig:m,translations:l,handleChangeStep:L,onSubmit:g})=>{const{formData:_,errors:f,formRef:c,handleChange:b,handleBlur:k,handleSubmit:y}=V({fieldsConfig:Y(m,i==null?void 0:i.length),onSubmit:g});return x("form",{className:"order-return-reason-form",ref:c,onSubmit:y,name:"returnReasonForm",children:[i.map((t,C)=>{var w,n,o,O,d;const e=t==null?void 0:t.giftCard,u=t==null?void 0:t.product,p=I(m,C),E=`${t==null?void 0:t.id}_${C}`,S=(t==null?void 0:t.currentReturnOrderQuantity)??1,N={...t!=null&&t.currentReturnOrderQuantity?{[l.configurationsListQuantity]:S}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[l.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[l.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[l.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[l.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[l.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(w=t==null?void 0:t.downloadableLinks)==null?void 0:w.count} ${l.downloadableCount}`]:(n=t==null?void 0:t.downloadableLinks)==null?void 0:n.result}:{}};return x(J,{children:[r(H,{loading:h,title:r("div",{"data-testid":"product-name",children:(o=t==null?void 0:t.product)==null?void 0:o.name}),sku:r("div",{children:u==null?void 0:u.sku}),image:r($,{src:((O=u==null?void 0:u.thumbnail)==null?void 0:O.url)??"",alt:((d=u==null?void 0:u.thumbnail)==null?void 0:d.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:N}),r("form",{name:E,ref:a==null?void 0:a.current[C],"data-quantity":S,children:r(Z,{className:"className",loading:h,fields:p,onChange:b,onBlur:k,errors:f,values:_})})]},t.id)}),r(q,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:L},children:x("div",{className:"order-return-reason-form__actions",children:[r(Q,{variant:"secondary",type:"button",onClick:()=>{L("products")},children:l.backStep}),r(Q,{children:l.submit})]})})]})},Ae=({className:s,orderData:a,slots:i,onSuccess:h,onError:m,routeReturnSuccess:l,showConfigurableOptions:L})=>{const g=ie({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:_,handleSetInLineAlert:f}=de(),{order:c,itemsEligibleForReturn:b,formsRef:k,taxConfig:y,attributesList:t,steps:C,loading:e,selectedProductList:u,handleSelectedProductList:p,handleSetQuantity:E,handleChangeStep:S,onSubmit:N}=oe({orderData:a,onSuccess:h,onError:m,handleSetInLineAlert:f});if(e)return r("div",{children:r(ae,{})});if(!e&&!t.length)return r("div",{});const w={products:r(pe,{itemsEligibleForReturn:b,slots:i,translations:g,loading:e,taxConfig:y,selectedProductList:u,handleSelectedProductList:p,showConfigurableOptions:L,handleSetQuantity:E,handleChangeStep:S}),attributes:r(me,{slots:i,formsRef:k,loading:e,fieldsConfig:t,selectedProductList:u,handleChangeStep:S,translations:g,onSubmit:N}),success:r(he,{translations:g,routeReturnSuccess:l,orderData:c}),error:null};return x("div",{className:A(["order-create-return",s]),children:[r(W,{title:g.headerText}),_.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",..._}):null,w[C]]})};export{Ae as CreateReturn,Ae as default}; +import{jsx as r,jsxs as x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as P}from"@dropins/tools/lib.js";import{Icon as H,Header as $,InLineAlert as W,Button as F,Checkbox as j,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as q,useCallback as E}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as C from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import{createRef as J,Fragment as K}from"@dropins/tools/preact.js";import{s as X,p as Y,r as I,m as ee}from"../chunks/returnOrdersHelper.js";import{events as te}from"@dropins/tools/event-bus.js";import{g as ne,r as re}from"../chunks/requestReturn.js";import{s as se}from"../chunks/setTaxStatus.js";import{S as ae,C as ce}from"../chunks/CartSummaryItem.js";import{a as ie}from"../chunks/OrderLoaders.js";import{useText as ue}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"../chunks/initialize.js";const oe=a=>C.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},C.createElement("g",{clipPath:"url(#clip0_841_1324)"},C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),C.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"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_841_1324"},C.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),le=a=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},C.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"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),de=({onSuccess:a,onError:s,handleSetInLineAlert:c,orderData:l})=>{const[g,O]=w({id:"",email:"",...l}),[d,f]=w("products"),[L,k]=w(!0),[p,m]=w([]),[_,R]=w([]),[y,t]=w([]),u=D([]);u.current.length!==p.length&&(u.current=p.map((n,o)=>u.current[o]||J())),q(()=>{const n=te.on("order/data",o=>{O(o);const S=X(o);t(S),k(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),q(()=>{ne("RMA_ITEM").then(n=>{n!=null&&n.length&&(R(n),k(!1))})},[]);const e=E(n=>{m(o=>o.findIndex(h=>(h==null?void 0:h.productSku)===(n==null?void 0:n.productSku))>-1?o.filter(h=>(h==null?void 0:h.productSku)!==(n==null?void 0:n.productSku)):[...o,n])},[]),i=E(n=>{f(n),c(),n==="products"&&m([])},[c]),b=E((n,o)=>{const S=p.map(h=>h.productSku===o?{...h,currentReturnOrderQuantity:n}:h);m(S)},[p]),N=E(async(n,o)=>{if(!o)return;k(!0);const S={orderUid:g.id,contactEmail:g.email},h=Y(u);re({...S,items:h}).then(v=>{a==null||a(v),i("success"),c()}).catch(v=>{s==null||s(v.message),c({type:"error",heading:v.message})}),k(!1)},[i,s,a,c,g]);return{order:g,steps:d,loading:L,formsRef:u,attributesList:_,selectedProductList:p,itemsEligibleForReturn:y,handleSelectedProductList:e,handleSetQuantity:b,handleChangeStep:i,onSubmit:N}},pe={success:le,warning:oe,error:ae},he=()=>{const[a,s]=w({type:"success",heading:""}),c=E(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const g=r(H,{source:pe[l.type]});s({...l,icon:g})},[]);return{inLineAlertProps:a,handleSetInLineAlert:c}},Pe=({className:a,orderData:s,slots:c,onSuccess:l,onError:g,routeReturnSuccess:O,showConfigurableOptions:d})=>{const f=ue({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:L,handleSetInLineAlert:k}=he(),p=G(),{order:m,itemsEligibleForReturn:_,formsRef:R,attributesList:y,steps:t,loading:u,selectedProductList:e,handleSelectedProductList:i,handleSetQuantity:b,handleChangeStep:N,onSubmit:n}=de({orderData:s,onSuccess:l,onError:g,handleSetInLineAlert:k});if(u)return r("div",{children:r(ie,{})});if(!u&&!y.length)return r("div",{});const o=(p==null?void 0:p.baseMediaUrl)??"",S={products:r(ge,{itemsEligibleForReturn:_,placeholderImage:o,taxConfig:se((p==null?void 0:p.shoppingCartDisplayPrice)??0),slots:c,translations:f,loading:u,selectedProductList:e,handleSelectedProductList:i,showConfigurableOptions:d,handleSetQuantity:b,handleChangeStep:N}),attributes:r(fe,{placeholderImage:o,slots:c,formsRef:R,loading:u,fieldsConfig:y,selectedProductList:e,handleChangeStep:N,translations:f,onSubmit:n}),success:r(me,{translations:f,routeReturnSuccess:O,orderData:m}),error:null};return x("div",{className:B(["order-create-return",a]),children:[r($,{title:f.headerText}),L.heading?r(W,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...L}):null,S[t]]})},me=({routeReturnSuccess:a,translations:s,orderData:c})=>x("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(F,{href:(a==null?void 0:a(c))??"#",children:s.backStore})]}),ge=({placeholderImage:a,itemsEligibleForReturn:s,slots:c,loading:l,taxConfig:g,translations:O,selectedProductList:d,handleSelectedProductList:f,showConfigurableOptions:L,handleSetQuantity:k,handleChangeStep:p})=>x("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((m,_)=>{const{quantityReturnRequested:R,quantityShipped:y,eligibleForReturn:t}=m,u=d.some(b=>(b==null?void 0:b.productSku)===m.productSku&&m.eligibleForReturn),e=y===R&&t,i=y-R===0?R:y-R;return x("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(j,{"data-testid":`key_${_}`,name:`key_${_}`,checked:u,disabled:e,onChange:()=>{f({...m,currentReturnOrderQuantity:1})}}),r(ce,{placeholderImage:a,loading:l,product:{...m,totalQuantity:i},itemType:"",taxConfig:g,translations:O,showConfigurableOptions:L,disabledIncrementer:!u,onQuantity:i>1?b=>{k(b,m.productSku)}:void 0}),r(P,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:c==null?void 0:c.ReturnOrderItem})]},m.id)}),r("li",{className:"order-return-order-product-list__item",children:r(F,{type:"button",onClick:()=>p("attributes"),disabled:!d.length,children:O.nextStep})})]}),fe=({placeholderImage:a,slots:s,formsRef:c,selectedProductList:l,loading:g,fieldsConfig:O,translations:d,handleChangeStep:f,onSubmit:L})=>{const{formData:k,errors:p,formRef:m,handleChange:_,handleBlur:R,handleSubmit:y}=U({fieldsConfig:I(O,l==null?void 0:l.length),onSubmit:L});return x("form",{className:"order-return-reason-form",ref:m,onSubmit:y,name:"returnReasonForm",children:[l.map((t,u)=>{var h,v,M,Q,A,T;const e=t==null?void 0:t.giftCard,i=t==null?void 0:t.product,b=ee(O,u),N=`${t==null?void 0:t.id}_${u}`,n=(t==null?void 0:t.currentReturnOrderQuantity)??1,o={...t!=null&&t.currentReturnOrderQuantity?{[d.configurationsListQuantity]:n}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[d.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[d.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[d.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[d.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[d.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(h=t==null?void 0:t.downloadableLinks)==null?void 0:h.count} ${d.downloadableCount}`]:(v=t==null?void 0:t.downloadableLinks)==null?void 0:v.result}:{}},S=(Q=(M=i==null?void 0:i.thumbnail)==null?void 0:M.url)!=null&&Q.length?i.thumbnail.url:a;return x(K,{children:[r(V,{loading:g,title:r("div",{"data-testid":"product-name",children:(A=t==null?void 0:t.product)==null?void 0:A.name}),sku:r("div",{children:i==null?void 0:i.sku}),image:r(Z,{src:S,alt:((T=i==null?void 0:i.thumbnail)==null?void 0:T.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:o}),r("form",{name:N,ref:c==null?void 0:c.current[u],"data-quantity":n,children:r(z,{className:"className",loading:g,fields:b,onChange:_,onBlur:R,errors:p,values:k})})]},t.id)}),r(P,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:f},children:x("div",{className:"order-return-reason-form__actions",children:[r(F,{variant:"secondary",type:"button",onClick:()=>{f("products")},children:d.backStep}),r(F,{children:d.submit})]})})]})};export{Pe as CreateReturn,Pe as default}; diff --git a/scripts/__dropins__/storefront-order/containers/CustomerDetails.js b/scripts/__dropins__/storefront-order/containers/CustomerDetails.js index 5e65d42237..75f96d413f 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{useState as k,useEffect as E,useCallback as B,useMemo as S}from"@dropins/tools/preact-hooks.js";import{events as z}from"@dropins/tools/event-bus.js";import{c as F}from"../chunks/convertCase.js";import{g as q}from"../chunks/getAttributesForm.js";import"@dropins/tools/preact.js";import{Icon as K,Price as G,Card as J,Header as Q}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import*as u from"@dropins/tools/preact-compat.js";import{f as U}from"../chunks/returnOrdersHelper.js";import{f as X}from"../chunks/formatDateToLocale.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/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})),oe=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],ie=({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:oe.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}},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}`))},se=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!==""}},ce=({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}=se(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,$]})]})},Ne=({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}=ie({orderData:e});return r("div",{className:_(["order-customer-details",d]),children:r(ce,{slots:o,loading:g,order:t,title:m,paymentIconsMap:i,normalizeAddress:l,translations:s})})};export{Ne as CustomerDetails,Ne as default}; +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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js index aa5ede1190..a148b2ddf6 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";import"../chunks/getGuestOrder.graphql.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";export{C as OrderCancelForm,F as default}; +import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/initialize.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/GurestOrderFragment.graphql.js";export{C as OrderCancelForm,F as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js index 5e15d76563..b949cc7d36 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{jsxs as i,jsx as c,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{classes as H}from"@dropins/tools/lib.js";import{useState as g,useEffect as T}from"@dropins/tools/preact-hooks.js";import{events as V}from"@dropins/tools/event-bus.js";import{s as C}from"../chunks/setTaxStatus.js";import{g as N}from"../chunks/getStoreConfig.js";import"@dropins/tools/preact.js";import{Price as d,Icon as f,Accordion as b,AccordionSection as E,Card as D,Header as k}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import*as x from"@dropins/tools/preact-compat.js";import{O as z}from"../chunks/OrderLoaders.js";import{useText as B}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const I=e=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),A=e=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),$=e=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.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"})),j=({orderData:e})=>{const[a,t]=g(!0),[n,l]=g(e),[r,m]=g(null);return T(()=>{N().then(u=>{if(u){const{shoppingCartDisplayPrice:o,shoppingOrdersDisplayShipping:s,shoppingOrdersDisplaySubtotal:y,...h}=u;m(p=>({...p,...h,shoppingCartDisplayPrice:C(o),shoppingOrdersDisplayShipping:C(s),shoppingOrdersDisplaySubtotal:C(y)}))}}).finally(()=>{t(!1)})},[]),T(()=>{const u=V.on("order/data",o=>{l(o)},{eager:!0});return()=>{u==null||u.off()}},[]),{loading:a,storeConfig:r,order:n}},P=({translations:e,order:a,subTotalValue:t,shoppingOrdersDisplaySubtotal:n})=>{var l,r;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(l=a==null?void 0:a.subtotal)==null?void 0:l.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:e.incl}):null,n.taxExcluded&&n.taxIncluded?i(S,{children:[c(d,{currency:(r=a==null?void 0:a.subtotal)==null?void 0:r.currency,amount:t,size:"small"})," ",c("span",{children:e.excl})]}):null]})]})},W=({translations:e,shoppingOrdersDisplayShipping:a,order:t,totalShipping:n})=>{var l,r,m,u;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:e.shipping}),(l=t==null?void 0:t.totalShipping)!=null&&l.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:e.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[a.taxIncluded&&a.taxExcluded?i(S,{children:[c(d,{weight:"normal",currency:(m=t==null?void 0:t.totalShipping)==null?void 0:m.currency,amount:(u=t==null?void 0:t.totalShipping)==null?void 0:u.value,size:"small"}),i("span",{children:[" ",e.excl]})]}):null,a.taxIncluded&&!a.taxExcluded?c("span",{children:e.incl}):null]})]})},q=({translations:e,order:a,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,m,u,o;const l=(r=a==null?void 0:a.discounts)==null?void 0:r.every(s=>s.amount.value===0);return!((m=a==null?void 0:a.discounts)!=null&&m.length)&&(l||!t||t<1)||(u=a==null?void 0:a.discounts)!=null&&u.length&&l?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:e.discount}),c("span",{children:(o=a==null?void 0:a.discounts)==null?void 0:o.map(({amount:s},y)=>{const p=((s==null?void 0:s.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:s==null?void 0:s.currency,amount:-p},`${s==null?void 0:s.value}${y}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(f,{source:$,size:"16"}),c("span",{children:e.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},F=({order:e})=>{var a;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(a=e==null?void 0:e.coupons)==null?void 0:a.map((t,n)=>i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},`${t==null?void 0:t.code}${n}`))})},U=({translations:e,renderTaxAccordion:a,totalAccordionTaxValue:t,order:n})=>{var m,u,o;const[l,r]=g(!1);return a?c(b,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:I,iconClose:A,children:i(E,{onStateChange:r,title:e.accordionTitle,secondaryText:c(S,{children:l?null:c(d,{weight:"normal",amount:t,currency:(u=n==null?void 0:n.totalTax)==null?void 0:u.currency})}),renderContentWhenClosed:!1,children:[(o=n==null?void 0:n.taxes)==null?void 0:o.map((s,y)=>{var h,p,_;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:s==null?void 0:s.title}),c("p",{children:c(d,{weight:"normal",amount:(h=s==null?void 0:s.amount)==null?void 0:h.value,currency:(p=s==null?void 0:s.amount)==null?void 0:p.currency})})]},`${(_=s==null?void 0:s.amount)==null?void 0:_.value}${y}`)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:e.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:e.tax}),c(d,{currency:(m=n==null?void 0:n.totalTax)==null?void 0:m.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},R=({translations:e,shoppingOrdersDisplaySubtotal:a,order:t})=>{var n,l,r,m;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:e.total}),c(d,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(l=t==null?void 0:t.grandTotal)==null?void 0:l.value,weight:"bold",size:"medium"})]}),a.taxExcluded&&a.taxIncluded?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:e.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.currency,amount:((m=t==null?void 0:t.grandTotal)==null?void 0:m.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},G=({translations:e,loading:a,storeConfig:t,order:n,withHeader:l=!0})=>{var h,p,_,O,w,L;if(a||!n)return c(z,{});const r=((h=n==null?void 0:n.totalGiftcard)==null?void 0:h.value)??0,m=((p=n.totalGiftcard)==null?void 0:p.currency)??"",u=((_=n.subtotal)==null?void 0:_.value)??0,o=((O=n.totalShipping)==null?void 0:O.value)??0,s=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),y=s?(L=n==null?void 0:n.taxes)==null?void 0:L.reduce((Z,v)=>{var M;return+((M=v==null?void 0:v.amount)==null?void 0:M.value)+Z},0):0;return i(D,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[l?c(k,{title:e.headerText}):null,i("div",{className:"order-cost-summary-content__wrapper",children:[c(P,{translations:e,order:n,subTotalValue:u,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(W,{translations:e,order:n,totalShipping:o,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(q,{translations:e,order:n,totalGiftcardValue:r,totalGiftcardCurrency:m}),c(F,{order:n}),c(U,{order:n,translations:e,renderTaxAccordion:s,totalAccordionTaxValue:y}),c(R,{translations:e,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})},rt=({withHeader:e,orderData:a,children:t,className:n,...l})=>{const{loading:r,storeConfig:m,order:u}=j({orderData:a}),o=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",{...l,className:H(["order-cost-summary",n]),children:c(G,{order:u,withHeader:e,loading:r,storeConfig:m,translations:o})})};export{rt as OrderCostSummary,rt as default}; +import{jsx as c,jsxs as i,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{classes as H}from"@dropins/tools/lib.js";import{useState as v,useEffect as T}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as V}from"@dropins/tools/event-bus.js";import{s as C}from"../chunks/setTaxStatus.js";import{Price as d,Icon as N,Accordion as b,AccordionSection as f,Card as E,Header as D}from"@dropins/tools/components.js";import{u as k}from"../chunks/useGetStoreConfig.js";import"../chunks/ShippingStatusCard.js";import*as x from"@dropins/tools/preact-compat.js";import{O as z}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 I=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),A=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),$=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.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"})),j=({orderData:a,config:e})=>{const[t,n]=v(!0),[l,r]=v(a),[u,o]=v(null);return T(()=>{if(e){const{shoppingCartDisplayPrice:m,shoppingOrdersDisplayShipping:s,shoppingOrdersDisplaySubtotal:y,...h}=e;o(p=>({...p,...h,shoppingCartDisplayPrice:C(m),shoppingOrdersDisplayShipping:C(s),shoppingOrdersDisplaySubtotal:C(y)})),n(!1)}},[e]),T(()=>{const m=V.on("order/data",s=>{r(s)},{eager:!0});return()=>{m==null||m.off()}},[]),{loading:t,storeConfig:u,order:l}},ut=({withHeader:a,orderData:e,children:t,className:n,...l})=>{const r=k(),{loading:u,storeConfig:o,order:m}=j({orderData:e,config:r}),s=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",{...l,className:H(["order-cost-summary",n]),children:c(R,{order:m,withHeader:a,loading:u,storeConfig:o,translations:s})})},P=({translations:a,order:e,subTotalValue:t,shoppingOrdersDisplaySubtotal:n})=>{var l,r;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(l=e==null?void 0:e.subtotal)==null?void 0:l.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:a.incl}):null,n.taxExcluded&&n.taxIncluded?i(S,{children:[c(d,{currency:(r=e==null?void 0:e.subtotal)==null?void 0:r.currency,amount:t,size:"small"})," ",c("span",{children:a.excl})]}):null]})]})},W=({translations:a,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var l,r,u,o;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:a.shipping}),(l=t==null?void 0:t.totalShipping)!=null&&l.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:a.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?i(S,{children:[c(d,{weight:"normal",currency:(u=t==null?void 0:t.totalShipping)==null?void 0:u.currency,amount:(o=t==null?void 0:t.totalShipping)==null?void 0:o.value,size:"small"}),i("span",{children:[" ",a.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:a.incl}):null]})]})},q=({translations:a,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,u,o,m;const l=(r=e==null?void 0:e.discounts)==null?void 0:r.every(s=>s.amount.value===0);return!((u=e==null?void 0:e.discounts)!=null&&u.length)&&(l||!t||t<1)||(o=e==null?void 0:e.discounts)!=null&&o.length&&l?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:a.discount}),c("span",{children:(m=e==null?void 0:e.discounts)==null?void 0:m.map(({amount:s},y)=>{const p=((s==null?void 0:s.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:s==null?void 0:s.currency,amount:-p},`${s==null?void 0:s.value}${y}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(N,{source:$,size:"16"}),c("span",{children:a.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},F=({order:a})=>{var e;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(e=a==null?void 0:a.coupons)==null?void 0:e.map((t,n)=>i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},`${t==null?void 0:t.code}${n}`))})},U=({translations:a,renderTaxAccordion:e,totalAccordionTaxValue:t,order:n})=>{var u,o,m;const[l,r]=v(!1);return e?c(b,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:I,iconClose:A,children:i(f,{onStateChange:r,title:a.accordionTitle,secondaryText:c(S,{children:l?null:c(d,{weight:"normal",amount:t,currency:(o=n==null?void 0:n.totalTax)==null?void 0:o.currency})}),renderContentWhenClosed:!1,children:[(m=n==null?void 0:n.taxes)==null?void 0:m.map((s,y)=>{var h,p,_;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:s==null?void 0:s.title}),c("p",{children:c(d,{weight:"normal",amount:(h=s==null?void 0:s.amount)==null?void 0:h.value,currency:(p=s==null?void 0:s.amount)==null?void 0:p.currency})})]},`${(_=s==null?void 0:s.amount)==null?void 0:_.value}${y}`)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:a.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:a.tax}),c(d,{currency:(u=n==null?void 0:n.totalTax)==null?void 0:u.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},G=({translations:a,shoppingOrdersDisplaySubtotal:e,order:t})=>{var n,l,r,u;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:a.total}),c(d,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(l=t==null?void 0:t.grandTotal)==null?void 0:l.value,weight:"bold",size:"medium"})]}),e.taxExcluded&&e.taxIncluded?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:a.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.currency,amount:((u=t==null?void 0:t.grandTotal)==null?void 0:u.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},R=({translations:a,loading:e,storeConfig:t,order:n,withHeader:l=!0})=>{var h,p,_,O,w,L;if(e||!n)return c(z,{});const r=((h=n==null?void 0:n.totalGiftcard)==null?void 0:h.value)??0,u=((p=n.totalGiftcard)==null?void 0:p.currency)??"",o=((_=n.subtotal)==null?void 0:_.value)??0,m=((O=n.totalShipping)==null?void 0:O.value)??0,s=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),y=s?(L=n==null?void 0:n.taxes)==null?void 0:L.reduce((Z,g)=>{var M;return+((M=g==null?void 0:g.amount)==null?void 0:M.value)+Z},0):0;return i(E,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[l?c(D,{title:a.headerText}):null,i("div",{className:"order-cost-summary-content__wrapper",children:[c(P,{translations:a,order:n,subTotalValue:o,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(W,{translations:a,order:n,totalShipping:m,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(q,{translations:a,order:n,totalGiftcardValue:r,totalGiftcardCurrency:u}),c(F,{order:n}),c(U,{order:n,translations:a,renderTaxAccordion:s,totalAccordionTaxValue:y}),c(G,{translations:a,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})};export{ut as OrderCostSummary,ut as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderHeader.d.ts b/scripts/__dropins__/storefront-order/containers/OrderHeader.d.ts new file mode 100644 index 0000000000..b698d2d3ef --- /dev/null +++ b/scripts/__dropins__/storefront-order/containers/OrderHeader.d.ts @@ -0,0 +1,3 @@ +export * from './OrderHeader/index' +import _default from './OrderHeader/index' +export default _default diff --git a/scripts/__dropins__/storefront-order/containers/OrderHeader.js b/scripts/__dropins__/storefront-order/containers/OrderHeader.js new file mode 100644 index 0000000000..ea4ab4300c --- /dev/null +++ b/scripts/__dropins__/storefront-order/containers/OrderHeader.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +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/OrderHeader/OrderHeader.d.ts b/scripts/__dropins__/storefront-order/containers/OrderHeader/OrderHeader.d.ts new file mode 100644 index 0000000000..ced3a986ff --- /dev/null +++ b/scripts/__dropins__/storefront-order/containers/OrderHeader/OrderHeader.d.ts @@ -0,0 +1,5 @@ +import { OrderHeaderProps } from '../../types'; +import { FunctionComponent } from 'preact'; + +export declare const OrderHeader: FunctionComponent; +//# sourceMappingURL=OrderHeader.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/containers/OrderHeader/index.d.ts b/scripts/__dropins__/storefront-order/containers/OrderHeader/index.d.ts new file mode 100644 index 0000000000..829eff409c --- /dev/null +++ b/scripts/__dropins__/storefront-order/containers/OrderHeader/index.d.ts @@ -0,0 +1,3 @@ +export * from './OrderHeader'; +export { OrderHeader as default } from './OrderHeader'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/containers/OrderProductList.js b/scripts/__dropins__/storefront-order/containers/OrderProductList.js index 0bd3dc97db..2c8ad403ba 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 P}from"@dropins/tools/preact-jsx-runtime.js";import{Card as h,Header as x}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as q}from"@dropins/tools/lib.js";import{useState as g,useEffect as L,useMemo as R}from"@dropins/tools/preact-hooks.js";import{events as T}from"@dropins/tools/event-bus.js";import{s as S}from"../chunks/setTaxStatus.js";import{g as b}from"../chunks/getStoreConfig.js";import{Fragment as N}from"@dropins/tools/preact.js";import"@dropins/tools/preact-compat.js";import{a as Q}from"../chunks/OrderLoaders.js";import{C as k}from"../chunks/CartSummaryItem.js";import{useText as v}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const w=({orderData:s})=>{const[o,r]=g(!0),[d,n]=g(s),[t,i]=g({taxIncluded:!1,taxExcluded:!1});return L(()=>{b().then(e=>{if(e){const c=S(e==null?void 0:e.shoppingCartDisplayPrice);i(c)}}).finally(()=>{r(!1)})},[]),L(()=>{const e=T.on("order/data",c=>{n(c)},{eager:!0});return()=>{e==null||e.off()}},[]),{loading:o,taxConfig:t,order:d}},G=s=>{const o=(s==null?void 0:s.items)??[],r=o.filter(t=>(t==null?void 0:t.eligibleForReturn)&&(t==null?void 0:t.quantityReturnRequested)).map(t=>({...t,totalQuantity:t.quantityReturnRequested})),d=new Map(r.map(t=>[t.id,t])),n=o.map(t=>{const i=d.get(t==null?void 0:t.id);if(i){const e=t.totalQuantity-i.quantityReturnRequested;return e===0?null:{...t,totalQuantity:e}}return t}).filter(t=>t!==null);return{returnedList:r,canceledItems:n==null?void 0:n.filter(t=>t.quantityCanceled),nonCanceledItems:n==null?void 0:n.filter(t=>!t.quantityCanceled)}},I=({loading:s,taxConfig:o,order:r=null,withHeader:d=!0,showConfigurableOptions:n,routeProductDetails:t})=>{const i=!!(r!=null&&r.returnNumber),e=v({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"}),c=R(()=>{var m,p;if(!r)return[];if(!i){const{returnedList:u,canceledItems:f,nonCanceledItems:C}=G(r);return[{type:"returned",list:u,title:e.returned},{type:"cancelled",list:f,title:e.cancelled},{type:"allItems",list:C,title:e.allOrders}].filter(O=>{var y;return((y=O==null?void 0:O.list)==null?void 0:y.length)>0})}return[{type:"returned",list:((p=(m=r.returns.find(u=>u.returnNumber===(r==null?void 0:r.returnNumber)))==null?void 0:m.items)==null?void 0:p.map(u=>({...u,totalQuantity:u.requestQuantity})))??[],title:e.returned}]},[r,i,e]);return r?c.every(l=>l.list.length===0)?null:a(h,{variant:"secondary",className:"order-order-product-list-content",children:c.map((l,m)=>{var u;const p=l.list.reduce((f,{totalQuantity:C})=>C+f,0);return P(N,{children:[d?a(x,{title:`${l.title} (${p})`}):null,a("ul",{className:"order-order-product-list-content__items",children:(u=l.list)==null?void 0:u.map(f=>a("li",{"data-testid":"order-product-list-content-item",children:a(k,{loading:s,product:f,itemType:l.type,taxConfig:o,translations:e,showConfigurableOptions:n,routeProductDetails:t})},f.id))})]},m)})}):a(Q,{})},W=({className:s,orderData:o,withHeader:r,showConfigurableOptions:d,routeProductDetails:n})=>{const{loading:t,taxConfig:i,order:e}=w({orderData:o});return a("div",{className:q(["order-order-product-list",s]),children:a(I,{loading:t,taxConfig:i,order:e,withHeader:r,showConfigurableOptions:d,routeProductDetails:n})})};export{W as OrderProductList,W as default}; +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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderReturns.js b/scripts/__dropins__/storefront-order/containers/OrderReturns.js index 1fcfe1cee5..6a98f6c332 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderReturns.js +++ b/scripts/__dropins__/storefront-order/containers/OrderReturns.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as c}from"@dropins/tools/lib.js";import{useState as d,useEffect as R}from"@dropins/tools/preact-hooks.js";import{events as L}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import{u as O}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as b}from"../chunks/ReturnsListContent.js";import{useText as g}from"@dropins/tools/i18n.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const w=({orderData:s})=>{const[i,n]=d(s),[u,o]=d([]);return R(()=>{const t=L.on("order/data",e=>{n(e),o(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:u}},v=({slots:s,className:i,orderData:n,withHeader:u,withThumbnails:o,routeReturnDetails:t,routeProductDetails:e,routeTracking:f})=>{const{orderReturns:m}=w({orderData:n}),l=O(),r="fullSizeView",p=g({minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return a("div",{className:c(["order-order-returns",i]),children:m.length?a(b,{pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:l,withOrderNumber:!1,withReturnNumber:!0,orderReturns:m,translations:p,withHeader:u,withThumbnails:o,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:f,loading:!1}):null})};export{v as OrderReturns,v as default}; +import{jsx as d}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as l,useEffect as O}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"@dropins/tools/preact.js";import{events as g}from"@dropins/tools/event-bus.js";import{u as w}from"../chunks/useIsMobile.js";import{R as N}from"../chunks/ReturnsListContent.js";import{useText as $}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const h=({orderData:s})=>{const[i,n]=l(s),[o,u]=l([]);return O(()=>{const t=g.on("order/data",e=>{n(e),u(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:o}},A=({slots:s,className:i,orderData:n,withHeader:o,withThumbnails:u,routeReturnDetails:t,routeProductDetails:e,routeTracking:p})=>{const m=b(),{orderReturns:a}=h({orderData:n}),f=w(),r="fullSizeView",c=(m==null?void 0:m.baseMediaUrl)??"",R=$({minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return d("div",{className:L(["order-order-returns",i]),children:a.length?d(N,{placeholderImage:c,pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:f,withOrderNumber:!1,withReturnNumber:!0,orderReturns:a,translations:R,withHeader:o,withThumbnails:u,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:p,loading:!1}):null})};export{A as OrderReturns,A as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index 9c102f1595..e3900654b3 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{jsxs as V,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{F as D}from"../chunks/OrderCancel.js";import{useState as v,useCallback as w,useEffect as F,useMemo as U}from"@dropins/tools/preact-hooks.js";import{events as _}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import*as N from"@dropins/tools/preact-compat.js";import{Text as g,useText as H}from"@dropins/tools/i18n.js";import{F as T,g as B}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E,a as z}from"../chunks/getCustomer.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getGuestOrder.graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";const P=r=>N.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},N.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"})),X=({onSubmit:r,loading:t,inLineAlert:a,fieldsConfig:i})=>V(M,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(g,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(g,{id:"Order.OrderSearchForm.description"})}),a.text?s(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:s(C,{source:P})}):null,s(D,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:i,onSubmit:r,children:s("div",{className:"order-order-search-form__button-container",children:s(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(g,{id:"Order.OrderSearchForm.button"})},"logIn")})})]}),x=r=>{try{return new URL(window.location.href).searchParams.get(r)}catch{return null}},Z=({onError:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[y,u]=v({text:"",type:"success"}),[b,p]=v(!1),m=H({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=w(async e=>{const l=x("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(t){const d=await E();(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})},[t,i,c]);F(()=>{const e=_.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),F(()=>{const e=x("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):t?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[t,i,c,a]);const O=U(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.lastname,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:w(async(e,l)=>{if(!l)return null;p(!0);const o=B(e.target);await z(o).then(n=>{n||u({text:m.invalidSearch,type:"warning"}),_.emit("order/data",n)}).catch(async n=>{var S;let d=!0;r==null||r({error:n.message});const h=t?await E():{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=n==null?void 0:n.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:n.message,type:"warning"})}).finally(()=>{p(!1)})},[t,r,a,i,m.invalidSearch]),inLineAlert:y,loading:b,normalizeFieldsConfig:O}},me=({className:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:y})=>{const{onSubmit:u,loading:b,inLineAlert:p,normalizeFieldsConfig:m}=Z({onError:y,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return s("div",{className:L(["order-order-search",r]),children:s(X,{onSubmit:u,loading:b,inLineAlert:p,fieldsConfig:m})})};export{me as OrderSearch,me as default}; +import{jsx as s,jsxs as V}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{useState as v,useCallback as w,useEffect as F,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as U}from"../chunks/ShippingStatusCard.js";import*as _ 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,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"../chunks/GurestOrderFragment.graphql.js";import"../chunks/initialize.js";const P=r=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},_.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"})),x=r=>{try{return new URL(window.location.href).searchParams.get(r)}catch{return null}},X=({onError:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[y,u]=v({text:"",type:"success"}),[b,p]=v(!1),m=z({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=w(async e=>{const l=x("orderRef"),n=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(t){const d=await E();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):n||f(c,{orderRef:e.token})}else n||f(c,{orderRef:e==null?void 0:e.token})},[t,i,c]);F(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),F(()=>{const e=x("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):t?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[t,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:w(async(e,l)=>{if(!l)return null;p(!0);const n=H(e.target);await B(n).then(o=>{o||u({text:m.invalidSearch,type:"warning"}),N.emit("order/data",o)}).catch(async o=>{var S;let d=!0;r==null||r({error:o.message});const h=t?await E():{email:""};(h==null?void 0:h.email)===(n==null?void 0:n.email)?f(i,{orderRef:n.number}):d=a==null?void 0:a({render:h===null||((S=o==null?void 0:o.message)==null?void 0:S.includes("Please login to view the order.")),formValues:n}),d&&u({text:o.message,type:"warning"})}).finally(()=>{p(!1)})},[t,r,a,i,m.invalidSearch]),inLineAlert:y,loading:b,normalizeFieldsConfig:O}},oe=({className:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:y})=>{const{onSubmit:u,loading:b,inLineAlert:p,normalizeFieldsConfig:m}=X({onError:y,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return s("div",{className:L(["order-order-search",r]),children:s(Z,{onSubmit:u,loading:b,inLineAlert:p,fieldsConfig:m})})},Z=({onSubmit:r,loading:t,inLineAlert:a,fieldsConfig:i})=>V(M,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(T,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(T,{id:"Order.OrderSearchForm.description"})}),a.text?s(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:s(C,{source:P})}):null,s(U,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:i,onSubmit:r,children:s("div",{className:"order-order-search-form__button-container",children:s(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{oe as OrderSearch,oe as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index d5a91e3a36..677e078def 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderStatus.js +++ b/scripts/__dropins__/storefront-order/containers/OrderStatus.js @@ -1,14 +1,13 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as c,jsxs as N,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{Card as F,Header as P,Button as E,InLineAlert as G,Modal as V}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{f as K}from"../chunks/returnOrdersHelper.js";import{classes as y,Slot as q}from"@dropins/tools/lib.js";import{f as x}from"../chunks/formatDateToLocale.js";import{useState as O,useEffect as v,useCallback as H}from"@dropins/tools/preact-hooks.js";import{events as I}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import{useMemo as W,useState as j}from"@dropins/tools/preact-compat.js";import{r as k}from"../chunks/redirectTo.js";import{O as J}from"../chunks/OrderCancelForm.js";import{useText as C,Text as $}from"@dropins/tools/i18n.js";import{r as z}from"../chunks/reorderItems.js";import{C as B}from"../chunks/OrderLoaders.js";import{G as Q}from"../chunks/getGuestOrder.graphql.js";import{f as X,h as Y}from"../chunks/fetch-graphql.js";import{b as Z}from"../chunks/transform-order-details.js";import{g as D}from"../chunks/getStoreConfig.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/convertCase.js";var _=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(_||{});const w={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"},ee=({slots:r,title:t,status:n,orderData:e,routeCreateReturn:i,onError:s,routeOnSuccess:a})=>{var M,L,b;const l=!!(e!=null&&e.returnNumber),d=String(n).toLocaleLowerCase(),o=(M=e==null?void 0:e.returns)==null?void 0:M[0],m=(o==null?void 0:o.returnStatus)??"",p=(o==null?void 0:o.createdReturnAt)??"",g=C(`Order.OrderStatusContent.${w[d]}.title`),h=C(`Order.OrderStatusContent.${w[d]}.message`),R=C(`Order.OrderStatusContent.${w[d]}.messageWithoutDate`),u=C({title:`Order.OrderStatusContent.returnStatus.${K(m)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return c("div",{});const f=e!=null&&e.orderStatusChangeDate?h==null?void 0:h.message.replace("{DATE}",e==null?void 0:e.orderStatusChangeDate):R.messageWithoutDate,A=((b=(L=u==null?void 0:u.returnMessage)==null?void 0:L.replace("{ORDER_CREATE_DATE}",x(e==null?void 0:e.orderDate)))==null?void 0:b.replace("{RETURN_CREATE_DATE}",x(p)))??"",T=l?t??u.title:t??g.title;return N(F,{className:"order-order-status-content",variant:"secondary",children:[c(P,{title:T}),N("div",{className:"order-order-status-content__wrapper",children:[c("div",{className:y(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(r!=null&&r.OrderActions)]]),children:c("p",{children:l?A:f})}),c(re,{orderData:e,slots:r,routeCreateReturn:i,routeOnSuccess:a,onError:s})]})]})},te=({orderData:r})=>{const[t,n]=O(r),[e,i]=O(r==null?void 0:r.status);return v(()=>{const s=I.on("order/data",a=>{n(a),i(a.status)},{eager:!0});return()=>{s==null||s.off()}},[]),{orderStatus:e,order:t}},re=({className:r,orderData:t,slots:n,routeCreateReturn:e,routeOnSuccess:i,onError:s})=>{const a=C({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=W(()=>{const d=t==null?void 0:t.availableActions,o=!!(d!=null&&d.length),m=!!(t!=null&&t.returnNumber),p=()=>{k(e,{},t)};return c(S,{children:n!=null&&n.OrderActions?c(q,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:t}):c("div",{"data-testid":"availableActionsList",className:y(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!o]]),children:d==null?void 0:d.map(g=>{switch(g){case _.CANCEL:return c(S,{children:m?null:c(ce,{orderRef:(t==null?void 0:t.token)??(t==null?void 0:t.id)})});case _.RETURN:return c(E,{variant:"secondary",onClick:p,children:m?a.createAnotherReturn:a.createReturn});case _.REORDER:return c(S,{children:m?null:c(ie,{orderData:t,onError:s,routeOnSuccess:i,children:a.reorder})})}})})})},[s,t,i,e,n,a]);return c("div",{className:y(["order-order-actions",r]),children:l})},U=()=>{const[r,t]=O(null);return v(()=>{const n=sessionStorage.getItem("orderStoreConfig"),e=n?JSON.parse(n):null;e?t(e):D().then(i=>{i&&(sessionStorage.setItem("orderStoreConfig",JSON.stringify(i)),t(i))})},[]),r},ne=` +import{jsx as i,Fragment as _,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as j,classes as A}from"@dropins/tools/lib.js";import{Button as E,InLineAlert as z,Modal as K,Card as q,Header as H}from"@dropins/tools/components.js";import{useState as S,useEffect as U,useCallback as B}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as Q,useState as J}from"@dropins/tools/preact-compat.js";import{u as $}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as P}from"@dropins/tools/event-bus.js";import{G as X}from"../chunks/GurestOrderFragment.graphql.js";import{f as Y,h as Z}from"../chunks/fetch-graphql.js";import{c as D}from"../chunks/initialize.js";import{useText as O,Text as x}from"@dropins/tools/i18n.js";import{C as ee}from"../chunks/OrderLoaders.js";import{f as re}from"../chunks/returnOrdersHelper.js";import{f as v}from"../chunks/formatDateToLocale.js";import{r as k}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import{r as ne}from"../chunks/reorderItems.js";import"../chunks/getStoreConfig.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(y||{});const se=({className:r,orderData:t,slots:n,routeCreateReturn:e,routeOnSuccess:a,onError:s})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=Q(()=>{const o=t==null?void 0:t.availableActions,c=!!(o!=null&&o.length),u=!!(t!=null&&t.returnNumber),R=()=>{k(e,{},t)};return i(_,{children:n!=null&&n.OrderActions?i(j,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:t}):i("div",{"data-testid":"availableActionsList",className:A(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!c]]),children:o==null?void 0:o.map(f=>{switch(f){case y.CANCEL:return i(_,{children:u?null:i(ae,{orderRef:(t==null?void 0:t.token)??(t==null?void 0:t.id)})});case y.RETURN:return i(E,{variant:"secondary",onClick:R,children:u?d.createAnotherReturn:d.createReturn});case y.REORDER:return i(_,{children:u?null:i(ue,{orderData:t,onError:s,routeOnSuccess:a,children:d.reorder})})}})})})},[s,t,a,e,n,d]);return i("div",{className:A(["order-order-actions",r]),children:l})},oe=({orderData:r})=>{const[t,n]=S(r),[e,a]=S(r==null?void 0:r.status);return U(()=>{const s=P.on("order/data",d=>{n(d),a(d.status)},{eager:!0});return()=>{s==null||s.off()}},[]),{orderStatus:e,order:t}},ce=` mutation CONFIRM_CANCEL_ORDER_MUTATION( - $orderId: ID!, - $confirmationKey: String! + $orderId: ID! + $confirmationKey: String! + ) { + confirmCancelOrder( + input: { order_id: $orderId, confirmation_key: $confirmationKey } ) { - confirmCancelOrder(input: { - order_id: $orderId, - confirmation_key: $confirmationKey - }) { order { ...guestOrderData } @@ -18,5 +17,5 @@ import{jsx as c,jsxs as N,Fragment as S}from"@dropins/tools/preact-jsx-runtime.j } } } -${Q} -`,se=async(r,t)=>X(ne,{variables:{orderId:r,confirmationKey:t}}).then(async({errors:n,data:e})=>{var a,l,d,o;const i=[...(a=e==null?void 0:e.confirmCancelOrder)!=null&&a.errorV2?[(l=e==null?void 0:e.confirmCancelOrder)==null?void 0:l.errorV2]:[],...n??[]];let s=null;return(d=e==null?void 0:e.confirmCancelOrder)!=null&&d.order&&(s=Z((o=e==null?void 0:e.confirmCancelOrder)==null?void 0:o.order),I.emit("order/data",s)),i.length>0?Y(i):s}),oe=({enableOrderCancellation:r})=>{const t=C({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[n,e]=O({text:"",status:void 0});return v(()=>{if(!r)return;const i=new URLSearchParams(window.location.search),s=i.get("order_id"),a=i.get("confirmation_key");s&&a&&se(s,a).then(()=>{e({text:t.orderCancelled,status:"success"})}).catch(l=>{e({text:l.message,status:"warning"})})},[r,t.orderCancelled]),{confirmOrderCancellation:n}},be=({slots:r,orderData:t,className:n,statusTitle:e,status:i,routeCreateReturn:s,onError:a,routeOnSuccess:l})=>{const{orderStatus:d,order:o}=te({orderData:t}),[m,p]=j(!1),g=()=>{p(!0);const f=new URL(window.location.href),A=f.searchParams.get("order_id"),T=f.searchParams.get("confirmation_key");A&&T&&(f.searchParams.delete("order_id"),f.searchParams.delete("confirmation_key"),window.history.replaceState({},document.title,f.toString()))},h=C({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),R=U(),{confirmOrderCancellation:u}=oe({enableOrderCancellation:R==null?void 0:R.orderCancellationEnabled});return N("div",{className:y(["order-order-status",n]),children:[!m&&(u==null?void 0:u.status)!==void 0&&c(G,{heading:h.cancelOrder,onDismiss:g,description:u.text,type:u.status}),o?c(ee,{title:e,status:i||d,slots:r,orderData:o,routeCreateReturn:s,onError:a,routeOnSuccess:l}):c(B,{withCard:!1})]})},ce=({orderRef:r})=>{const[t,n]=O(!1),e=()=>{n(!0)},i=()=>{n(!1)},s=U(),a=(s==null?void 0:s.orderCancellationReasons)??[],l=d=>d.map((o,m)=>({text:o==null?void 0:o.description,value:m.toString()}));return I.on("order/data",d=>{const o=String(d.status).toLocaleLowerCase();(o==="guest order cancellation requested"||o==="canceled")&&i()}),N(S,{children:[c(E,{variant:"secondary",onClick:e,"data-testid":"cancel-button",children:c($,{id:"Order.OrderStatusContent.actions.cancel"})}),t&&c(V,{centered:!0,size:"medium",onClose:i,className:"order-order-cancel__modal",title:c("h2",{className:"order-order-cancel__title",children:c($,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:c(J,{orderRef:r,cancelReasons:l(a)})})]})},ie=({onError:r,routeOnSuccess:t,orderData:n,children:e})=>{const[i,s]=O(!1),a=H(()=>{s(!0);const l=n==null?void 0:n.number;z(l).then(({success:d,userInputErrors:o})=>{d&&k(t,{}),o.length&&(r==null||r(o))}).catch(d=>{r==null||r(d.message)}).finally(()=>{s(!1)})},[n,t,r]);return c(E,{type:"button",disabled:i,variant:"secondary",className:"order-reorder",onClick:a,children:e})};export{be as OrderStatus,be as default}; + ${X} +`,ie=async(r,t)=>Y(ce,{variables:{orderId:r,confirmationKey:t}}).then(async({errors:n,data:e})=>{var d,l,o,c;const a=[...(d=e==null?void 0:e.confirmCancelOrder)!=null&&d.errorV2?[(l=e==null?void 0:e.confirmCancelOrder)==null?void 0:l.errorV2]:[],...n??[]];let s=null;return(o=e==null?void 0:e.confirmCancelOrder)!=null&&o.order&&(s=D((c=e==null?void 0:e.confirmCancelOrder)==null?void 0:c.order),P.emit("order/data",s)),a.length>0?Z(a):s}),de=({enableOrderCancellation:r})=>{const t=O({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[n,e]=S({text:"",status:void 0});return U(()=>{if(!r)return;const a=new URLSearchParams(window.location.search),s=a.get("order_id"),d=a.get("confirmation_key");s&&d&&ie(s,d).then(()=>{e({text:t.orderCancelled,status:"success"})}).catch(l=>{e({text:l.message,status:"warning"})})},[r,t.orderCancelled]),{confirmOrderCancellation:n}},$e=({slots:r,orderData:t,className:n,statusTitle:e,status:a,routeCreateReturn:s,onError:d,routeOnSuccess:l})=>{const{orderStatus:o,order:c}=oe({orderData:t}),[u,R]=J(!1),f=()=>{R(!0);const p=new URL(window.location.href),T=p.searchParams.get("order_id"),g=p.searchParams.get("confirmation_key");T&&g&&(p.searchParams.delete("order_id"),p.searchParams.delete("confirmation_key"),window.history.replaceState({},document.title,p.toString()))},h=O({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),C=$(),{confirmOrderCancellation:m}=de({enableOrderCancellation:C==null?void 0:C.orderCancellationEnabled});return N("div",{className:A(["order-order-status",n]),children:[!u&&(m==null?void 0:m.status)!==void 0&&i(z,{heading:h.cancelOrder,onDismiss:f,description:m.text,type:m.status}),c?i(le,{title:e,status:a||o,slots:r,orderData:c,routeCreateReturn:s,onError:d,routeOnSuccess:l}):i(ee,{withCard:!1})]})},ae=({orderRef:r})=>{const[t,n]=S(!1),e=()=>{n(!0)},a=()=>{n(!1)},s=$(),d=(s==null?void 0:s.orderCancellationReasons)??[],l=o=>o.map((c,u)=>({text:c==null?void 0:c.description,value:u.toString()}));return P.on("order/data",o=>{const c=String(o.status).toLocaleLowerCase();(c==="guest order cancellation requested"||c==="canceled")&&a()}),N(_,{children:[i(E,{variant:"secondary",onClick:e,"data-testid":"cancel-button",children:i(x,{id:"Order.OrderStatusContent.actions.cancel"})}),t&&i(K,{centered:!0,size:"medium",onClose:a,className:"order-order-cancel__modal",title:i("h2",{className:"order-order-cancel__title",children:i(x,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:i(te,{orderRef:r,cancelReasons:l(d)})})]})},b=r=>r&&r.charAt(0).toLocaleUpperCase()+r.slice(1).toLocaleLowerCase(),w={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"},le=({slots:r,title:t,status:n,orderData:e,routeCreateReturn:a,onError:s,routeOnSuccess:d})=>{var L,I,M;const l=!!(e!=null&&e.returnNumber),o=String(n).toLocaleLowerCase(),c=(L=e==null?void 0:e.returns)==null?void 0:L[0],u=(c==null?void 0:c.returnStatus)??"",R=(c==null?void 0:c.createdReturnAt)??"",f=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),h=O(`Order.OrderStatusContent.${w[o]}.title`),C=O(`Order.OrderStatusContent.${w[o]}.message`),m=O(`Order.OrderStatusContent.${w[o]}.messageWithoutDate`),p=O({title:`Order.OrderStatusContent.returnStatus.${re(u)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return i("div",{});const T=h!=null&&h.title?h:{title:b(o)},g=C!=null&&C.message?C:f,F=m!=null&&m.messageWithoutDate?m:f,G=e!=null&&e.orderStatusChangeDate?g==null?void 0:g.message.replace("{DATE}",v(e==null?void 0:e.orderStatusChangeDate)):F.messageWithoutDate,V=((M=(I=p==null?void 0:p.returnMessage)==null?void 0:I.replace("{ORDER_CREATE_DATE}",v(e==null?void 0:e.orderDate)))==null?void 0:M.replace("{RETURN_CREATE_DATE}",v(R)))??"",W=l?t??(p.title||b(u)):t??T.title;return N(q,{className:"order-order-status-content",variant:"secondary",children:[i(H,{title:W}),N("div",{className:"order-order-status-content__wrapper",children:[i("div",{className:A(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(r!=null&&r.OrderActions)]]),children:i("p",{children:l?V:G})}),i(se,{orderData:e,slots:r,routeCreateReturn:a,routeOnSuccess:d,onError:s})]})]})},ue=({onError:r,routeOnSuccess:t,orderData:n,children:e})=>{const[a,s]=S(!1),d=B(()=>{s(!0);const l=n==null?void 0:n.number;ne(l).then(({success:o,userInputErrors:c})=>{o&&k(t,{}),c.length&&(r==null||r(c))}).catch(o=>{r==null||r(o.message)}).finally(()=>{s(!1)})},[n,t,r]);return i(E,{type:"button",disabled:a,variant:"secondary",className:"order-reorder",onClick:d,children:e})};export{$e as OrderStatus,$e as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index 09fcf8e325..74da1dcd46 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as $}from"@dropins/tools/lib.js";import{useState as s,useEffect as h,useCallback as I}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as y}from"../chunks/getCustomerOrdersReturn.js";import"@dropins/tools/preact.js";import{u as A}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as M}from"../chunks/ReturnsListContent.js";import{useText as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const g={totalPages:1,currentPage:1,pageSize:1},V=({returnPageSize:t})=>{const[n,o]=s(!0),[i,u]=s([]),[a,m]=s(g),[d,l]=s(1);h(()=>{y(t).then(r=>{u((r==null?void 0:r.ordersReturn)??[]),m((r==null?void 0:r.pageInfo)??g)}).finally(()=>{o(!1)})},[t]);const c=I(r=>{l(r)},[]);return{pageInfo:a,selectedPage:d,loading:n,orderReturns:i,handleSetSelectPage:c}},Y=({slots:t,withReturnsListButton:n,className:o,minifiedView:i,withHeader:u,withThumbnails:a,returnPageSize:m,returnsInMinifiedView:d,routeReturnDetails:l,routeOrderDetails:c,routeTracking:r,routeReturnsList:p,routeProductDetails:L})=>{const{pageInfo:R,selectedPage:O,handleSetSelectPage:b,loading:w,orderReturns:N}=V({returnPageSize:m}),P=A(),e=i?"minifiedView":"fullSizeView",S=T({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",o]),children:f(M,{minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:t,selectedPage:O,handleSetSelectPage:b,pageInfo:R,withReturnsListButton:n,isMobile:P,orderReturns:N,translations:S,withHeader:u,returnsInMinifiedView:d,withThumbnails:a,minifiedView:i,routeReturnDetails:l,routeOrderDetails:c,routeTracking:r,routeReturnsList:p,routeProductDetails:L,loading:w})})};export{Y as default}; +import{jsx as p}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},er=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const f=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return p("div",{className:$(["order-returns-list",u]),children:p(A,{placeholderImage:(f==null?void 0:f.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{er as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js index f8605409a1..6649338f09 100644 --- a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js +++ b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as i,jsxs as S,Fragment as a}from"@dropins/tools/preact-jsx-runtime.js";import{classes as _,VComponent as A,Slot as E}from"@dropins/tools/lib.js";import{Card as L,Header as w,Accordion as R,AccordionSection as q,ContentGrid as G,Image as V}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{useState as x,useEffect as k}from"@dropins/tools/preact-hooks.js";import{events as D}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import{u as nn}from"../chunks/useIsMobile.js";import{Text as B,useText as en}from"@dropins/tools/i18n.js";import{C as pn}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact-compat.js";var M=(e=>(e.PENDING="pending",e.SHIPPING="shipping",e.COMPLETE="complete",e.PROCESSING="processing",e.HOLD="on hold",e.CANCELED="Canceled",e.SUSPECTED_FRAUD="suspected fraud",e.PAYMENT_REVIEW="payment review",e))(M||{});const tn=({orderData:e})=>{const[l,n]=x(!0),[t,m]=x(e),[h,f]=x(!1);return k(()=>{const u=D.on("order/data",d=>{m(d),f(d==null?void 0:d.isVirtual),n(!1)},{eager:!0});return e!=null&&e.id&&n(!1),()=>{u==null||u.off()}},[e]),{loading:l,order:t,isVirtualProduct:h}},v=({value:e,variant:l="primary",size:n="medium",icon:t,className:m,children:h,disabled:f=!1,active:u=!1,activeChildren:d,activeIcon:p,href:C,...b})=>{let g="dropin-button";(t&&!h||t&&u&&!d||!t&&u&&p)&&(g="dropin-iconButton"),u&&d&&(g="dropin-button"),m=_([g,`${g}--${n}`,`${g}--${l}`,[`${g}--${l}--disabled`,f],h&&t&&`${g}--with-icon`,!h&&d&&t&&`${g}--with-icon`,u&&p&&`${g}--with-icon`,m]);const c=_(["dropin-button-icon",`dropin-button-icon--${l}`,[`dropin-button-icon--${l}--disabled`,f],t==null?void 0:t.props.className]),y=C?{node:i("a",{}),role:"link",href:C,...b,disabled:f,active:u,onKeyDown:I=>{f&&I.preventDefault()},tabIndex:f?-1:0}:{node:i("button",{}),role:"button",...b,value:e,disabled:f,active:u};return S(A,{...y,className:m,children:[t&&!u&&i(A,{node:t,className:c}),p&&u&&i(A,{node:p,className:c}),h&&!u&&(typeof h=="string"?i("span",{children:h}):h),u&&d&&(typeof d=="string"?i("span",{children:d}):d)]})},sn=({slots:e,collapseThreshold:l,translations:n,returnData:t,routeTracking:m,routeProductDetails:h})=>{var d;const f=nn(),u=h?"a":"span";return S(L,{variant:"secondary",className:_(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(w,{title:n.returnOrderCardTitle}),S("div",{children:[(d=t==null?void 0:t.tracking)==null?void 0:d.map((p,C)=>{var y,I;const b={title:"",number:(p==null?void 0:p.trackingNumber)??"",carrier:((y=p==null?void 0:p.carrier)==null?void 0:y.label)??""},g=m==null?void 0:m(b),c=g?()=>{window.open(g,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(I=b.carrier)==null?void 0:I.toLocaleUpperCase()} | `,b.number]}),c?i(v,{onClick:c,children:n.trackButton}):null]},`${b.number}_${C}`)}),e!=null&&e.ReturnItemsDetails?i(E,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:e==null?void 0:e.ReturnItemsDetails,context:{items:t.items}}):null,i(R,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(q,{defaultOpen:l>=t.items.length,title:i(B,{id:"Order.ShippingStatusCard.itemText",plural:t.items.reduce((p,C)=>p+C.requestQuantity,0),fields:{count:t.items.reduce((p,C)=>p+C.requestQuantity,0)}}),children:i(G,{maxColumns:f?3:9,emptyGridContent:i(a,{}),className:_(["order-shipping-status-card__images",["order-shipping-status-card__images-3",f]]),children:t.items.map((p,C)=>{var c,y;const b=(c=p.thumbnail)==null?void 0:c.label,g=(y=p.thumbnail)==null?void 0:y.url;return i(u,{href:(h==null?void 0:h(p))??"#","data-testid":`${C}${p.uid}`,children:i(V,{alt:b,src:g,width:85,height:114})},`${C}${p.uid}`)})})})})]})]})},ln=({translations:e,slots:l,orderData:n,collapseThreshold:t=10,routeProductDetails:m,routeTracking:h})=>{var I,U,H,j,F,Q,K;const f=!!(n!=null&&n.returnNumber),u=n==null?void 0:n.returnNumber,d=m?"a":"span",p=(I=n==null?void 0:n.status)==null?void 0:I.toLocaleLowerCase(),b=((U=n==null?void 0:n.shipments)==null?void 0:U.length)===1&&(p==null?void 0:p.includes(M.COMPLETE)),g=(H=n==null?void 0:n.shipments)==null?void 0:H.every(s=>s.tracking.length===0),c=(j=n==null?void 0:n.items)==null?void 0:j.filter(s=>(s==null?void 0:s.quantityShipped)===0||(s==null?void 0:s.quantityShipped)<(s==null?void 0:s.quantityOrdered)),y=(F=n==null?void 0:n.items)==null?void 0:F.reduce((s,o)=>{const N=o.quantityOrdered-o.quantityShipped;return s+(N>0?N:0)},0);if(f&&(n!=null&&n.returns.length)){const s=n.returns.find(o=>o.returnNumber===u);return!s||s.tracking.length===0?null:i(sn,{slots:l,collapseThreshold:t,translations:e,returnData:s,routeTracking:h,routeProductDetails:m})}return!n||p!=null&&p.includes(M.CANCELED)?null:(Q=n==null?void 0:n.shipments)!=null&&Q.length?g&&!(c!=null&&c.length)&&b?null:S(a,{children:[(K=n==null?void 0:n.shipments)==null?void 0:K.map(({tracking:s,items:o,id:N},P)=>{const W=o.reduce((r,O)=>r+((O==null?void 0:O.quantityShipped)??0),0);return S(L,{variant:"secondary",className:"order-shipping-status-card",children:[i(w,{title:e.shippingCardTitle}),s==null?void 0:s.map(r=>{var T;const O=h==null?void 0:h(r),$=O?()=>{window.open(O,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[e.carrier," ",(T=r==null?void 0:r.carrier)==null?void 0:T.toLocaleUpperCase()," | ",r==null?void 0:r.number]}),i("p",{children:r==null?void 0:r.title})]}),l!=null&&l.DeliveryTrackActions?i(E,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:l==null?void 0:l.DeliveryTrackActions,context:{trackInformation:r}}):$?i(v,{onClick:$,children:e.trackButton}):null]},r.number)}),b?null:i(R,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(q,{"data-position":P+1,defaultOpen:t>=(o==null?void 0:o.length),title:i(B,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:W,fields:{count:W}}),children:i(G,{maxColumns:6,emptyGridContent:i(a,{}),className:"order-shipping-status-card__images",children:o==null?void 0:o.map(r=>{var T,Y,z,J,X,Z;const O=(z=(Y=(T=r==null?void 0:r.orderItem)==null?void 0:T.product)==null?void 0:Y.thumbnail)==null?void 0:z.label,$=(Z=(X=(J=r==null?void 0:r.orderItem)==null?void 0:J.product)==null?void 0:X.thumbnail)==null?void 0:Z.url;return i(d,{href:(m==null?void 0:m(r))??"#",children:i(V,{alt:O,src:$||"",width:85,height:114})},r.id)})})})}),l!=null&&l.DeliveryTimeLine?i(E,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:l==null?void 0:l.DeliveryTimeLine,context:{}}):null]},N)}),c!=null&&c.length?S(L,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(w,{title:e.notYetShippedTitle}),i(R,{actionIconPosition:"right",children:i(q,{defaultOpen:t>=(c==null?void 0:c.length),title:i(B,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(G,{maxColumns:6,emptyGridContent:i(a,{}),className:"order-shipping-status-card__images",children:c==null?void 0:c.map(s=>{var o,N;return i(d,{href:(m==null?void 0:m(s))??"#",children:i(V,{alt:(o=s.thumbnail)==null?void 0:o.label,src:((N=s.thumbnail)==null?void 0:N.url)||"",width:85,height:114})},s.id)})})})})]}):null]}):S(L,{variant:"secondary",className:"order-shipping-status-card",children:[i(w,{title:e.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:e.noInfoTitle})]})})]})},bn=({slots:e,className:l,collapseThreshold:n,orderData:t,routeOrderDetails:m,routeTracking:h,routeProductDetails:f})=>{const{loading:u,order:d,isVirtualProduct:p}=tn({orderData:t}),C=en({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});return!u&&p?null:i("div",{className:_(["order-shipping-status",l]),children:!u&&d?i(ln,{translations:C,routeOrderDetails:m,routeTracking:h,slots:e,orderData:d,collapseThreshold:n,routeProductDetails:f}):i(pn,{withCard:!1})})};export{bn as ShippingStatus,bn as default}; +import{jsx as i,jsxs as S,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $,VComponent as E,Slot as q}from"@dropins/tools/lib.js";import{Card as A,Header as x,Accordion as G,AccordionSection as V,ContentGrid as B,Image as M}from"@dropins/tools/components.js";import{useState as R,useEffect as tn}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as sn}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as ln}from"@dropins/tools/event-bus.js";import{C as rn}from"../chunks/OrderLoaders.js";import{u as hn}from"../chunks/useIsMobile.js";import{Text as U,useText as un}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";var H=(s=>(s.PENDING="pending",s.SHIPPING="shipping",s.COMPLETE="complete",s.PROCESSING="processing",s.HOLD="on hold",s.CANCELED="Canceled",s.SUSPECTED_FRAUD="suspected fraud",s.PAYMENT_REVIEW="payment review",s))(H||{});const dn=({orderData:s})=>{const[r,h]=R(!0),[n,c]=R(s),[l,m]=R(!1);return tn(()=>{const u=ln.on("order/data",o=>{c(o),m(o==null?void 0:o.isVirtual),h(!1)},{eager:!0});return s!=null&&s.id&&h(!1),()=>{u==null||u.off()}},[s]),{loading:r,order:n,isVirtualProduct:l}},en=({value:s,variant:r="primary",size:h="medium",icon:n,className:c,children:l,disabled:m=!1,active:u=!1,activeChildren:o,activeIcon:b,href:e,...C})=>{let d="dropin-button";(n&&!l||n&&u&&!o||!n&&u&&b)&&(d="dropin-iconButton"),u&&o&&(d="dropin-button"),c=$([d,`${d}--${h}`,`${d}--${r}`,[`${d}--${r}--disabled`,m],l&&n&&`${d}--with-icon`,!l&&o&&n&&`${d}--with-icon`,u&&b&&`${d}--with-icon`,c]);const I=$(["dropin-button-icon",`dropin-button-icon--${r}`,[`dropin-button-icon--${r}--disabled`,m],n==null?void 0:n.props.className]),g=e?{node:i("a",{}),role:"link",href:e,...C,disabled:m,active:u,onKeyDown:y=>{m&&y.preventDefault()},tabIndex:m?-1:0}:{node:i("button",{}),role:"button",...C,value:s,disabled:m,active:u};return S(E,{...g,className:c,children:[n&&!u&&i(E,{node:n,className:I}),b&&u&&i(E,{node:b,className:I}),l&&!u&&(typeof l=="string"?i("span",{children:l}):l),u&&o&&(typeof o=="string"?i("span",{children:o}):o)]})},cn=({placeholderImage:s,slots:r,collapseThreshold:h,translations:n,returnData:c,routeTracking:l,routeProductDetails:m})=>{var b;const u=hn(),o=m?"a":"span";return S(A,{variant:"secondary",className:$(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(x,{title:n.returnOrderCardTitle}),S("div",{children:[(b=c==null?void 0:c.tracking)==null?void 0:b.map((e,C)=>{var y,O;const d={title:"",number:(e==null?void 0:e.trackingNumber)??"",carrier:((y=e==null?void 0:e.carrier)==null?void 0:y.label)??""},I=l==null?void 0:l(d),g=I?()=>{window.open(I,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(O=d.carrier)==null?void 0:O.toLocaleUpperCase()} | `,d.number]}),g?i(en,{onClick:g,children:n.trackButton}):null]},`${d.number}_${C}`)}),r!=null&&r.ReturnItemsDetails?i(q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:r==null?void 0:r.ReturnItemsDetails,context:{items:c.items}}):null,i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{defaultOpen:h>=c.items.length,title:i(U,{id:"Order.ShippingStatusCard.itemText",plural:c.items.reduce((e,C)=>e+C.requestQuantity,0),fields:{count:c.items.reduce((e,C)=>e+C.requestQuantity,0)}}),children:i(B,{maxColumns:u?3:9,emptyGridContent:i(w,{}),className:$(["order-shipping-status-card__images",["order-shipping-status-card__images-3",u]]),children:c.items.map((e,C)=>{var g,y,O,_;const d=(g=e.thumbnail)==null?void 0:g.label,I=(O=(y=e.thumbnail)==null?void 0:y.url)!=null&&O.length?(_=e.thumbnail)==null?void 0:_.url:s;return i(o,{href:(m==null?void 0:m(e))??"#","data-testid":`${C}${e.uid}`,children:i(M,{alt:d,src:I,width:85,height:114})},`${C}${e.uid}`)})})})})]})]})},mn=({placeholderImage:s,translations:r,slots:h,orderData:n,collapseThreshold:c=10,routeProductDetails:l,routeTracking:m})=>{var O,_,j,F,Q,K,W;const u=!!(n!=null&&n.returnNumber),o=n==null?void 0:n.returnNumber,b=l?"a":"span",e=(O=n==null?void 0:n.status)==null?void 0:O.toLocaleLowerCase(),d=((_=n==null?void 0:n.shipments)==null?void 0:_.length)===1&&(e==null?void 0:e.includes(H.COMPLETE)),I=(j=n==null?void 0:n.shipments)==null?void 0:j.every(p=>p.tracking.length===0),g=(F=n==null?void 0:n.items)==null?void 0:F.filter(p=>(p==null?void 0:p.quantityShipped)===0||(p==null?void 0:p.quantityShipped)<(p==null?void 0:p.quantityOrdered)),y=(Q=n==null?void 0:n.items)==null?void 0:Q.reduce((p,f)=>{const T=f.quantityOrdered-f.quantityShipped;return p+(T>0?T:0)},0);if(u&&(n!=null&&n.returns.length)){const p=n.returns.find(f=>f.returnNumber===o);return!p||p.tracking.length===0?null:i(cn,{placeholderImage:s,slots:h,collapseThreshold:c,translations:r,returnData:p,routeTracking:m,routeProductDetails:l})}return!n||e!=null&&e.includes(H.CANCELED)?null:(K=n==null?void 0:n.shipments)!=null&&K.length?I&&!(g!=null&&g.length)&&d?null:S(w,{children:[(W=n==null?void 0:n.shipments)==null?void 0:W.map(({tracking:p,items:f,id:T},pn)=>{const Y=f.reduce((t,N)=>t+((N==null?void 0:N.quantityShipped)??0),0);return S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingCardTitle}),p==null?void 0:p.map(t=>{var a;const N=m==null?void 0:m(t),L=N?()=>{window.open(N,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[r.carrier," ",(a=t==null?void 0:t.carrier)==null?void 0:a.toLocaleUpperCase()," | ",t==null?void 0:t.number]}),i("p",{children:t==null?void 0:t.title})]}),h!=null&&h.DeliveryTrackActions?i(q,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:h==null?void 0:h.DeliveryTrackActions,context:{trackInformation:t}}):L?i(en,{onClick:L,children:r.trackButton}):null]},t.number)}),d?null:i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{"data-position":pn+1,defaultOpen:c>=(f==null?void 0:f.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:Y,fields:{count:Y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:f==null?void 0:f.map(t=>{var a,z,J,X,Z,v,P,k,D,nn;const N=(J=(z=(a=t==null?void 0:t.orderItem)==null?void 0:a.product)==null?void 0:z.thumbnail)==null?void 0:J.label,L=(P=(v=(Z=(X=t==null?void 0:t.orderItem)==null?void 0:X.product)==null?void 0:Z.thumbnail)==null?void 0:v.url)!=null&&P.length?(nn=(D=(k=t==null?void 0:t.orderItem)==null?void 0:k.product)==null?void 0:D.thumbnail)==null?void 0:nn.url:s;return i(b,{href:(l==null?void 0:l(t))??"#",children:i(M,{alt:N,src:L,width:85,height:114})},t.id)})})})}),h!=null&&h.DeliveryTimeLine?i(q,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:h==null?void 0:h.DeliveryTimeLine,context:{}}):null]},T)}),g!=null&&g.length?S(A,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(x,{title:r.notYetShippedTitle}),i(G,{actionIconPosition:"right",children:i(V,{defaultOpen:c>=(g==null?void 0:g.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:g==null?void 0:g.map(p=>{var f,T;return i(b,{href:(l==null?void 0:l(p))??"#",children:i(M,{alt:(f=p.thumbnail)==null?void 0:f.label,src:((T=p.thumbnail)==null?void 0:T.url)||"",width:85,height:114})},p.id)})})})})]}):null]}):S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:r.noInfoTitle})]})})]})},wn=({slots:s,className:r,collapseThreshold:h,orderData:n,routeOrderDetails:c,routeTracking:l,routeProductDetails:m})=>{const{loading:u,order:o,isVirtualProduct:b}=dn({orderData:n}),e=sn(),C=un({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});if(!u&&b)return null;const d=(e==null?void 0:e.baseMediaUrl)??"";return i("div",{className:$(["order-shipping-status",r]),children:!u&&o?i(mn,{placeholderImage:d,translations:C,routeOrderDetails:c,routeTracking:l,slots:s,orderData:o,collapseThreshold:h,routeProductDetails:m}):i(rn,{withCard:!1})})};export{wn as ShippingStatus,wn as default}; diff --git a/scripts/__dropins__/storefront-order/containers/index.d.ts b/scripts/__dropins__/storefront-order/containers/index.d.ts index 06da75d995..33f75b0a3d 100644 --- a/scripts/__dropins__/storefront-order/containers/index.d.ts +++ b/scripts/__dropins__/storefront-order/containers/index.d.ts @@ -1,11 +1,12 @@ -export * from './OrderSearch'; -export * from './OrderStatus'; -export * from './ShippingStatus'; +export * from './CreateReturn'; export * from './CustomerDetails'; -export * from './ReturnsList'; -export * from './OrderProductList'; +export * from './OrderCancelForm'; export * from './OrderCostSummary'; +export * from './OrderHeader'; +export * from './OrderProductList'; export * from './OrderReturns'; -export * from './CreateReturn'; -export * from './OrderCancelForm'; +export * from './OrderSearch'; +export * from './OrderStatus'; +export * from './ReturnsList'; +export * from './ShippingStatus'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/models/acdl.d.ts b/scripts/__dropins__/storefront-order/data/models/acdl.d.ts new file mode 100644 index 0000000000..bb2c6081bc --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/models/acdl.d.ts @@ -0,0 +1,99 @@ +/** + * This module contains the schema type definitions to build the ShoppingCart + * and Order contexts, which are required to trigger the "place-order" event. + * + * The following schema types have been extracted from the Adobe Commerce + * Events SDK package. + * + * ShoppingCart schema type @see https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/shoppingCart.ts + * Order schema type @see https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/order.ts + */ +type ShoppingCartItem = { + canApplyMsrp: boolean; + formattedPrice: string; + id: string; + prices: { + price: Price; + }; + product: Product; + configurableOptions?: Array; + quantity: number; +}; +type Price = { + value: number; + currency?: string; + regularPrice?: number; +}; +type Product = { + productId: number; + name: string; + sku: string; + topLevelSku?: string | null; + specialToDate?: string | null; + specialFromDate?: string | null; + newToDate?: string | null; + newFromDate?: string | null; + createdAt?: string | null; + updatedAt?: string | null; + manufacturer?: string | null; + countryOfManufacture?: string | null; + categories?: string[] | null; + productType?: string | null; + pricing?: { + regularPrice: number; + minimalPrice?: number; + maximalPrice?: number; + specialPrice?: number; + tierPricing?: { + customerGroupId?: number | null; + qty: number; + value: number; + }[]; + currencyCode: string | null; + }; + canonicalUrl?: string | null; + mainImageUrl?: string | null; +}; +type ConfigurableOption = { + id?: number; + optionLabel: string; + valueId?: number; + valueLabel: string; +}; +type Payment = { + paymentMethodCode: string; + paymentMethodName: string; + total: number; +}; +type Shipping = { + shippingMethod?: string; + shippingAmount?: number; +}; +export type ShoppingCartContext = { + id: string | null; + items?: Array; + prices?: { + subtotalExcludingTax?: Price; + subtotalIncludingTax?: Price; + }; + totalQuantity: number; + possibleOnepageCheckout?: boolean; + giftMessageSelected?: boolean; + giftWrappingSelected?: boolean; + source?: string; +}; +export type OrderContext = { + appliedCouponCode: string; + email: string; + grandTotal: number; + orderId: string; + orderType?: 'checkout' | 'instant_purchase'; + otherTax: number; + payments?: Payment[]; + salesTax: number; + shipping?: Shipping; + subtotalExcludingTax: number; + subtotalIncludingTax: number; +}; +export {}; +//# sourceMappingURL=acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/models/index.d.ts b/scripts/__dropins__/storefront-order/data/models/index.d.ts index 25a5e493bb..33d6b55695 100644 --- a/scripts/__dropins__/storefront-order/data/models/index.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/index.d.ts @@ -1,7 +1,8 @@ -export * from './order-details'; +export * from './acdl'; export * from './attributes-form'; -export * from './store-config'; export * from './customer'; -export * from './store-config'; export * from './customer-orders-return'; +export * from './request-return'; +export * from './order-details'; +export * from './store-config'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file 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 2caff4eebd..a27ac60a28 100644 --- a/scripts/__dropins__/storefront-order/data/models/order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/order-details.d.ts @@ -119,6 +119,7 @@ export type ShipmentsModel = { items: ShipmentItemsModel[]; }; export type OrderDataModel = { + placeholderImage?: string; returnNumber: string; id: string; orderStatusChangeDate?: string; diff --git a/scripts/__dropins__/storefront-order/data/models/request-return.d.ts b/scripts/__dropins__/storefront-order/data/models/request-return.d.ts new file mode 100644 index 0000000000..b1b956b633 --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/models/request-return.d.ts @@ -0,0 +1,7 @@ +export interface RequestReturnModel { + uid: string; + number: string; + status: string; + createdAt: string; +} +//# sourceMappingURL=request-return.d.ts.map \ No newline at end of file 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 9df6001dc3..1770b4f2ec 100644 --- a/scripts/__dropins__/storefront-order/data/models/store-config.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/store-config.d.ts @@ -1,4 +1,5 @@ export interface StoreConfigModel { + baseMediaUrl: string; orderCancellationEnabled: boolean; orderCancellationReasons: OrderCancellationReason[]; shoppingCartDisplayPrice: 1 | 2 | 3; diff --git a/scripts/__dropins__/storefront-order/data/transforms/index.d.ts b/scripts/__dropins__/storefront-order/data/transforms/index.d.ts index 22fb3ce575..a10f2a7e82 100644 --- a/scripts/__dropins__/storefront-order/data/transforms/index.d.ts +++ b/scripts/__dropins__/storefront-order/data/transforms/index.d.ts @@ -1,8 +1,11 @@ -export * from './transform-order-details'; -export * from './transform-guest-order'; +export * from './transform-acdl'; export * from './transform-attributes-form'; -export * from './transform-store-config'; export * from './transform-customer'; -export * from './transform-store-config'; +export * from './transform-customer-address-input'; export * from './transform-customer-orders-returns'; +export * from './transform-guest-order'; +export * from './transform-order-details'; +export * from './transform-place-order'; +export * from './transform-store-config'; +export * from './transform-request-return'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-acdl.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-acdl.d.ts new file mode 100644 index 0000000000..c30df667ff --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-acdl.d.ts @@ -0,0 +1,5 @@ +import { OrderContext, OrderDataModel, ShoppingCartContext } from '../models'; + +export declare const transformShoppingCartContext: (cartId: string, data: OrderDataModel) => ShoppingCartContext; +export declare const transformOrderContext: (data: OrderDataModel) => OrderContext; +//# sourceMappingURL=transform-acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-customer-address-input.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-customer-address-input.d.ts new file mode 100644 index 0000000000..4050049a7b --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-customer-address-input.d.ts @@ -0,0 +1,22 @@ +import { OrderAddressModel } from '../models'; + +export declare function transformCustomerAddressInput(address: OrderAddressModel): { + region: { + region_id: number | null; + region: string | undefined; + }; + city: string | undefined; + company: string | undefined; + country_code: string | undefined; + firstname: string | undefined; + lastname: string | undefined; + middlename: string | undefined; + postcode: string | undefined; + street: string[] | undefined; + telephone: string | undefined; + custom_attributesV2: { + attribute_code: string; + value: string; + }[]; +}; +//# sourceMappingURL=transform-customer-address-input.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-place-order.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-place-order.d.ts new file mode 100644 index 0000000000..5758b4d2a2 --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-place-order.d.ts @@ -0,0 +1,5 @@ +import { PlaceOrderResponse } from '../../types'; +import { OrderDataModel } from '../models'; + +export declare const transformPlaceOrder: (response: PlaceOrderResponse) => OrderDataModel | null; +//# sourceMappingURL=transform-place-order.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-request-return.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-request-return.d.ts new file mode 100644 index 0000000000..487d8f8cf4 --- /dev/null +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-request-return.d.ts @@ -0,0 +1,5 @@ +import { RequestReturnResponse } from '../../types'; +import { RequestReturnModel } from '../models'; + +export declare const transformRequestReturn: (response: RequestReturnResponse) => RequestReturnModel | {}; +//# sourceMappingURL=transform-request-return.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts index 8785b2223c..dedc3def4d 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts @@ -1,9 +1,10 @@ import { AttributesFormModel, OrderItemModel } from '../../data/models'; -import { StepsTypes, TaxTypes, UseCreateReturn } from '../../types'; +import { StepsTypes, UseCreateReturn } from '../../types'; import { RefObject } from 'preact'; export declare const useCreateReturn: ({ onSuccess, onError, handleSetInLineAlert, orderData, }: UseCreateReturn) => { order: { + placeholderImage?: string | undefined; returnNumber?: string | undefined; id: string; orderStatusChangeDate?: string | undefined; @@ -52,7 +53,6 @@ export declare const useCreateReturn: ({ onSuccess, onError, handleSetInLineAler steps: StepsTypes; loading: boolean; formsRef: import('preact/hooks').MutableRef[]>; - taxConfig: TaxTypes; attributesList: [] | AttributesFormModel[]; selectedProductList: [] | OrderItemModel[]; itemsEligibleForReturn: OrderItemModel[]; diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useOrderCostSummary.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useOrderCostSummary.d.ts index 10e8080d22..e5fdda0bad 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useOrderCostSummary.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useOrderCostSummary.d.ts @@ -1,7 +1,7 @@ import { OrderDataModel } from '../../data/models'; import { StoreConfigProps, UseOrderCostSummaryProps } from '../../types'; -export declare const useOrderCostSummary: ({ orderData, }: UseOrderCostSummaryProps) => { +export declare const useOrderCostSummary: ({ orderData, config, }: UseOrderCostSummaryProps) => { loading: boolean; storeConfig: StoreConfigProps | null; order: OrderDataModel | undefined; diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useOrderHeader.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useOrderHeader.d.ts new file mode 100644 index 0000000000..1c941f6f80 --- /dev/null +++ b/scripts/__dropins__/storefront-order/hooks/containers/useOrderHeader.d.ts @@ -0,0 +1,8 @@ +import { OrderDataModel } from '../../data/models'; +import { UseOrderHeaderProps } from '../../types'; + +export declare const useOrderHeader: ({ orderData, handleEmailAvailability, handleSignUpClick, }: UseOrderHeaderProps) => { + order: OrderDataModel | undefined; + onSignUpClickHandler: (() => void) | undefined; +}; +//# sourceMappingURL=useOrderHeader.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useOrderProductList.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useOrderProductList.d.ts index 41ed08fd54..3b7b764fd5 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useOrderProductList.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useOrderProductList.d.ts @@ -1,9 +1,8 @@ import { OrderDataModel } from '../../data/models'; -import { TaxTypes, UseOrderProductListProps } from '../../types'; +import { UseOrderProductListProps } from '../../types'; export declare const useOrderProductList: ({ orderData, }: UseOrderProductListProps) => { loading: boolean; - taxConfig: TaxTypes; order: OrderDataModel | undefined; }; //# sourceMappingURL=useOrderProductList.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/index.d.ts b/scripts/__dropins__/storefront-order/hooks/index.d.ts index 8edc217cda..eeec23d318 100644 --- a/scripts/__dropins__/storefront-order/hooks/index.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/index.d.ts @@ -1,11 +1,13 @@ +export * from './containers/useCreateReturn'; +export * from './containers/useCustomerDetails'; +export * from './containers/useOrderCostSummary'; +export * from './containers/useOrderHeader'; +export * from './containers/useOrderProductList'; export * from './containers/useOrderSearch'; export * from './containers/useOrderStatus'; -export * from './containers/useShippingStatus'; -export * from './containers/useCustomerDetails'; export * from './containers/useReturnsList'; -export * from './containers/useOrderProductList'; -export * from './containers/useOrderCostSummary'; -export * from './containers/useCreateReturn'; +export * from './containers/useShippingStatus'; export * from './useInLineAlert'; export * from './useIsMobile'; +export * from './api/useGetStoreConfig'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts index 128c70a944..6a4befce7d 100644 --- a/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts @@ -187,6 +187,11 @@ declare const _default: { "createAnotherReturn": "Start another return", "reorder": "Reorder" }, + "orderPlaceholder": { + "title": "", + "message": "Your order has been in its current status since {DATE}.", + "messageWithoutDate": "Your order has been in its current status for some time." + }, "orderPending": { "title": "Pending", "message": "The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.", @@ -230,6 +235,41 @@ declare const _default: { "title": "cancellation requested", "message": "The cancellation has been requested on {DATE}. Check your email for further instructions.", "messageWithoutDate": "The cancellation has been requested. Check your email for further instructions." + }, + "orderPendingPayment": { + "title": "Pending Payment", + "message": "The order was successfully placed on {DATE}, but it is awaiting payment. Please complete the payment so we can start processing your order.", + "messageWithoutDate": "Your order is awaiting payment. Please complete the payment so we can start processing your order." + }, + "orderRejected": { + "title": "Rejected", + "message": "Your order was rejected on {DATE}. Please contact us for more information.", + "messageWithoutDate": "Your order was rejected. Please contact us for more information." + }, + "orderAuthorized": { + "title": "Authorized", + "message": "Your order was successfully authorized on {DATE}. We will begin processing your order shortly.", + "messageWithoutDate": "Your order was successfully authorized. We will begin processing your order shortly." + }, + "orderPaypalCanceledReversal": { + "title": "PayPal Canceled Reversal", + "message": "The PayPal transaction reversal was canceled on {DATE}. Please check your order details for more information.", + "messageWithoutDate": "The PayPal transaction reversal was canceled. Please check your order details for more information." + }, + "orderPendingPaypal": { + "title": "Pending PayPal", + "message": "Your order is awaiting PayPal payment confirmation since {DATE}. Please check your PayPal account for the payment status.", + "messageWithoutDate": "Your order is awaiting PayPal payment confirmation. Please check your PayPal account for the payment status." + }, + "orderPaypalReversed": { + "title": "PayPal Reversed", + "message": "The PayPal payment was reversed on {DATE}. Please contact us for further details.", + "messageWithoutDate": "The PayPal payment was reversed. Please contact us for further details." + }, + "orderClosed": { + "title": "Closed", + "message": "The order placed on {DATE} has been closed. For any further assistance, please contact support.", + "messageWithoutDate": "Your order has been closed. For any further assistance, please contact support." } }, "CustomerDetails": { @@ -287,8 +327,18 @@ declare const _default: { "button": "Submit Cancellation", "errorHeading": "Error", "errorDescription": "There was an error processing your order cancellation." + }, + "OrderHeader": { + "title": "{{name}}, thank you for your order!", + "defaultTitle": "Thank you for your order!", + "order": "ORDER #{{order}}", + "CreateAccount": { + "message": "Save your information for faster checkout next time.", + "button": "Create an account" + } } } -}; +} +; export default _default; diff --git a/scripts/__dropins__/storefront-order/lib/acdl.d.ts b/scripts/__dropins__/storefront-order/lib/acdl.d.ts new file mode 100644 index 0000000000..4b20d2ad49 --- /dev/null +++ b/scripts/__dropins__/storefront-order/lib/acdl.d.ts @@ -0,0 +1,18 @@ +import { OrderDataModel } from '../data/models'; + +/** + * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/contexts.ts + */ +export declare const contexts: { + SHOPPING_CART_CONTEXT: string; + ORDER_CONTEXT: string; +}; +/** + * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/events.ts + */ +export declare const events: { + PLACE_ORDER: string; +}; +export declare function getAdobeDataLayer(): any; +export declare function publishPlaceOrderEvent(cartId: string, data: OrderDataModel): void; +//# sourceMappingURL=acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/lib/capitalizeFirst.d.ts b/scripts/__dropins__/storefront-order/lib/capitalizeFirst.d.ts new file mode 100644 index 0000000000..18269aab6f --- /dev/null +++ b/scripts/__dropins__/storefront-order/lib/capitalizeFirst.d.ts @@ -0,0 +1,2 @@ +export declare const capitalizeFirst: (str: string) => string; +//# sourceMappingURL=capitalizeFirst.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/render.js b/scripts/__dropins__/storefront-order/render.js index a338507bd7..94a3765951 100644 --- a/scripts/__dropins__/storefront-order/render.js +++ b/scripts/__dropins__/storefront-order/render.js @@ -1,5 +1,5 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ (function(n,e){try{if(typeof document<"u"){const r=document.createElement("style"),a=e.styleId;for(const t in e.attributes)r.setAttribute(t,e.attributes[t]);r.setAttribute("data-dropin",a),r.appendChild(document.createTextNode(n));const o=document.querySelector('style[data-dropin="sdk"]');if(o)o.after(r);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(r):document.head.append(r)}}}catch(r){console.error("dropin-styles (injectCodeFunction)",r)}})(`.dropin-button,.dropin-iconButton{border:0 none;cursor:pointer;white-space:normal}.dropin-button{border-radius:var(--shape-border-radius-3);font-size:var(--type-button-1-font);font-weight:var(--type-button-1-font);padding:var(--spacing-xsmall) var(--spacing-medium);display:flex;justify-content:center;align-items:center;text-align:left;word-wrap:break-word}.dropin-iconButton{height:var(--spacing-xbig);width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button:disabled,.dropin-iconButton:disabled{pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button:not(:disabled),.dropin-iconButton:not(:disabled){cursor:pointer}.dropin-button:focus,.dropin-iconButton:focus{outline:none}.dropin-button:focus-visible,.dropin-iconButton:focus-visible{outline:var(--spacing-xxsmall) solid var(--color-button-focus)}.dropin-button--primary,a.dropin-button--primary,.dropin-iconButton--primary{border:none;background:var(--color-brand-500) 0 0% no-repeat padding-box;color:var(--color-neutral-50);text-align:left;margin-right:0}.dropin-iconButton--primary{border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button--primary--disabled,a.dropin-button--primary--disabled,.dropin-iconButton--primary--disabled{background:var(--color-neutral-300) 0 0% no-repeat padding-box;color:var(--color-neutral-500);fill:var(--color-neutral-300);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--primary:hover,a.dropin-button--primary:hover,.dropin-iconButton--primary:hover,.dropin-button--primary:focus:hover,.dropin-iconButton--primary:focus:hover{background-color:var(--color-button-hover);text-decoration:none}.dropin-button--primary:focus,.dropin-iconButton--primary:focus{background-color:var(--color-brand-500)}.dropin-button--primary:hover:active,.dropin-iconButton--primary:hover:active{background-color:var(--color-button-active)}.dropin-button--secondary,a.dropin-button--secondary,.dropin-iconButton--secondary{border:var(--shape-border-width-2) solid var(--color-brand-500);background:none 0 0% no-repeat padding-box;color:var(--color-brand-500);padding-top:calc(var(--spacing-xsmall) - var(--shape-border-width-2));padding-left:calc(var(--spacing-medium) - var(--shape-border-width-2))}.dropin-iconButton--secondary{border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall);padding-top:calc(var(--spacing-xsmall) - var(--shape-border-width-2));padding-left:calc(var(--spacing-xsmall) - var(--shape-border-width-2))}.dropin-button--secondary--disabled,a.dropin-button--secondary--disabled,.dropin-iconButton--secondary--disabled{border:var(--shape-border-width-2) solid var(--color-neutral-300);background:none 0 0% no-repeat padding-box;color:var(--color-neutral-500);fill:var(--color-neutral-300);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--secondary:hover,a.dropin-button--secondary:hover,.dropin-iconButton--secondary:hover{border:var(--shape-border-width-2) solid var(--color-button-hover);color:var(--color-button-hover);text-decoration:none}.dropin-button--secondary:active,.dropin-iconButton--secondary:active{border:var(--shape-border-width-2) solid var(--color-button-active);color:var(--color-button-active)}.dropin-button--tertiary,a.dropin-button--tertiary,.dropin-iconButton--tertiary{border:none;background:none 0 0% no-repeat padding-box;color:var(--color-brand-500)}.dropin-iconButton--tertiary{border:none;border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button--tertiary--disabled,a.dropin-button--tertiary--disabled,.dropin-iconButton--tertiary--disabled{border:none;color:var(--color-neutral-500);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--tertiary:hover,a.dropin-button--tertiary:hover,.dropin-iconButton--tertiary:hover{color:var(--color-button-hover);text-decoration:none}.dropin-button--tertiary:active,.dropin-iconButton--tertiary:active{color:var(--color-button-active)}.dropin-button--tertiary:focus-visible,.dropin-iconButton--tertiary:focus-visible{-webkit-box-shadow:inset 0 0 0 2px var(--color-neutral-800);-moz-box-shadow:inset 0 0 0 2px var(--color-neutral-800);box-shadow:inset 0 0 0 2px var(--color-neutral-800)}.dropin-button--large{font:var(--type-button-1-font);letter-spacing:var(--type-button-1-letter-spacing)}.dropin-button--medium{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.dropin-button-icon{height:24px}.dropin-button--with-icon{column-gap:var(--spacing-xsmall);row-gap:var(--spacing-xsmall)} -.order-order-search-form{gap:var(--spacing-small);border-color:transparent}.order-order-search-form .dropin-card__content{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}.order-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-order-search-form__wrapper{display:grid;grid-template-columns:1fr;grid-template-rows:auto;grid-template-areas:"email" "lastname" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--lastname{grid-area:lastname}.order-order-search-form__wrapper__item--number{grid-area:number}.order-order-search-form__button-container{display:flex;justify-content:flex-end;grid-area:button}.order-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}@media (min-width: 768px){.order-order-search-form__wrapper{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;grid-template-areas:"email lastname" "number number" "button button"}}.order-order-status-content .dropin-card__content{gap:0}.order-order-status-content__wrapper .order-order-status-content__wrapper-description p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.order-order-status-content__wrapper-description--actions-slot{margin-bottom:0}.order-shipping-status-card .dropin-card__content{gap:0}.order-shipping-status-card--count-steper{font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-shipping-status-card__header{display:grid;grid-template-columns:1fr auto;justify-items:self-start;align-items:center;margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card__header button{max-height:40px}.order-shipping-status-card__header--content p,.order-shipping-status-card--return-order p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card--return-order p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-shipping-status-card--return-order p a:hover{text-decoration:none;color:var(--color-brand-800)}.order-shipping-status-card .order-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-shipping-status-card.order-shipping-status-card--return-order .dropin-content-grid.order-shipping-status-card__images{overflow:auto!important}.order-shipping-status-card .order-shipping-status-card__images img{object-fit:contain;width:85px;height:114px}.order-order-loaders--card-loader{margin-bottom:var(--spacing-small)}.order-order-actions__wrapper{display:flex;justify-content:space-between;gap:0 var(--spacing-small);margin-bottom:var(--spacing-small);margin-top:var(--spacing-medium)}.order-order-actions__wrapper button{width:100%;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing);cursor:pointer}.order-order-actions__wrapper--empty{display:none}.order-customer-details-content .dropin-card__content{gap:0}.order-customer-details-content__container{display:block;flex-direction:column}.order-customer-details-content__container-shipping_address,.order-customer-details-content__container-billing_address{margin:var(--spacing-medium) 0}@media (min-width: 768px){.order-customer-details-content__container{display:grid;grid-template-columns:auto;grid-template-rows:auto auto auto;grid-auto-flow:row}.order-customer-details-content__container-email{grid-area:1 / 1 / 2 / 2}.order-customer-details-content__container--no-margin p{margin-bottom:0}.order-customer-details-content__container-shipping_address{grid-area:2 / 1 / 3 / 2;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address,.order-customer-details-content__container-return-information{grid-area:2 / 2 / 3 / 3;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address--fullwidth{grid-area:2 / 1 / 3 / 3}.order-customer-details-content__container-shipping_methods{grid-area:3 / 1 / 4 / 2}.order-customer-details-content__container-payment_methods{grid-area:3 / 2 / 4 / 3}.order-customer-details-content__container-payment_methods--fullwidth{grid-area:3 / 1 / 4 / 3}}.order-customer-details-content__container-title{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.order-customer-details-content__container p{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:0}.order-customer-details-content__container-payment_methods p{display:grid;gap:0;grid-template-columns:auto 1fr}.order-customer-details-content__container-payment_methods p.order-customer-details-content__container-payment_methods--icon{gap:0 var(--spacing-xsmall)}.order-customer-details-content__container-description p{margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-big);padding:0}.order-customer-details-content__container-description p:nth-child(1),.order-customer-details-content__container-description p:nth-child(3),.order-customer-details-content__container-description p:nth-child(4),.order-customer-details-content__container-description p:nth-child(6){float:left}.order-customer-details-content__container-return-information .order-customer-details-content__container-description p{float:none;display:block}.order-empty-list{margin-bottom:var(--spacing-small)}.order-empty-list.order-empty-list--minified,.order-empty-list .dropin-card{border:none}.order-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.order-empty-list.order-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.order-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.order-empty-list.order-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.order-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list--empty-box .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.order-returns-list-content .order-returns__header--minified{margin-bottom:var(--spacing-small)}.order-returns-list-content .order-returns__header--full-size{margin-bottom:0}.order-returns-list-content__cards-list{margin-bottom:var(--spacing-small)}.order-returns-list-content__cards-list .dropin-card__content{gap:0}.order-returns-list-content__cards-grid{display:grid;grid-template-columns:1fr 1fr auto;gap:0px 0px;grid-template-areas:"descriptions descriptions actions" "images images actions"}.order-returns-list-content__descriptions{grid-area:descriptions}.order-returns-list-content__descriptions p{margin:0 0 var(--spacing-small) 0;padding:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);color:var(--color-neutral-800)}.order-returns-list-content__descriptions p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-returns-list-content__descriptions p a:hover{color:var(--color-brand-800)}.order-returns-list-content__descriptions .order-returns-list-content__return-status{font:var(--type-button-2-font);font-weight:500;color:var(--color-neutral-800)}.order-returns-list-content .order-returns-list-content__actions{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.order-returns-list-content .order-returns-list-content__actions:hover{text-decoration:none;color:var(--color-brand-500)}.order-returns-list-content__card .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.order-returns-list-content__card .order-returns-list-content__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.order-returns-list-content__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.order-returns-list-content__card-wrapper svg{color:var(--color-neutral-800)}.order-returns-list-content__images{margin-top:var(--spacing-small);grid-area:images}.order-returns-list-content__actions{grid-area:actions;align-self:center}.order-returns-list-content .order-returns-list-content__images{overflow:auto}.order-returns-list-content .order-returns-list-content__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-returns-list-content .order-returns-list-content__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.order-returns-list-content .order-returns-list-content__images img{object-fit:contain;width:85px;height:114px}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin:0 0 var(--spacing-medium) 0;padding:0}.order-order-product-list-content .dropin-card__content{gap:0}.order-order-product-list-content__items .dropin-card__content{gap:var(--spacing-xsmall)}.order-order-product-list-content .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-order-product-list-content .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-cart-summary-item{margin-bottom:var(--spacing-medium)}}.order-cost-summary-content .dropin-card__content{gap:0}.order-cost-summary-content__description{margin-bottom:var(--spacing-xsmall)}.order-cost-summary-content__description .order-cost-summary-content__description--header,.order-cost-summary-content__description .order-cost-summary-content__description--subheader{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__description .order-cost-summary-content__description--header span{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-cost-summary-content__description--subheader{margin-top:var(--spacing-xxsmall)}.order-cost-summary-content__description--subheader span{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-brand-700)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader{display:flex;justify-content:flex-start;align-items:center;gap:0 var(--spacing-xxsmall)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader .dropin-price,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-overline-font)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--header span:last-child{color:var(--color-alert-800)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child{display:flex;justify-content:flex-start;align-items:flex-end;gap:0 var(--spacing-xsmall)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child span{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-neutral-700)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-alert-800)}.order-cost-summary-content__description--total{margin-top:var(--spacing-medium)}.order-cost-summary-content__description--total .order-cost-summary-content__description--header span{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.order-cost-summary-content__accordion .dropin-accordion-section .dropin-accordion-section__content-container{gap:var(--spacing-small);margin:var(--spacing-small) 0}.order-cost-summary-content__accordion-row{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__accordion-row p{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-cost-summary-content__accordion-row p:first-child{color:var(--color-neutral-700)}.order-cost-summary-content__accordion .order-cost-summary-content__accordion-row.order-cost-summary-content__accordion-total p:first-child{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-create-return .order-create-return_notification{margin-bottom:var(--spacing-medium)}.order-return-order-product-list{list-style:none;margin:0;padding:0}.order-return-order-product-list .order-return-order-product-list__item{display:grid;grid-template-columns:auto 1fr;align-items:start;margin-bottom:var(--spacing-medium);position:relative}.order-return-order-product-list__item--blur:before{content:"";position:absolute;width:100%;height:100%;background-color:var(--color-opacity-24);z-index:1}.order-return-order-product-list>.order-return-order-product-list__item:last-child{display:flex;justify-content:flex-end}.order-return-order-product-list>.order-return-order-product-list__item .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-return-order-product-list>.order-return-order-product-list__item .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-create-return .dropin-cart-item__footer .dropin-incrementer.dropin-incrementer--medium{max-width:160px}.order-return-order-product-list .dropin-incrementer__button-container{margin:0}@media only screen and (min-width: 320px) and (max-width: 768px){.order-return-order-product-list>.order-return-order-product-list__item{margin-bottom:var(--spacing-medium)}}.order-return-order-message p{margin:0;padding:0}.order-return-order-message a{max-width:162px;padding:var(--spacing-xsmall)}.order-return-order-message .order-return-order-message__title{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800);margin-bottom:var(--spacing-small)}.order-return-order-message .order-return-order-message__subtitle{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-bottom:var(--spacing-xlarge)}.order-return-reason-form .dropin-cart-item,.order-return-reason-form form .dropin-field{margin-bottom:var(--spacing-medium)}.order-return-reason-form .order-return-reason-form__actions{display:flex;gap:0 var(--spacing-medium);justify-content:flex-end;margin-bottom:0}.order-order-cancel-reasons-form__text{text-align:left;color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel-reasons-form__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}.order-order-cancel__modal{margin:auto}.order-order-cancel__modal .dropin-modal__header{display:grid;grid-template-columns:1fr auto}.order-order-cancel__title{color:var(--color-neutral-900);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-order-cancel__text{color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel__modal .dropin-modal__header-close-button{align-self:center}.order-order-cancel__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}@media only screen and (min-width: 768px){.dropin-modal__body--medium.order-order-cancel__modal>.dropin-modal__header-title{margin:0 var(--spacing-xxbig) var(--spacing-medium)}}`,{styleId:"order"}); -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as n}from"@dropins/tools/lib.js";import{useState as s,useEffect as d}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const u={CreateReturn:{headerText:"Return items",downloadableCount:"Files",returnedItems:"Returned items:",configurationsList:{quantity:"Quantity"},stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},giftCard:{sender:"Sender",recipient:"Recipient",message:"Note"},success:{title:"Return submitted",message:"Your return request has been successfully submitted."},buttons:{nextStep:"Continue",backStep:"Back",submit:"Submit return",backStore:"Back to order"}},OrderCostSummary:{headerText:"Order summary",headerReturnText:"Return summary",subtotal:{title:"Subtotal"},shipping:{title:"Shipping",freeShipping:"Free shipping"},tax:{accordionTitle:"Taxes",accordionTotalTax:"Tax Total",totalExcludingTaxes:"Total excluding taxes",title:"Tax",incl:"Including taxes",excl:"Excluding taxes"},discount:{title:"Discount",subtitle:"discounted"},total:{title:"Total"}},Returns:{minifiedView:{returnsList:{viewAllOrdersButton:"View all returns",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Recent returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}},fullSizeView:{returnsList:{viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}}},OrderProductListContent:{cancelledTitle:"Cancelled",allOrdersTitle:"Your order",returnedTitle:"Returned",refundedTitle:"Your refunded",downloadableCount:"Files",stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},GiftCard:{sender:"Sender",recipient:"Recipient",message:"Note"}},OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",lastname:"Last Name",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{orderNumber:"Order number:",returnNumber:"Return number:",itemText:{none:"",one:"Package contents ({{count}} item)",many:"Package contents ({{count}} items)"},trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",returnOrderCardTitle:"Package details",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping information",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:{singular:"Package contents ({{count}} item)",plural:"Package contents ({{count}} items)"}},OrderStatusContent:{noInfoTitle:"Check back later for more details.",returnMessage:"The order was placed on {ORDER_CREATE_DATE} and your return process started on {RETURN_CREATE_DATE}",returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},actions:{cancel:"Cancel order",createReturn:"Return or replace",createAnotherReturn:"Start another return",reorder:"Reorder"},orderPending:{title:"Pending",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderProcessing:{title:"Processing",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderOnHold:{title:"On hold",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderReceived:{title:"Order received",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderComplete:{title:"Complete",message:"Your order is complete. Need help with your order? Contact us at support@adobe.com"},orderCanceled:{title:"Canceled",message:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days.",messageWithoutDate:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days."},orderSuspectedFraud:{title:"Suspected fraud",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderPaymentReview:{title:"Payment Review",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},guestOrderCancellationRequested:{title:"cancellation requested",message:"The cancellation has been requested on {DATE}. Check your email for further instructions.",messageWithoutDate:"The cancellation has been requested. Check your email for further instructions."}},CustomerDetails:{headerText:"Customer information",freeShipping:"Free shipping",orderReturnLabels:{createdReturnAt:"Return requested on: ",returnStatusLabel:"Return status: ",orderNumberLabel:"Order number: "},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},paymentMethods:{title:"Payment method"},returnInformation:{title:"Return details"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details."},OrderCancel:{buttonText:"Cancel Order"},OrderCancelForm:{title:"Cancel order",description:"Select a reason for canceling the order",label:"Reason for cancel",button:"Submit Cancellation",errorHeading:"Error",errorDescription:"There was an error processing your order cancellation."}},p={Order:u},m={default:p},h=({children:t})=>{const[o,i]=s("en_US");return d(()=>{const e=c.on("locale",a=>{i(a)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},T=new n(r(h,{}));export{T as render}; +.order-customer-details-content .dropin-card__content{gap:0}.order-customer-details-content__container{display:block;flex-direction:column}.order-customer-details-content__container-shipping_address,.order-customer-details-content__container-billing_address{margin:var(--spacing-medium) 0}@media (min-width: 768px){.order-customer-details-content__container{display:grid;grid-template-columns:auto;grid-template-rows:auto auto auto;grid-auto-flow:row}.order-customer-details-content__container-email{grid-area:1 / 1 / 2 / 2}.order-customer-details-content__container--no-margin p{margin-bottom:0}.order-customer-details-content__container-shipping_address{grid-area:2 / 1 / 3 / 2;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address,.order-customer-details-content__container-return-information{grid-area:2 / 2 / 3 / 3;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address--fullwidth{grid-area:2 / 1 / 3 / 3}.order-customer-details-content__container-shipping_methods{grid-area:3 / 1 / 4 / 2}.order-customer-details-content__container-payment_methods{grid-area:3 / 2 / 4 / 3}.order-customer-details-content__container-payment_methods--fullwidth{grid-area:3 / 1 / 4 / 3}}.order-customer-details-content__container-title{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.order-customer-details-content__container p{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:0}.order-customer-details-content__container-payment_methods p{display:grid;gap:0;grid-template-columns:auto 1fr}.order-customer-details-content__container-payment_methods p.order-customer-details-content__container-payment_methods--icon{gap:0 var(--spacing-xsmall)}.order-customer-details-content__container-description p{margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-big);padding:0}.order-customer-details-content__container-description p:nth-child(1),.order-customer-details-content__container-description p:nth-child(3),.order-customer-details-content__container-description p:nth-child(4),.order-customer-details-content__container-description p:nth-child(6){float:left}.order-customer-details-content__container-return-information .order-customer-details-content__container-description p{float:none;display:block}.order-empty-list{margin-bottom:var(--spacing-small)}.order-empty-list.order-empty-list--minified,.order-empty-list .dropin-card{border:none}.order-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.order-empty-list.order-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.order-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.order-empty-list.order-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.order-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list--empty-box .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.order-order-actions__wrapper{display:flex;justify-content:space-between;gap:0 var(--spacing-small);margin-bottom:var(--spacing-small);margin-top:var(--spacing-medium)}.order-order-actions__wrapper button{width:100%;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing);cursor:pointer}.order-order-actions__wrapper--empty{display:none}.order-order-cancel-reasons-form__text{text-align:left;color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel-reasons-form__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}.order-order-cancel__modal{margin:auto}.order-order-cancel__modal .dropin-modal__header{display:grid;grid-template-columns:1fr auto}.order-order-cancel__title{color:var(--color-neutral-900);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-order-cancel__text{color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel__modal .dropin-modal__header-close-button{align-self:center}.order-order-cancel__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}@media only screen and (min-width: 768px){.dropin-modal__body--medium.order-order-cancel__modal>.dropin-modal__header-title{margin:0 var(--spacing-xxbig) var(--spacing-medium)}}.order-order-loaders--card-loader{margin-bottom:var(--spacing-small)}.order-cost-summary-content .dropin-card__content{gap:0}.order-cost-summary-content__description{margin-bottom:var(--spacing-xsmall)}.order-cost-summary-content__description .order-cost-summary-content__description--header,.order-cost-summary-content__description .order-cost-summary-content__description--subheader{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__description .order-cost-summary-content__description--header span{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-cost-summary-content__description--subheader{margin-top:var(--spacing-xxsmall)}.order-cost-summary-content__description--subheader span{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-brand-700)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader{display:flex;justify-content:flex-start;align-items:center;gap:0 var(--spacing-xxsmall)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader .dropin-price,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-overline-font)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--header span:last-child{color:var(--color-alert-800)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child{display:flex;justify-content:flex-start;align-items:flex-end;gap:0 var(--spacing-xsmall)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child span{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-neutral-700)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-alert-800)}.order-cost-summary-content__description--total{margin-top:var(--spacing-medium)}.order-cost-summary-content__description--total .order-cost-summary-content__description--header span{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.order-cost-summary-content__accordion .dropin-accordion-section .dropin-accordion-section__content-container{gap:var(--spacing-small);margin:var(--spacing-small) 0}.order-cost-summary-content__accordion-row{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__accordion-row p{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-cost-summary-content__accordion-row p:first-child{color:var(--color-neutral-700)}.order-cost-summary-content__accordion .order-cost-summary-content__accordion-row.order-cost-summary-content__accordion-total p:first-child{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-header{text-align:center;padding:var(--spacing-xxbig)}.order-header__icon{margin-bottom:var(--spacing-small)}.order-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-header__title:first-letter{text-transform:uppercase}.order-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-header .success-icon{color:var(--color-positive-500)}.order-header-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-header-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-header-create-account__button{display:flex;margin:0 auto;text-align:center}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin:0 0 var(--spacing-medium) 0;padding:0}.order-order-product-list-content .dropin-card__content{gap:0}.order-order-product-list-content__items .dropin-card__content{gap:var(--spacing-xsmall)}.order-order-product-list-content .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-order-product-list-content .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-cart-summary-item{margin-bottom:var(--spacing-medium)}}.order-order-search-form{gap:var(--spacing-small);border-color:transparent}.order-order-search-form .dropin-card__content{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}.order-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-order-search-form__wrapper{display:grid;grid-template-columns:1fr;grid-template-rows:auto;grid-template-areas:"email" "lastname" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--lastname{grid-area:lastname}.order-order-search-form__wrapper__item--number{grid-area:number}.order-order-search-form__button-container{display:flex;justify-content:flex-end;grid-area:button}.order-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}@media (min-width: 768px){.order-order-search-form__wrapper{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;grid-template-areas:"email lastname" "number number" "button button"}}.order-order-status-content .dropin-card__content{gap:0}.order-order-status-content__wrapper .order-order-status-content__wrapper-description p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.order-order-status-content__wrapper-description--actions-slot{margin-bottom:0}.order-return-order-message p{margin:0;padding:0}.order-return-order-message a{max-width:162px;padding:var(--spacing-xsmall)}.order-return-order-message .order-return-order-message__title{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800);margin-bottom:var(--spacing-small)}.order-return-order-message .order-return-order-message__subtitle{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-bottom:var(--spacing-xlarge)}.order-create-return .order-create-return_notification{margin-bottom:var(--spacing-medium)}.order-return-order-product-list{list-style:none;margin:0;padding:0}.order-return-order-product-list .order-return-order-product-list__item{display:grid;grid-template-columns:auto 1fr;align-items:start;margin-bottom:var(--spacing-medium);position:relative}.order-return-order-product-list__item--blur:before{content:"";position:absolute;width:100%;height:100%;background-color:var(--color-opacity-24);z-index:1}.order-return-order-product-list>.order-return-order-product-list__item:last-child{display:flex;justify-content:flex-end}.order-return-order-product-list>.order-return-order-product-list__item .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-return-order-product-list>.order-return-order-product-list__item .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-create-return .dropin-cart-item__footer .dropin-incrementer.dropin-incrementer--medium{max-width:160px}.order-return-order-product-list .dropin-incrementer__button-container{margin:0}@media only screen and (min-width: 320px) and (max-width: 768px){.order-return-order-product-list>.order-return-order-product-list__item{margin-bottom:var(--spacing-medium)}}.order-return-reason-form .dropin-cart-item,.order-return-reason-form form .dropin-field{margin-bottom:var(--spacing-medium)}.order-return-reason-form .order-return-reason-form__actions{display:flex;gap:0 var(--spacing-medium);justify-content:flex-end;margin-bottom:0}.order-returns-list-content .order-returns__header--minified{margin-bottom:var(--spacing-small)}.order-returns-list-content .order-returns__header--full-size{margin-bottom:0}.order-returns-list-content__cards-list{margin-bottom:var(--spacing-small)}.order-returns-list-content__cards-list .dropin-card__content{gap:0}.order-returns-list-content__cards-grid{display:grid;grid-template-columns:1fr 1fr auto;gap:0px 0px;grid-template-areas:"descriptions descriptions actions" "images images actions"}.order-returns-list-content__descriptions{grid-area:descriptions}.order-returns-list-content__descriptions p{margin:0 0 var(--spacing-small) 0;padding:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);color:var(--color-neutral-800)}.order-returns-list-content__descriptions p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-returns-list-content__descriptions p a:hover{color:var(--color-brand-800)}.order-returns-list-content__descriptions .order-returns-list-content__return-status{font:var(--type-button-2-font);font-weight:500;color:var(--color-neutral-800)}.order-returns-list-content .order-returns-list-content__actions{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.order-returns-list-content a.order-returns-list-content__actions{display:inline-block;width:100%}.order-returns-list-content .order-returns-list-content__actions:hover{text-decoration:none;color:var(--color-brand-500)}.order-returns-list-content__card .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.order-returns-list-content__card .order-returns-list-content__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.order-returns-list-content__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.order-returns-list-content__card-wrapper svg{color:var(--color-neutral-800)}.order-returns-list-content__images{margin-top:var(--spacing-small);grid-area:images}.order-returns-list-content__actions{grid-area:actions;align-self:center}.order-returns-list-content .order-returns-list-content__images{overflow:auto}.order-returns-list-content .order-returns-list-content__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-returns-list-content .order-returns-list-content__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.order-returns-list-content .order-returns-list-content__images img{object-fit:contain;width:85px;height:114px}.order-shipping-status-card .dropin-card__content{gap:0}.order-shipping-status-card--count-steper{font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-shipping-status-card__header{display:grid;grid-template-columns:1fr auto;justify-items:self-start;align-items:center;margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card__header button{max-height:40px}.order-shipping-status-card__header--content p,.order-shipping-status-card--return-order p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card--return-order p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-shipping-status-card--return-order p a:hover{text-decoration:none;color:var(--color-brand-800)}.order-shipping-status-card .order-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-shipping-status-card.order-shipping-status-card--return-order .dropin-content-grid.order-shipping-status-card__images{overflow:auto!important}.order-shipping-status-card .order-shipping-status-card__images img{object-fit:contain;width:85px;height:114px}`,{styleId:"order"}); +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as n,useEffect as d}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const u={CreateReturn:{headerText:"Return items",downloadableCount:"Files",returnedItems:"Returned items:",configurationsList:{quantity:"Quantity"},stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},giftCard:{sender:"Sender",recipient:"Recipient",message:"Note"},success:{title:"Return submitted",message:"Your return request has been successfully submitted."},buttons:{nextStep:"Continue",backStep:"Back",submit:"Submit return",backStore:"Back to order"}},OrderCostSummary:{headerText:"Order summary",headerReturnText:"Return summary",subtotal:{title:"Subtotal"},shipping:{title:"Shipping",freeShipping:"Free shipping"},tax:{accordionTitle:"Taxes",accordionTotalTax:"Tax Total",totalExcludingTaxes:"Total excluding taxes",title:"Tax",incl:"Including taxes",excl:"Excluding taxes"},discount:{title:"Discount",subtitle:"discounted"},total:{title:"Total"}},Returns:{minifiedView:{returnsList:{viewAllOrdersButton:"View all returns",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Recent returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}},fullSizeView:{returnsList:{viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}}},OrderProductListContent:{cancelledTitle:"Cancelled",allOrdersTitle:"Your order",returnedTitle:"Returned",refundedTitle:"Your refunded",downloadableCount:"Files",stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},GiftCard:{sender:"Sender",recipient:"Recipient",message:"Note"}},OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",lastname:"Last Name",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{orderNumber:"Order number:",returnNumber:"Return number:",itemText:{none:"",one:"Package contents ({{count}} item)",many:"Package contents ({{count}} items)"},trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",returnOrderCardTitle:"Package details",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping information",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:{singular:"Package contents ({{count}} item)",plural:"Package contents ({{count}} items)"}},OrderStatusContent:{noInfoTitle:"Check back later for more details.",returnMessage:"The order was placed on {ORDER_CREATE_DATE} and your return process started on {RETURN_CREATE_DATE}",returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},actions:{cancel:"Cancel order",createReturn:"Return or replace",createAnotherReturn:"Start another return",reorder:"Reorder"},orderPlaceholder:{title:"",message:"Your order has been in its current status since {DATE}.",messageWithoutDate:"Your order has been in its current status for some time."},orderPending:{title:"Pending",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderProcessing:{title:"Processing",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderOnHold:{title:"On hold",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderReceived:{title:"Order received",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderComplete:{title:"Complete",message:"Your order is complete. Need help with your order? Contact us at support@adobe.com"},orderCanceled:{title:"Canceled",message:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days.",messageWithoutDate:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days."},orderSuspectedFraud:{title:"Suspected fraud",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderPaymentReview:{title:"Payment Review",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},guestOrderCancellationRequested:{title:"cancellation requested",message:"The cancellation has been requested on {DATE}. Check your email for further instructions.",messageWithoutDate:"The cancellation has been requested. Check your email for further instructions."},orderPendingPayment:{title:"Pending Payment",message:"The order was successfully placed on {DATE}, but it is awaiting payment. Please complete the payment so we can start processing your order.",messageWithoutDate:"Your order is awaiting payment. Please complete the payment so we can start processing your order."},orderRejected:{title:"Rejected",message:"Your order was rejected on {DATE}. Please contact us for more information.",messageWithoutDate:"Your order was rejected. Please contact us for more information."},orderAuthorized:{title:"Authorized",message:"Your order was successfully authorized on {DATE}. We will begin processing your order shortly.",messageWithoutDate:"Your order was successfully authorized. We will begin processing your order shortly."},orderPaypalCanceledReversal:{title:"PayPal Canceled Reversal",message:"The PayPal transaction reversal was canceled on {DATE}. Please check your order details for more information.",messageWithoutDate:"The PayPal transaction reversal was canceled. Please check your order details for more information."},orderPendingPaypal:{title:"Pending PayPal",message:"Your order is awaiting PayPal payment confirmation since {DATE}. Please check your PayPal account for the payment status.",messageWithoutDate:"Your order is awaiting PayPal payment confirmation. Please check your PayPal account for the payment status."},orderPaypalReversed:{title:"PayPal Reversed",message:"The PayPal payment was reversed on {DATE}. Please contact us for further details.",messageWithoutDate:"The PayPal payment was reversed. Please contact us for further details."},orderClosed:{title:"Closed",message:"The order placed on {DATE} has been closed. For any further assistance, please contact support.",messageWithoutDate:"Your order has been closed. For any further assistance, please contact support."}},CustomerDetails:{headerText:"Customer information",freeShipping:"Free shipping",orderReturnLabels:{createdReturnAt:"Return requested on: ",returnStatusLabel:"Return status: ",orderNumberLabel:"Order number: "},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},paymentMethods:{title:"Payment method"},returnInformation:{title:"Return details"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details."},OrderCancel:{buttonText:"Cancel Order"},OrderCancelForm:{title:"Cancel order",description:"Select a reason for canceling the order",label:"Reason for cancel",button:"Submit Cancellation",errorHeading:"Error",errorDescription:"There was an error processing your order cancellation."},OrderHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},p={Order:u},m={default:p},h=({children:t})=>{const[o,a]=n("en_US");return d(()=>{const e=c.on("locale",s=>{a(s)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},T=new i(r(h,{}));export{T as render}; diff --git a/scripts/__dropins__/storefront-order/types/api/placeOrder.types.d.ts b/scripts/__dropins__/storefront-order/types/api/placeOrder.types.d.ts new file mode 100644 index 0000000000..fe5b52e24f --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/api/placeOrder.types.d.ts @@ -0,0 +1,19 @@ +import { OrderProps } from '..'; + +export interface PlaceOrderProps extends OrderProps { +} +export interface PlaceOrderResponse { + data: { + placeOrder?: { + errors?: { + code: string; + message: string; + }[]; + orderV2?: PlaceOrderProps; + }; + }; + errors?: { + message: string; + }[]; +} +//# sourceMappingURL=placeOrder.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts b/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts index 9454fae5bb..17aafb587b 100644 --- a/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/createReturn.types.d.ts @@ -27,6 +27,7 @@ export interface CreateReturnProps { showConfigurableOptions?: (options: options | {}) => options; } export interface ReturnOrderProductListProps { + placeholderImage: string; slots?: { ReturnOrderItem: SlotProps; }; @@ -41,6 +42,7 @@ export interface ReturnOrderProductListProps { handleChangeStep: (value: StepsTypes) => void; } export interface ReturnReasonFormProps { + placeholderImage: string; slots?: { ReturnFormActions: SlotProps<{ handleChangeStep: (value: StepsTypes) => void; diff --git a/scripts/__dropins__/storefront-order/types/index.d.ts b/scripts/__dropins__/storefront-order/types/index.d.ts index 0c1bb08da9..4322eb4855 100644 --- a/scripts/__dropins__/storefront-order/types/index.d.ts +++ b/scripts/__dropins__/storefront-order/types/index.d.ts @@ -1,23 +1,25 @@ -export * from './api/guestOrderByToken.types'; -export * from './api/getOrderDetails.types'; -export * from './api/getGuestOrder.types'; export * from './api/getAttributesForm.types'; +export * from './api/getAttributesList.types'; export * from './api/getCustomer.types'; export * from './api/getCustomerOrdersReturn.types'; -export * from './api/getAttributesList.types'; -export * from './api/requestReturn.types'; +export * from './api/getGuestOrder.types'; +export * from './api/getOrderDetails.types'; +export * from './api/guestOrderByToken.types'; +export * from './api/placeOrder.types'; export * from './api/reorderItems.types'; -export * from './orderSearch.types'; -export * from './form.types'; -export * from './orderStatus.types'; -export * from './shippingStatus.types'; +export * from './api/requestReturn.types'; +export * from './createReturn.types'; export * from './customerDetails.types'; -export * from './orderCancel.types'; -export * from './returnsList.types'; export * from './emptyList.types'; -export * from './orderProductList.types'; -export * from './orderCostSummary.types'; -export * from './createReturn.types'; +export * from './form.types'; export * from './notification.types'; +export * from './orderCancel.types'; +export * from './orderCostSummary.types'; +export * from './orderHeader.types'; +export * from './orderProductList.types'; +export * from './orderSearch.types'; +export * from './orderStatus.types'; export * from './reorder.types'; +export * from './returnsList.types'; +export * from './shippingStatus.types'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts b/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts index ceee817ad9..1578f9a786 100644 --- a/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/orderCostSummary.types.d.ts @@ -23,6 +23,7 @@ export interface OrderCostSummaryContentProps { } export interface UseOrderCostSummaryProps { orderData?: OrderDataModel; + config: StoreConfigModel | null; } export {}; //# sourceMappingURL=orderCostSummary.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderHeader.types.d.ts b/scripts/__dropins__/storefront-order/types/orderHeader.types.d.ts new file mode 100644 index 0000000000..8d0c15a079 --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/orderHeader.types.d.ts @@ -0,0 +1,19 @@ +import { OrderDataModel } from '../data/models'; + +export interface SignUpContext { + inputsDefaultValueSet: DefaultValues; + addressesData: any[]; +} +type DefaultValues = { + code: string; + defaultValue: string; +}[]; +export interface OrderHeaderProps { + handleEmailAvailability?: (email: string) => Promise; + handleSignUpClick?: (ctx: SignUpContext) => void; + orderData?: OrderDataModel; +} +export interface UseOrderHeaderProps extends OrderHeaderProps { +} +export {}; +//# sourceMappingURL=orderHeader.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderProductList.types.d.ts b/scripts/__dropins__/storefront-order/types/orderProductList.types.d.ts index 3e797fed12..027355ea02 100644 --- a/scripts/__dropins__/storefront-order/types/orderProductList.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/orderProductList.types.d.ts @@ -13,11 +13,13 @@ export interface OrderProductListProps { routeProductDetails?: (product: any) => string; } export interface OrderProductListContentProps extends Omit { + placeholderImage: string; order?: OrderDataModel; taxConfig: TaxTypes; loading: boolean; } export interface CartSummaryItemProps { + placeholderImage?: string; disabledIncrementer?: boolean; loading: boolean; itemType: string; diff --git a/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts b/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts index 17cf40f211..e06e0c2017 100644 --- a/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/returnsList.types.d.ts @@ -40,6 +40,7 @@ export interface ReturnsListProps { withThumbnails?: boolean; } export interface ReturnsListContentProps extends Omit { + placeholderImage?: string; minifiedViewKey: 'minifiedView' | 'fullSizeView'; orderReturns?: OrdersReturnPropsModel[] | []; translations: Record; diff --git a/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts b/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts index f546da4fa6..c6699b9f7b 100644 --- a/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts @@ -28,6 +28,7 @@ export interface UseShippingStatusProps { orderData?: OrderDataModel; } export interface ShippingStatusCardProps { + placeholderImage: string; translations: Record; slots?: { DeliveryTimeLine?: SlotProps; From cdb8af05c9749942bf76b4624657ddf3dd95f80b Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Sat, 7 Dec 2024 01:07:07 +0100 Subject: [PATCH 3/5] Fix cypress --- cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js b/cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js index a7691b68db..3519ddde2f 100644 --- a/cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js +++ b/cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js @@ -125,7 +125,7 @@ describe('Verify guest user can place order', () => { cy.get('.dropin-header-container__title', {timeout: 3000}) .should('exist') .and('be.visible') - .and('contain.text', 'cancellation requested'); + .and('contain.text', 'Cancellation requested'); cy.get(fields.cancellationReasonsModal).should('not.exist'); From 3ffd2166daba2ceb6188a50dc865a582864d1457 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Sat, 7 Dec 2024 02:39:27 +0100 Subject: [PATCH 4/5] Install 1.0.0 version of order dropin --- package-lock.json | 8 +-- package.json | 2 +- scripts/__dropins__/storefront-order/api.js | 4 +- .../confirmGuestReturn.d.ts | 2 + .../graphql/confirmGuestReturn.graphql.d.ts | 2 + .../api/confirmGuestReturn/index.d.ts | 2 + .../graphql/OrderSummaryFragment.graphql.d.ts | 2 +- .../storefront-order/api/index.d.ts | 3 + .../graphql/requestGuestReturn.graphql.d.ts | 2 + .../api/requestGuestReturn/index.d.ts | 2 + .../requestGuestReturn.d.ts | 9 +++ .../RequestReturnOrderFragment.graphql.js | 11 ++++ .../chunks/ReturnsListContent.js | 2 +- .../chunks/capitalizeFirst.js | 3 + .../chunks/confirmCancelOrder.js | 56 +++++++++++++++++++ .../storefront-order/chunks/getQueryParam.js | 3 + .../storefront-order/chunks/initialize.js | 8 ++- .../storefront-order/chunks/reorderItems.js | 20 ------- .../chunks/requestGuestOrderCancel.js | 12 ++-- .../chunks/requestGuestReturn.js | 54 ++++++++++++++++++ .../storefront-order/chunks/requestReturn.js | 53 ------------------ .../chunks/returnOrdersHelper.js | 2 +- .../OrderCostSummaryContent/Blocks.d.ts | 5 +- .../containers/CreateReturn.js | 2 +- .../containers/OrderCostSummary.js | 2 +- .../containers/OrderReturns.js | 2 +- .../containers/OrderSearch.js | 2 +- .../containers/OrderStatus.js | 20 +------ .../containers/ReturnsList.js | 2 +- .../containers/ShippingStatus.js | 2 +- .../data/models/order-details.d.ts | 3 +- .../containers/useConfirmCancelOrder.d.ts | 9 --- .../hooks/containers/useCreateReturn.d.ts | 3 +- .../hooks/containers/useOrderActions.d.ts | 12 ++++ .../storefront-order/hooks/index.d.ts | 1 + .../storefront-order/i18n/en_US.json.d.ts | 4 +- .../storefront-order/lib/getQueryParam.d.ts | 2 +- .../lib/removeQueryParams.d.ts | 2 + .../__dropins__/storefront-order/render.js | 4 +- .../types/api/confirmGuestReturn.types.d.ts | 18 ++++++ .../types/api/requestReturn.types.d.ts | 22 ++++++-- .../storefront-order/types/index.d.ts | 2 + .../types/orderCancel.types.d.ts | 2 +- .../types/orderEmailActionHandler.types.d.ts | 4 ++ 44 files changed, 249 insertions(+), 138 deletions(-) create mode 100644 scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/confirmGuestReturn/graphql/confirmGuestReturn.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/confirmGuestReturn/index.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/requestGuestReturn/graphql/requestGuestReturn.graphql.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/requestGuestReturn/index.d.ts create mode 100644 scripts/__dropins__/storefront-order/api/requestGuestReturn/requestGuestReturn.d.ts create mode 100644 scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js create mode 100644 scripts/__dropins__/storefront-order/chunks/capitalizeFirst.js create mode 100644 scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js create mode 100644 scripts/__dropins__/storefront-order/chunks/getQueryParam.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/reorderItems.js create mode 100644 scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/requestReturn.js delete mode 100644 scripts/__dropins__/storefront-order/hooks/containers/useConfirmCancelOrder.d.ts create mode 100644 scripts/__dropins__/storefront-order/hooks/containers/useOrderActions.d.ts create mode 100644 scripts/__dropins__/storefront-order/lib/removeQueryParams.d.ts create mode 100644 scripts/__dropins__/storefront-order/types/api/confirmGuestReturn.types.d.ts create mode 100644 scripts/__dropins__/storefront-order/types/orderEmailActionHandler.types.d.ts diff --git a/package-lock.json b/package-lock.json index e277b67281..2b58d1611f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "0.1.0-alpha32", + "@dropins/storefront-order": "1.0.0-beta1", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" }, @@ -783,9 +783,9 @@ "integrity": "sha512-w/6Me6NL1ImA8E3jSzazRihI6kLazVcOWTyXVycr0AgYz8Q2pBSCt9KlMzWZnFT9VsRuIn+wwMd8AsbQqQpetg==" }, "node_modules/@dropins/storefront-order": { - "version": "0.1.0-alpha32", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-0.1.0-alpha32.tgz", - "integrity": "sha512-kgoLuROfpMaenX8sJzHMWJxeY4OuQ11CVtTpkDQyxGi7jLhal1eR1ZLjF0MDC8/QZXWMME6OUodPHubQlqSXlw==" + "version": "1.0.0-beta1", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.0-beta1.tgz", + "integrity": "sha512-FIuwWkVS2e8rvgqwZXZdAkQJ6JC9kHPYt5hArRhJCqZzoI8BaJDYM1GgWT/FN5hmnDRw0Xg4HbBDCU5eaBfA+A==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0-beta3", diff --git a/package.json b/package.json index 974667ff55..694360a296 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "0.1.0-alpha32", + "@dropins/storefront-order": "1.0.0-beta1", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" } diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 4ecab87f4c..6de3ff0c18 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as H,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as _,h as T}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as tt,r as et}from"./chunks/requestReturn.js";import{g as at,a as ot}from"./chunks/getGuestOrder.js";import{g as st}from"./chunks/getCustomerOrdersReturn.js";import{c as m,P as R,a as A,G as D,O as g,B as O,b as h,A as C}from"./chunks/initialize.js";import{e as pt,g as ct,d as ut,i as dt}from"./chunks/initialize.js";import{g as Et}from"./chunks/getStoreConfig.js";import{h as f}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{r as Tt}from"./chunks/reorderItems.js";import"./chunks/GurestOrderFragment.graphql.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const M=(e,r)=>({id:e,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(t=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:t.id,quantity:t.totalQuantity,product:{canonicalUrl:((a=t.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=t.product)==null?void 0:o.image)??"",name:((n=t.product)==null?void 0:n.name)??"",productId:0,productType:(s=t.product)==null?void 0:s.productType,sku:((i=t.product)==null?void 0:i.sku)??""},prices:{price:{value:t.price.value,currency:t.price.currency}},configurableOptions:((p=t.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),G=e=>{var a,o,n;const r=e.coupons[0],t=(a=e.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:e.email,grandTotal:e.grandTotal.value,orderId:e.number,orderType:"checkout",otherTax:0,salesTax:e.totalTax.value,shipping:{shippingMethod:((o=e.shipping)==null?void 0:o.code)??"",shippingAmount:((n=e.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:e.subtotal.value,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:e.grandTotal.value}]:[]}},N=e=>{var t,a;const r=(a=(t=e==null?void 0:e.data)==null?void 0:t.placeOrder)==null?void 0:a.orderV2;return r?m(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(e,r){const t=E();t.push({[e]:null}),t.push({[e]:r})}function I(e,r){E().push(a=>{const o=a.getState?a.getState():{};a.push({event:e,eventInfo:{...o,...r}})})}function L(e,r){const t=G(r),a=M(e,r);l(d.ORDER_CONTEXT,{...t}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` +import{c as q,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as Y,r as z,s as j,a as J,b as K}from"./chunks/fetch-graphql.js";import{g as Z}from"./chunks/getAttributesForm.js";import{g as te,a as re,r as ae}from"./chunks/requestGuestReturn.js";import{g as ne,a as se}from"./chunks/getGuestOrder.js";import{g as pe}from"./chunks/getCustomerOrdersReturn.js";import{c as T,P as R,a as A,G as D,O as g,B as O,b as h,A as C}from"./chunks/initialize.js";import{e as ue,g as de,d as le,i as me}from"./chunks/initialize.js";import{g as _e}from"./chunks/getStoreConfig.js";import{h as f}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{a as Re,c as Ae,r as De}from"./chunks/confirmCancelOrder.js";import"./chunks/GurestOrderFragment.graphql.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"./chunks/RequestReturnOrderFragment.graphql.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -89,4 +89,4 @@ import{c as H,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as _,h a ${O} ${h} ${C} -`,k=async e=>{if(!e)throw new Error("No cart ID found");return _(S,{variables:{cartId:e}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&T(r.errors);const t=N(r);return t&&(u.emit("order/placed",t),u.emit("cart/reset",void 0),L(e,t)),t}).catch(f)};export{H as cancelOrder,pt as config,_ as fetchGraphQl,W as getAttributesForm,tt as getAttributesList,V as getConfig,at as getCustomer,st as getCustomerOrdersReturn,ot as getGuestOrder,ct as getOrderDetailsById,Et as getStoreConfig,ut as guestOrderByToken,dt as initialize,k as placeOrder,Y as removeFetchGraphQlHeader,Tt as reorderItems,X as requestGuestOrderCancel,et as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; +`,Q=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(f)};export{q as cancelOrder,ue as config,Re as confirmCancelOrder,Ae as confirmGuestReturn,E as fetchGraphQl,Z as getAttributesForm,te as getAttributesList,Y as getConfig,ne as getCustomer,pe as getCustomerOrdersReturn,se as getGuestOrder,de as getOrderDetailsById,_e as getStoreConfig,le as guestOrderByToken,me as initialize,Q as placeOrder,z as removeFetchGraphQlHeader,De as reorderItems,X as requestGuestOrderCancel,re as requestGuestReturn,ae as requestReturn,j as setEndpoint,J as setFetchGraphQlHeader,K as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts new file mode 100644 index 0000000000..2711506a10 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/confirmGuestReturn.d.ts @@ -0,0 +1,2 @@ +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/confirmGuestReturn/graphql/confirmGuestReturn.graphql.d.ts b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/graphql/confirmGuestReturn.graphql.d.ts new file mode 100644 index 0000000000..95af93e910 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/graphql/confirmGuestReturn.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const CONFIRM_RETURN_GUEST_ORDER: string; +//# sourceMappingURL=confirmGuestReturn.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/confirmGuestReturn/index.d.ts b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/index.d.ts new file mode 100644 index 0000000000..03db300d09 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/confirmGuestReturn/index.d.ts @@ -0,0 +1,2 @@ +export * from './confirmGuestReturn'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts index 94c708b81c..716d4ebe38 100644 --- a/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/graphql/OrderSummaryFragment.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; +export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal_excl_tax {\n currency\n value\n }\n subtotal_incl_tax {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; //# sourceMappingURL=OrderSummaryFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/index.d.ts b/scripts/__dropins__/storefront-order/api/index.d.ts index 0b19030217..3a572a4507 100644 --- a/scripts/__dropins__/storefront-order/api/index.d.ts +++ b/scripts/__dropins__/storefront-order/api/index.d.ts @@ -13,4 +13,7 @@ export * from './placeOrder'; export * from './reorderItems'; export * from './requestGuestOrderCancel'; export * from './requestReturn'; +export * from './requestGuestReturn'; +export * from './confirmGuestReturn'; +export * from './confirmCancelOrder'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/requestGuestReturn/graphql/requestGuestReturn.graphql.d.ts b/scripts/__dropins__/storefront-order/api/requestGuestReturn/graphql/requestGuestReturn.graphql.d.ts new file mode 100644 index 0000000000..b9a8c0f202 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/requestGuestReturn/graphql/requestGuestReturn.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const REQUEST_RETURN_GUEST_ORDER: string; +//# sourceMappingURL=requestGuestReturn.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/requestGuestReturn/index.d.ts b/scripts/__dropins__/storefront-order/api/requestGuestReturn/index.d.ts new file mode 100644 index 0000000000..bcca4ec752 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/requestGuestReturn/index.d.ts @@ -0,0 +1,2 @@ +export * from './requestGuestReturn'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/requestGuestReturn/requestGuestReturn.d.ts b/scripts/__dropins__/storefront-order/api/requestGuestReturn/requestGuestReturn.d.ts new file mode 100644 index 0000000000..7c96cb4914 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/requestGuestReturn/requestGuestReturn.d.ts @@ -0,0 +1,9 @@ +import { RequestGuestReturnProps } from '../../types'; + +export declare const requestGuestReturn: (form: RequestGuestReturnProps) => Promise<{ + uid: string; + number: string; + status: string; + createdAt: string; +}>; +//# sourceMappingURL=requestGuestReturn.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js new file mode 100644 index 0000000000..fbf77e337f --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js @@ -0,0 +1,11 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const R=` + fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { + __typename + uid + status + number + created_at + } +`;export{R}; diff --git a/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js index 0e8cf12c0c..dd9c2eeb08 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 L,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as V}from"@dropins/tools/preact-hooks.js";import{classes as I,Slot as Q}from"@dropins/tools/lib.js";import{IllustratedMessage as t1,Icon as A,Card as U,ContentGrid as n1,Image as a1,Header as J,Pagination as L1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as c1}from"@dropins/tools/preact-compat.js";import"./ShippingStatusCard.js";import{f as i1}from"./returnOrdersHelper.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{C as T}from"./OrderLoaders.js";import{Text as W}from"@dropins/tools/i18n.js";const X=c=>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",...c},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"})))),s1=c=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},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"})),Y=({typeList:c,isEmpty:C,minifiedView:g,message:M})=>{const t=c1(()=>{switch(c){case"orders":return{icon:s1,text:r("p",{children:M}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[c,M]);return!C||!c||!t.text?null:r(t1,{className:I(["order-empty-list",t.className,g?"order-empty-list--minified":""]),message:t.text,icon:r(A,{source:t.icon}),"data-testid":"emptyList"})},K={size:"32",stroke:"2"},g1=({placeholderImage:c,minifiedViewKey:C,withReturnNumber:g=!1,withOrderNumber:M=!1,slots:t,pageInfo:i,withReturnsListButton:B=!0,isMobile:$=!1,returnsInMinifiedView:R=1,translations:a={},orderReturns:s=[],minifiedView:h=!1,withHeader:f=!0,withThumbnails:S=!0,selectedPage:k=1,handleSetSelectPage:z,routeReturnDetails:d,routeOrderDetails:v,routeTracking:b,routeReturnsList:x,routeProductDetails:m,loading:y})=>{const j=h?R:s.length,F=m!=null&&m()?"a":"span",H=V(()=>s.slice(0,j).map((e,e1)=>{var G,q;const w=((e==null?void 0:e.items)??[]).reduce((n,Z)=>(Z.requestQuantity??0)+n,0);return r(U,{variant:"secondary",className:"order-returns-list-content__cards-list",children:L("div",{className:"order-returns-list-content__cards-grid",children:[L("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(W,{id:`Order.Returns.${C}.returnsList.returnStatus.${i1(e.returnStatus)}`})}),g?L("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?L("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,Z)=>{var _,p;const u={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(u),o=`${u.number}_${Z}`;return L("p",{children:[`${a.carrier} `,`${(p=u.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?L("p",{children:[w," ",r(W,{id:`Order.Returns.${C}.returnsList.itemText`,plural:w,fields:{count:w}})]}):null]}),S?r(n1,{maxColumns:$?3:9,emptyGridContent:r(N,{}),className:I(["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,Z)=>{var _,p,O,P;const u=(_=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:c,o=`key_${Z}_${n.uid}`;return r(F,{"data-testid":o,href:(m==null?void 0:m(n))??"#",children:r(a1,{alt:u,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(A,{source:X,...K})})]})},e1)}),[s,j,C,g,a,M,t,S,$,c,F,b,m,d,v]),D=V(()=>L(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,y?r(T,{withCard:!1}):L(N,{children:[H,r(Y,{minifiedView:h,typeList:"orders",isEmpty:!s.length,message:a.emptyOrdersListMessage}),B?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:L("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:a.viewAllOrdersButton}),r(A,{source:X,...K})]})})}):null]})]}),[x,B,f,a,H,h,s.length,y]),r1=V(()=>L(N,{children:[f?r(J,{title:a.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,y?r(T,{withCard:!1}):L(N,{children:[r(Y,{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?D:r1})};export{g1 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/capitalizeFirst.js b/scripts/__dropins__/storefront-order/chunks/capitalizeFirst.js new file mode 100644 index 0000000000..a8297f4927 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/capitalizeFirst.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const a=e=>e&&e.charAt(0).toLocaleUpperCase()+e.slice(1).toLocaleLowerCase();export{a as c}; diff --git a/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js new file mode 100644 index 0000000000..0c05980aae --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js @@ -0,0 +1,56 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql.js";import{R as I}from"./RequestReturnOrderFragment.graphql.js";import{G as a}from"./GurestOrderFragment.graphql.js";import{c as O}from"./initialize.js";import{events as T}from"@dropins/tools/event-bus.js";const N=` + mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { + reorderItems(orderNumber: $orderNumber) { + cart { + itemsV2 { + items { + uid + } + } + } + userInputErrors { + code + message + path + } + } + } +`,$=async E=>await u(N,{method:"POST",variables:{orderNumber:E}}).then(t=>{var n,o,i,c,m,R;if((n=t.errors)!=null&&n.length)return _(t.errors);const e=!!((c=(i=(o=t==null?void 0:t.data)==null?void 0:o.reorderItems)==null?void 0:i.cart)!=null&&c.itemsV2.items.length),r=((R=(m=t==null?void 0:t.data)==null?void 0:m.reorderItems)==null?void 0:R.userInputErrors)??[];return{success:e,userInputErrors:r}}).catch(d),l=` + mutation CONFIRM_RETURN_GUEST_ORDER( + $orderId: ID! + $confirmationKey: String! + ) { + confirmReturn( + input: { order_id: $orderId, confirmation_key: $confirmationKey } + ) { + return { + ...REQUEST_RETURN_ORDER_FRAGMENT + order { + ...GUEST_ORDER_FRAGMENT + } + } + } + } + ${I} + ${a} +`,s=async(E,t)=>await u(l,{method:"POST",variables:{orderId:E,confirmationKey:t}}).then(e=>{var r,n,o,i,c,m,R;if((r=e.errors)!=null&&r.length)return _(e.errors);if((i=(o=(n=e==null?void 0:e.data)==null?void 0:n.confirmReturn)==null?void 0:o.return)!=null&&i.order){const f=O((R=(m=(c=e==null?void 0:e.data)==null?void 0:c.confirmReturn)==null?void 0:m.return)==null?void 0:R.order);return T.emit("order/data",f),f}return null}).catch(d),h=` + mutation CONFIRM_CANCEL_ORDER_MUTATION( + $orderId: ID! + $confirmationKey: String! + ) { + confirmCancelOrder( + input: { order_id: $orderId, confirmation_key: $confirmationKey } + ) { + order { + ...GUEST_ORDER_FRAGMENT + } + errorV2 { + message + code + } + } + } + ${a} +`,y=async(E,t)=>u(h,{variables:{orderId:E,confirmationKey:t}}).then(async({errors:e,data:r})=>{var i,c,m,R;const n=[...(i=r==null?void 0:r.confirmCancelOrder)!=null&&i.errorV2?[(c=r==null?void 0:r.confirmCancelOrder)==null?void 0:c.errorV2]:[],...e??[]];let o=null;return(m=r==null?void 0:r.confirmCancelOrder)!=null&&m.order&&(o=O((R=r==null?void 0:r.confirmCancelOrder)==null?void 0:R.order),T.emit("order/data",o)),n.length>0?_(n):o});export{y as a,s as c,$ as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/getQueryParam.js b/scripts/__dropins__/storefront-order/chunks/getQueryParam.js new file mode 100644 index 0000000000..29459cba0e --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/getQueryParam.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const t=r=>{try{return new URL(window.location.href).searchParams.get(r)??""}catch{return""}};export{t as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js index 2510c9abfa..ed56d3ced3 100644 --- a/scripts/__dropins__/storefront-order/chunks/initialize.js +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -126,7 +126,11 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as currency value } - subtotal { + subtotal_excl_tax { + currency + value + } + subtotal_incl_tax { currency value } @@ -195,7 +199,7 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } -`,_a=a=>a||0,ua=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)||""}}},ea=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},ia=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(e=>e.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},sa=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,la=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 E,c,r,O,d,g,N,M,A,D,u,y,T,p,S,f,o,G,h,F,C,L,k,U,B,$,P,m,w,x;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R}=la(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:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((O=(r=(c=(E=n==null?void 0:n.product)==null?void 0:E.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)!==((d=n==null?void 0:n.product_sale_price)==null?void 0:d.value)*(n==null?void 0:n.quantity_ordered),total:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.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:((y=n==null?void 0:n.product_sale_price)==null?void 0:y.value)||0,currency:(T=n==null?void 0:n.product_sale_price)==null?void 0:T.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(o=(f=(S=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:S.maximum_price)==null?void 0:f.regular_price)==null?void 0:o.value,currency:(C=(F=(h=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:h.maximum_price)==null?void 0:F.regular_price)==null?void 0:C.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((k=(L=n==null?void 0:n.product)==null?void 0:L.thumbnail)==null?void 0:k.label)||"",url:((B=(U=n==null?void 0:n.product)==null?void 0:U.thumbnail)==null?void 0:B.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:(($=n.gift_card)==null?void 0:$.sender_name)||"",senderEmail:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((m=n.gift_card)==null?void 0:m.recipient_email)||"",recipientName:((w=n.gift_card)==null?void 0:w.recipient_name)||"",message:((x=n.gift_card)==null?void 0:x.message)||""}:void 0,configurableOptions:ea(n),bundleOptions:n.__typename==="BundleOrderItem"?ia(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?sa(n==null?void 0:n.downloadable_links):null}}),v=(a,n)=>{var O,d,g,N,M,A,D,u,y;const t=I(a.items),_=((O=ra(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],e=n?_.filter(T=>T.returnNumber===n):_,{total:i,...s}=ta({...a,items:t,returns:e},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(d=a==null?void 0:a.payment_methods)==null?void 0:d[0],R=(l==null?void 0:l.type)||"",E=(l==null?void 0:l.name)||"",c=(g=s==null?void 0:s.items)==null?void 0:g.reduce((T,p)=>T+(p==null?void 0:p.totalQuantity),0),r={...i,...s,totalQuantity:c,shipping:{amount:((N=i==null?void 0:i.totalShipping)==null?void 0:N.value)??0,currency:((M=i==null?void 0:i.totalShipping)==null?void 0:M.currency)||"",code:s.shippingMethod??""},payments:[{code:R,name:E}]};return z(r,(y=(u=(D=(A=b==null?void 0:b.getConfig())==null?void 0:A.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:y.call(u,a))},ca=(a,n,t)=>{var _,e,i,s,l,R,E;if((s=(i=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:i.items)!=null&&s.length&&a==="orderData"){const c=(E=(R=(l=n==null?void 0:n.data)==null?void 0:l.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return v(c,t)}return null},ra=a=>{var i,s,l,R,E;if(!((i=a==null?void 0:a.items)!=null&&i.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,e={ordersReturn:[...n].sort((c,r)=>+r.number-+c.number).map(c=>{var A,D;const{order:r,status:O,number:d,created_at:g}=c,N=((D=(A=c==null?void 0:c.shipping)==null?void 0:A.tracking)==null?void 0:D.map(u=>{const{status:y,carrier:T,tracking_number:p}=u;return{status:y,carrier:T,trackingNumber:p}}))??[],M=c.items.map(u=>{var G;const y=u==null?void 0:u.quantity,T=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,S=u==null?void 0:u.uid,f=u==null?void 0:u.order_item,o=((G=I([f]))==null?void 0:G.reduce((h,F)=>F,{}))??{};return{uid:S,quantity:y,status:T,requestQuantity:p,...o}});return{createdReturnAt:g,returnStatus:O,token:r==null?void 0:r.token,orderNumber:r==null?void 0:r.number,returnNumber:d,items:M,tracking:N}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return z(e,(E=(R=(l=(s=b==null?void 0:b.getConfig())==null?void 0:s.models)==null?void 0:l.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Ma=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrder;return v(t,n)},Ra=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrderByToken;return v(t,n)},Ea=` +`,_a=a=>a||0,ua=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)||""}}},ea=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},ia=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(e=>e.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},sa=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,la=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 E,c,r,O,d,g,N,M,A,D,u,y,T,p,S,o,f,G,h,F,C,L,k,U,B,$,P,x,m,w;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R}=la(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:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((O=(r=(c=(E=n==null?void 0:n.product)==null?void 0:E.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)!==((d=n==null?void 0:n.product_sale_price)==null?void 0:d.value)*(n==null?void 0:n.quantity_ordered),total:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.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:((y=n==null?void 0:n.product_sale_price)==null?void 0:y.value)||0,currency:(T=n==null?void 0:n.product_sale_price)==null?void 0:T.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(f=(o=(S=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:S.maximum_price)==null?void 0:o.regular_price)==null?void 0:f.value,currency:(C=(F=(h=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:h.maximum_price)==null?void 0:F.regular_price)==null?void 0:C.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((k=(L=n==null?void 0:n.product)==null?void 0:L.thumbnail)==null?void 0:k.label)||"",url:((B=(U=n==null?void 0:n.product)==null?void 0:U.thumbnail)==null?void 0:B.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:(($=n.gift_card)==null?void 0:$.sender_name)||"",senderEmail:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((x=n.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((m=n.gift_card)==null?void 0:m.recipient_name)||"",message:((w=n.gift_card)==null?void 0:w.message)||""}:void 0,configurableOptions:ea(n),bundleOptions:n.__typename==="BundleOrderItem"?ia(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?sa(n==null?void 0:n.downloadable_links):null}}),v=(a,n)=>{var O,d,g,N,M,A,D,u,y;const t=I(a.items),_=((O=ra(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],e=n?_.filter(T=>T.returnNumber===n):_,{total:i,...s}=ta({...a,items:t,returns:e},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(d=a==null?void 0:a.payment_methods)==null?void 0:d[0],R=(l==null?void 0:l.type)||"",E=(l==null?void 0:l.name)||"",c=(g=s==null?void 0:s.items)==null?void 0:g.reduce((T,p)=>T+(p==null?void 0:p.totalQuantity),0),r={...i,...s,totalQuantity:c,shipping:{amount:((N=i==null?void 0:i.totalShipping)==null?void 0:N.value)??0,currency:((M=i==null?void 0:i.totalShipping)==null?void 0:M.currency)||"",code:s.shippingMethod??""},payments:[{code:R,name:E}]};return z(r,(y=(u=(D=(A=b==null?void 0:b.getConfig())==null?void 0:A.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:y.call(u,a))},ca=(a,n,t)=>{var _,e,i,s,l,R,E;if((s=(i=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:i.items)!=null&&s.length&&a==="orderData"){const c=(E=(R=(l=n==null?void 0:n.data)==null?void 0:l.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return v(c,t)}return null},ra=a=>{var i,s,l,R,E;if(!((i=a==null?void 0:a.items)!=null&&i.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,e={ordersReturn:[...n].sort((c,r)=>+r.number-+c.number).map(c=>{var A,D;const{order:r,status:O,number:d,created_at:g}=c,N=((D=(A=c==null?void 0:c.shipping)==null?void 0:A.tracking)==null?void 0:D.map(u=>{const{status:y,carrier:T,tracking_number:p}=u;return{status:y,carrier:T,trackingNumber:p}}))??[],M=c.items.map(u=>{var G;const y=u==null?void 0:u.quantity,T=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,S=u==null?void 0:u.uid,o=u==null?void 0:u.order_item,f=((G=I([o]))==null?void 0:G.reduce((h,F)=>F,{}))??{};return{uid:S,quantity:y,status:T,requestQuantity:p,...f}});return{createdReturnAt:g,returnStatus:O,token:r==null?void 0:r.token,orderNumber:r==null?void 0:r.number,returnNumber:d,items:M,tracking:N}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return z(e,(E=(R=(l=(s=b==null?void 0:b.getConfig())==null?void 0:s.models)==null?void 0:l.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Ma=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrder;return v(t,n)},Ra=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrderByToken;return v(t,n)},Ea=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders(filter: { number: { eq: $orderNumber } }) { diff --git a/scripts/__dropins__/storefront-order/chunks/reorderItems.js b/scripts/__dropins__/storefront-order/chunks/reorderItems.js deleted file mode 100644 index adcf632ac6..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/reorderItems.js +++ /dev/null @@ -1,20 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{h as i}from"./network-error.js";import{f as E,h as I}from"./fetch-graphql.js";const s=` - mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { - reorderItems(orderNumber: $orderNumber) { - cart { - itemsV2 { - items { - uid - } - } - } - userInputErrors { - code - message - path - } - } - } -`,l=async c=>await E(s,{method:"POST",variables:{orderNumber:c}}).then(r=>{var t,e,a,m,o,u;if((t=r.errors)!=null&&t.length)return I(r.errors);const d=!!((m=(a=(e=r==null?void 0:r.data)==null?void 0:e.reorderItems)==null?void 0:a.cart)!=null&&m.itemsV2.items.length),h=((u=(o=r==null?void 0:r.data)==null?void 0:o.reorderItems)==null?void 0:u.userInputErrors)??[];return{success:d,userInputErrors:h}}).catch(i);export{l as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js index 067577d243..f135fe1bcb 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{P as d,a as T,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize.js";import{f as s,h as R}from"./fetch-graphql.js";import{G as O}from"./GurestOrderFragment.graphql.js";const G=` +import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize.js";import{f as s,h as R}from"./fetch-graphql.js";import{G}from"./GurestOrderFragment.graphql.js";const O=` mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { cancelOrder(input: { order_id: $orderId, reason: $reason }) { error @@ -79,14 +79,14 @@ import{P as d,a as T,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize } } } - ${d} ${T} + ${d} ${i} ${A} ${D} ${c} ${u} -`,M=async(r,e,n,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return s(G,{variables:{orderId:r,reason:e}}).then(({errors:o,data:a})=>{if(o)return R(o);if(a.cancelOrder.error!=null){t();return}const _=E(a.cancelOrder.order);n(_)}).catch(()=>t())},l=` +`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return s(O,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const a=E(n.cancelOrder.order);_(a)}).catch(()=>t())},N=` mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION( $token: String! $reason: String! @@ -94,9 +94,9 @@ import{P as d,a as T,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize requestGuestOrderCancel(input: { token: $token, reason: $reason }) { error order { - ...guestOrderData + ...GUEST_ORDER_FRAGMENT } } } - ${O} -`,S=async(r,e,n,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return s(l,{variables:{token:r,reason:e}}).then(({errors:o,data:a})=>{if(o)return R(o);a.requestGuestOrderCancel.error!=null&&t();const _=E(a.requestGuestOrderCancel.order);n(_)}).catch(()=>t())};export{M as c,S as r}; + ${G} +`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return s(N,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const a=E(n.requestGuestOrderCancel.order);_(a)}).catch(()=>t())};export{M as c,S as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js new file mode 100644 index 0000000000..445a3d5263 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js @@ -0,0 +1,54 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql.js";import{t as d}from"./transform-attributes-form.js";import{R as m}from"./RequestReturnOrderFragment.graphql.js";import{merge as l}from"@dropins/tools/lib.js";import{e as f}from"./initialize.js";const h=r=>{var u,n,E,c,R,T;if(!((n=(u=r==null?void 0:r.data)==null?void 0:u.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,a={...t,createdAt:e};return l(a,(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 { + ... on CustomerAttributeMetadata { + multiline_count + sort_order + validate_rules { + name + value + } + } + ... on ReturnItemAttributeMetadata { + sort_order + } + code + label + default_value + frontend_input + is_unique + is_required + options { + is_default + label + value + } + } + errors { + type + message + } + } + } +`,g=async r=>await s(U,{method:"GET",cache:"force-cache",variables:{entityType:r}}).then(e=>{var t,a,u;return(t=e.errors)!=null&&t.length?o(e.errors):d((u=(a=e==null?void 0:e.data)==null?void 0:a.attributesList)==null?void 0:u.items)}).catch(i),q=` + mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { + requestReturn(input: $input) { + return { + ...REQUEST_RETURN_ORDER_FRAGMENT + } + } + } + ${m} +`,O=async r=>{const e=_(r,"snakeCase",{});return await s(q,{method:"POST",variables:{input:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?o(t.errors):h(t)}).catch(i)},S=` + mutation REQUEST_RETURN_GUEST_ORDER($input: RequestGuestReturnInput!) { + requestGuestReturn(input: $input) { + return { + ...REQUEST_RETURN_ORDER_FRAGMENT + } + } + } + ${m} +`,v=async r=>{const e=_(r,"snakeCase",{});return await s(S,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return o(t.errors);const{created_at:a,...u}=t.data.requestGuestReturn.return;return{...u,createdAt:a}}).catch(i)};export{v as a,g,O as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestReturn.js deleted file mode 100644 index cdc8685819..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/requestReturn.js +++ /dev/null @@ -1,53 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{h as E,a as c}from"./network-error.js";import{f as m,h as _}from"./fetch-graphql.js";import{t as T}from"./transform-attributes-form.js";import{merge as d}from"@dropins/tools/lib.js";import{e as l}from"./initialize.js";const f=` - fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { - __typename - uid - status - number - created_at - } -`,h=t=>{var u,i,R,o,n,s;if(!((i=(u=t==null?void 0:t.data)==null?void 0:u.requestReturn)!=null&&i.return))return{};const{created_at:e,...r}=t.data.requestReturn.return,a={...r,createdAt:e};return d(a,(s=(n=(o=(R=l.getConfig())==null?void 0:R.models)==null?void 0:o.RequestReturnModel)==null?void 0:n.transformer)==null?void 0:s.call(n,t.data.requestReturn.return))},y=` - query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { - attributesList(entityType: $entityType) { - items { - ... on CustomerAttributeMetadata { - multiline_count - sort_order - validate_rules { - name - value - } - } - ... on ReturnItemAttributeMetadata { - sort_order - } - code - label - default_value - frontend_input - is_unique - is_required - options { - is_default - label - value - } - } - errors { - type - message - } - } - } -`,N=async t=>await m(y,{method:"GET",cache:"force-cache",variables:{entityType:t}}).then(e=>{var r,a,u;return(r=e.errors)!=null&&r.length?_(e.errors):T((u=(a=e==null?void 0:e.data)==null?void 0:a.attributesList)==null?void 0:u.items)}).catch(E),b=` - mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { - requestReturn(input: $input) { - return { - ...REQUEST_RETURN_ORDER_FRAGMENT - } - } - } - ${f} -`,p=async t=>{const e=c(t,"snakeCase",{});return await m(b,{method:"POST",variables:{input:e}}).then(r=>{var a;return(a=r.errors)!=null&&a.length?_(r.errors):h(r)}).catch(E)};export{N as g,p as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js index 8676d96c05..07dcb6203f 100644 --- a/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js +++ b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{g as p,F as o}from"./getFormValues.js";const d={PENDING:"pending",AUTHORIZED:"authorized",PARTIALLY_AUTHORIZED:"partiallyAuthorized",RECEIVED:"received",PARTIALLY_RECEIVED:"partiallyReceived",APPROVED:"approved",PARTIALLY_APPROVED:"partiallyApproved",REJECTED:"rejected",PARTIALLY_REJECTED:"partiallyRejected",DENIED:"denied",PROCESSED_AND_CLOSED:"processedAndClosed",CLOSED:"closed"},u=(t,e)=>({id:`${t.id}_${t.fieldType}_${e+1}`,name:`${t.name}_${t.fieldType}_${e+1}`,code:`${t.code}_${t.fieldType}_${e+1}`,customUpperCode:`${t.customUpperCode}_${t.fieldType}_${e+1}`}),E=t=>{const e={};return!t||typeof t!="object"||Object.keys(t).length===0||Object.keys(t).forEach(n=>{if(/_(\d+)$/.exec(n)){const i=n==null?void 0:n.replace(/_\d+$/,"");e[i]=t[n]}else e[n]=t[n]}),e},A=(t,e)=>t.map(n=>({...n,...u(n,e)})),C=(t,e)=>t==null?void 0:t.flatMap(n=>Array.from({length:e},(s,i)=>({...n,...u(n,i)}))),l=t=>{const e=[],n=[];return Object.entries(t).forEach(([s,i])=>{const a=s.lastIndexOf("_"),r=s.slice(0,a),c=s.slice(a+1);c===o.MULTISELECT||c===o.SELECT?e.push({attributeCode:r,value:i}):n.push({attributeCode:r,value:i})}),{selectedCustomAttributes:e,enteredCustomAttributes:n}},_=t=>typeof t!="string"?"":d[t]??"",f=t=>{var n;const e=[];if(t!=null&&t.current.length)for(const{current:s}of t.current){if(!s)continue;const i=s.name.replace(/_\d+$/,""),a=((n=s==null?void 0:s.dataset)==null?void 0:n.quantity)??1,r=p(s),c=E(r);e.push({orderItemUid:i,quantityToReturn:+a,...l(c)})}return e},T=t=>{var e;return(e=t==null?void 0:t.items)!=null&&e.length?[...(t==null?void 0:t.items)??[]].sort((n,s)=>{const i=n.quantityShipped-n.quantityReturnRequested===0,a=s.quantityShipped-s.quantityReturnRequested===0;return i&&!a?1:!i&&a?-1:0}):[]};export{_ as f,A as m,f as p,C as r,T as s}; +import{g as p,F as c}from"./getFormValues.js";const d={PENDING:"pending",AUTHORIZED:"authorized",PARTIALLY_AUTHORIZED:"partiallyAuthorized",RECEIVED:"received",PARTIALLY_RECEIVED:"partiallyReceived",APPROVED:"approved",PARTIALLY_APPROVED:"partiallyApproved",REJECTED:"rejected",PARTIALLY_REJECTED:"partiallyRejected",DENIED:"denied",PROCESSED_AND_CLOSED:"processedAndClosed",CLOSED:"closed"},u=(t,n)=>({id:`${t.id}_${t.fieldType}_${n+1}`,name:`${t.name}_${t.fieldType}_${n+1}`,code:`${t.code}_${t.fieldType}_${n+1}`,customUpperCode:`${t.customUpperCode}_${t.fieldType}_${n+1}`}),l=t=>{const n={};return!t||typeof t!="object"||Object.keys(t).length===0||Object.keys(t).forEach(e=>{if(/_(\d+)$/.exec(e)){const s=e==null?void 0:e.replace(/_\d+$/,"");n[s]=t[e]}else n[e]=t[e]}),n},f=(t,n)=>t.map(e=>({...e,...u(e,n)})),A=(t,n)=>t==null?void 0:t.flatMap(e=>Array.from({length:n},(i,s)=>({...e,...u(e,s)}))),E=t=>{const n=[],e=[];return Object.entries(t).forEach(([i,s])=>{const r=i.lastIndexOf("_"),o=i.slice(0,r),a=i.slice(r+1);a===c.MULTISELECT||a===c.SELECT?n.push({attributeCode:o,value:s}):e.push({attributeCode:o,value:s})}),{selectedCustomAttributes:n,enteredCustomAttributes:e}},C=t=>typeof t!="string"?"":d[t]??"",R=t=>{var e;const n=[];if(t!=null&&t.current.length)for(const{current:i}of t.current){if(!i)continue;const s=i.name.replace(/_\d+$/,""),r=((e=i==null?void 0:i.dataset)==null?void 0:e.quantity)??1,o=p(i),a=l(o);n.push({orderItemUid:s,quantityToReturn:+r,...E(a)})}return n},_=t=>{var n;return(n=t==null?void 0:t.items)!=null&&n.length?[...(t==null?void 0:t.items)??[]].sort((e,i)=>{const s=e.quantityShipped-e.quantityReturnRequested===0,r=i.quantityShipped-i.quantityReturnRequested===0;return e.eligibleForReturn&&!i.eligibleForReturn?-1:!e.eligibleForReturn&&i.eligibleForReturn||s&&!r?1:!s&&r?-1:0}):[]};export{C as f,f as m,R as p,A as r,_ as s}; diff --git a/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts b/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts index 23bca034cb..1c01bb58dd 100644 --- a/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts +++ b/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts @@ -2,10 +2,11 @@ import { OrderDataModel } from '../../data/models'; import { TaxTypes } from '../../types'; type translationsTypes = Record; -export declare const Subtotal: ({ translations, order, subTotalValue, shoppingOrdersDisplaySubtotal, }: { +export declare const Subtotal: ({ translations, order, subtotalInclTax, subtotalExclTax, shoppingOrdersDisplaySubtotal, }: { translations: translationsTypes; order?: OrderDataModel | undefined; - subTotalValue: number; + subtotalInclTax: number; + subtotalExclTax: number; shoppingOrdersDisplaySubtotal: TaxTypes; }) => import("preact").JSX.Element; export declare const Shipping: ({ translations, shoppingOrdersDisplayShipping, order, totalShipping, }: { diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index 8f7909990e..a4eda97a2b 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 x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as P}from"@dropins/tools/lib.js";import{Icon as H,Header as $,InLineAlert as W,Button as F,Checkbox as j,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as q,useCallback as E}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as C from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import{createRef as J,Fragment as K}from"@dropins/tools/preact.js";import{s as X,p as Y,r as I,m as ee}from"../chunks/returnOrdersHelper.js";import{events as te}from"@dropins/tools/event-bus.js";import{g as ne,r as re}from"../chunks/requestReturn.js";import{s as se}from"../chunks/setTaxStatus.js";import{S as ae,C as ce}from"../chunks/CartSummaryItem.js";import{a as ie}from"../chunks/OrderLoaders.js";import{useText as ue}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"../chunks/initialize.js";const oe=a=>C.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},C.createElement("g",{clipPath:"url(#clip0_841_1324)"},C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),C.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"})),C.createElement("defs",null,C.createElement("clipPath",{id:"clip0_841_1324"},C.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),le=a=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},C.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"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),de=({onSuccess:a,onError:s,handleSetInLineAlert:c,orderData:l})=>{const[g,O]=w({id:"",email:"",...l}),[d,f]=w("products"),[L,k]=w(!0),[p,m]=w([]),[_,R]=w([]),[y,t]=w([]),u=D([]);u.current.length!==p.length&&(u.current=p.map((n,o)=>u.current[o]||J())),q(()=>{const n=te.on("order/data",o=>{O(o);const S=X(o);t(S),k(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),q(()=>{ne("RMA_ITEM").then(n=>{n!=null&&n.length&&(R(n),k(!1))})},[]);const e=E(n=>{m(o=>o.findIndex(h=>(h==null?void 0:h.productSku)===(n==null?void 0:n.productSku))>-1?o.filter(h=>(h==null?void 0:h.productSku)!==(n==null?void 0:n.productSku)):[...o,n])},[]),i=E(n=>{f(n),c(),n==="products"&&m([])},[c]),b=E((n,o)=>{const S=p.map(h=>h.productSku===o?{...h,currentReturnOrderQuantity:n}:h);m(S)},[p]),N=E(async(n,o)=>{if(!o)return;k(!0);const S={orderUid:g.id,contactEmail:g.email},h=Y(u);re({...S,items:h}).then(v=>{a==null||a(v),i("success"),c()}).catch(v=>{s==null||s(v.message),c({type:"error",heading:v.message})}),k(!1)},[i,s,a,c,g]);return{order:g,steps:d,loading:L,formsRef:u,attributesList:_,selectedProductList:p,itemsEligibleForReturn:y,handleSelectedProductList:e,handleSetQuantity:b,handleChangeStep:i,onSubmit:N}},pe={success:le,warning:oe,error:ae},he=()=>{const[a,s]=w({type:"success",heading:""}),c=E(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const g=r(H,{source:pe[l.type]});s({...l,icon:g})},[]);return{inLineAlertProps:a,handleSetInLineAlert:c}},Pe=({className:a,orderData:s,slots:c,onSuccess:l,onError:g,routeReturnSuccess:O,showConfigurableOptions:d})=>{const f=ue({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:L,handleSetInLineAlert:k}=he(),p=G(),{order:m,itemsEligibleForReturn:_,formsRef:R,attributesList:y,steps:t,loading:u,selectedProductList:e,handleSelectedProductList:i,handleSetQuantity:b,handleChangeStep:N,onSubmit:n}=de({orderData:s,onSuccess:l,onError:g,handleSetInLineAlert:k});if(u)return r("div",{children:r(ie,{})});if(!u&&!y.length)return r("div",{});const o=(p==null?void 0:p.baseMediaUrl)??"",S={products:r(ge,{itemsEligibleForReturn:_,placeholderImage:o,taxConfig:se((p==null?void 0:p.shoppingCartDisplayPrice)??0),slots:c,translations:f,loading:u,selectedProductList:e,handleSelectedProductList:i,showConfigurableOptions:d,handleSetQuantity:b,handleChangeStep:N}),attributes:r(fe,{placeholderImage:o,slots:c,formsRef:R,loading:u,fieldsConfig:y,selectedProductList:e,handleChangeStep:N,translations:f,onSubmit:n}),success:r(me,{translations:f,routeReturnSuccess:O,orderData:m}),error:null};return x("div",{className:B(["order-create-return",a]),children:[r($,{title:f.headerText}),L.heading?r(W,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...L}):null,S[t]]})},me=({routeReturnSuccess:a,translations:s,orderData:c})=>x("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(F,{href:(a==null?void 0:a(c))??"#",children:s.backStore})]}),ge=({placeholderImage:a,itemsEligibleForReturn:s,slots:c,loading:l,taxConfig:g,translations:O,selectedProductList:d,handleSelectedProductList:f,showConfigurableOptions:L,handleSetQuantity:k,handleChangeStep:p})=>x("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((m,_)=>{const{quantityReturnRequested:R,quantityShipped:y,eligibleForReturn:t}=m,u=d.some(b=>(b==null?void 0:b.productSku)===m.productSku&&m.eligibleForReturn),e=y===R&&t,i=y-R===0?R:y-R;return x("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(j,{"data-testid":`key_${_}`,name:`key_${_}`,checked:u,disabled:e,onChange:()=>{f({...m,currentReturnOrderQuantity:1})}}),r(ce,{placeholderImage:a,loading:l,product:{...m,totalQuantity:i},itemType:"",taxConfig:g,translations:O,showConfigurableOptions:L,disabledIncrementer:!u,onQuantity:i>1?b=>{k(b,m.productSku)}:void 0}),r(P,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:c==null?void 0:c.ReturnOrderItem})]},m.id)}),r("li",{className:"order-return-order-product-list__item",children:r(F,{type:"button",onClick:()=>p("attributes"),disabled:!d.length,children:O.nextStep})})]}),fe=({placeholderImage:a,slots:s,formsRef:c,selectedProductList:l,loading:g,fieldsConfig:O,translations:d,handleChangeStep:f,onSubmit:L})=>{const{formData:k,errors:p,formRef:m,handleChange:_,handleBlur:R,handleSubmit:y}=U({fieldsConfig:I(O,l==null?void 0:l.length),onSubmit:L});return x("form",{className:"order-return-reason-form",ref:m,onSubmit:y,name:"returnReasonForm",children:[l.map((t,u)=>{var h,v,M,Q,A,T;const e=t==null?void 0:t.giftCard,i=t==null?void 0:t.product,b=ee(O,u),N=`${t==null?void 0:t.id}_${u}`,n=(t==null?void 0:t.currentReturnOrderQuantity)??1,o={...t!=null&&t.currentReturnOrderQuantity?{[d.configurationsListQuantity]:n}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[d.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[d.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[d.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[d.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[d.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(h=t==null?void 0:t.downloadableLinks)==null?void 0:h.count} ${d.downloadableCount}`]:(v=t==null?void 0:t.downloadableLinks)==null?void 0:v.result}:{}},S=(Q=(M=i==null?void 0:i.thumbnail)==null?void 0:M.url)!=null&&Q.length?i.thumbnail.url:a;return x(K,{children:[r(V,{loading:g,title:r("div",{"data-testid":"product-name",children:(A=t==null?void 0:t.product)==null?void 0:A.name}),sku:r("div",{children:i==null?void 0:i.sku}),image:r(Z,{src:S,alt:((T=i==null?void 0:i.thumbnail)==null?void 0:T.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:o}),r("form",{name:N,ref:c==null?void 0:c.current[u],"data-quantity":n,children:r(z,{className:"className",loading:g,fields:b,onChange:_,onBlur:R,errors:p,values:k})})]},t.id)}),r(P,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:f},children:x("div",{className:"order-return-reason-form__actions",children:[r(F,{variant:"secondary",type:"button",onClick:()=>{f("products")},children:d.backStep}),r(F,{children:d.submit})]})})]})};export{Pe as CreateReturn,Pe as default}; +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"../chunks/RequestReturnOrderFragment.graphql.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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js index b949cc7d36..b15fa57476 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 S}from"@dropins/tools/preact-jsx-runtime.js";import{classes as H}from"@dropins/tools/lib.js";import{useState as v,useEffect as T}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as V}from"@dropins/tools/event-bus.js";import{s as C}from"../chunks/setTaxStatus.js";import{Price as d,Icon as N,Accordion as b,AccordionSection as f,Card as E,Header as D}from"@dropins/tools/components.js";import{u as k}from"../chunks/useGetStoreConfig.js";import"../chunks/ShippingStatusCard.js";import*as x from"@dropins/tools/preact-compat.js";import{O as z}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 I=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),A=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),$=a=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},x.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"})),j=({orderData:a,config:e})=>{const[t,n]=v(!0),[l,r]=v(a),[u,o]=v(null);return T(()=>{if(e){const{shoppingCartDisplayPrice:m,shoppingOrdersDisplayShipping:s,shoppingOrdersDisplaySubtotal:y,...h}=e;o(p=>({...p,...h,shoppingCartDisplayPrice:C(m),shoppingOrdersDisplayShipping:C(s),shoppingOrdersDisplaySubtotal:C(y)})),n(!1)}},[e]),T(()=>{const m=V.on("order/data",s=>{r(s)},{eager:!0});return()=>{m==null||m.off()}},[]),{loading:t,storeConfig:u,order:l}},ut=({withHeader:a,orderData:e,children:t,className:n,...l})=>{const r=k(),{loading:u,storeConfig:o,order:m}=j({orderData:e,config:r}),s=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",{...l,className:H(["order-cost-summary",n]),children:c(R,{order:m,withHeader:a,loading:u,storeConfig:o,translations:s})})},P=({translations:a,order:e,subTotalValue:t,shoppingOrdersDisplaySubtotal:n})=>{var l,r;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(l=e==null?void 0:e.subtotal)==null?void 0:l.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:a.incl}):null,n.taxExcluded&&n.taxIncluded?i(S,{children:[c(d,{currency:(r=e==null?void 0:e.subtotal)==null?void 0:r.currency,amount:t,size:"small"})," ",c("span",{children:a.excl})]}):null]})]})},W=({translations:a,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var l,r,u,o;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:a.shipping}),(l=t==null?void 0:t.totalShipping)!=null&&l.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:a.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?i(S,{children:[c(d,{weight:"normal",currency:(u=t==null?void 0:t.totalShipping)==null?void 0:u.currency,amount:(o=t==null?void 0:t.totalShipping)==null?void 0:o.value,size:"small"}),i("span",{children:[" ",a.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:a.incl}):null]})]})},q=({translations:a,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,u,o,m;const l=(r=e==null?void 0:e.discounts)==null?void 0:r.every(s=>s.amount.value===0);return!((u=e==null?void 0:e.discounts)!=null&&u.length)&&(l||!t||t<1)||(o=e==null?void 0:e.discounts)!=null&&o.length&&l?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:a.discount}),c("span",{children:(m=e==null?void 0:e.discounts)==null?void 0:m.map(({amount:s},y)=>{const p=((s==null?void 0:s.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:s==null?void 0:s.currency,amount:-p},`${s==null?void 0:s.value}${y}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(N,{source:$,size:"16"}),c("span",{children:a.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},F=({order:a})=>{var e;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(e=a==null?void 0:a.coupons)==null?void 0:e.map((t,n)=>i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},`${t==null?void 0:t.code}${n}`))})},U=({translations:a,renderTaxAccordion:e,totalAccordionTaxValue:t,order:n})=>{var u,o,m;const[l,r]=v(!1);return e?c(b,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:I,iconClose:A,children:i(f,{onStateChange:r,title:a.accordionTitle,secondaryText:c(S,{children:l?null:c(d,{weight:"normal",amount:t,currency:(o=n==null?void 0:n.totalTax)==null?void 0:o.currency})}),renderContentWhenClosed:!1,children:[(m=n==null?void 0:n.taxes)==null?void 0:m.map((s,y)=>{var h,p,_;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:s==null?void 0:s.title}),c("p",{children:c(d,{weight:"normal",amount:(h=s==null?void 0:s.amount)==null?void 0:h.value,currency:(p=s==null?void 0:s.amount)==null?void 0:p.currency})})]},`${(_=s==null?void 0:s.amount)==null?void 0:_.value}${y}`)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:a.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:a.tax}),c(d,{currency:(u=n==null?void 0:n.totalTax)==null?void 0:u.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},G=({translations:a,shoppingOrdersDisplaySubtotal:e,order:t})=>{var n,l,r,u;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:a.total}),c(d,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(l=t==null?void 0:t.grandTotal)==null?void 0:l.value,weight:"bold",size:"medium"})]}),e.taxExcluded&&e.taxIncluded?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:a.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.currency,amount:((u=t==null?void 0:t.grandTotal)==null?void 0:u.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},R=({translations:a,loading:e,storeConfig:t,order:n,withHeader:l=!0})=>{var h,p,_,O,w,L;if(e||!n)return c(z,{});const r=((h=n==null?void 0:n.totalGiftcard)==null?void 0:h.value)??0,u=((p=n.totalGiftcard)==null?void 0:p.currency)??"",o=((_=n.subtotal)==null?void 0:_.value)??0,m=((O=n.totalShipping)==null?void 0:O.value)??0,s=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),y=s?(L=n==null?void 0:n.taxes)==null?void 0:L.reduce((Z,g)=>{var M;return+((M=g==null?void 0:g.amount)==null?void 0:M.value)+Z},0):0;return i(E,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[l?c(D,{title:a.headerText}):null,i("div",{className:"order-cost-summary-content__wrapper",children:[c(P,{translations:a,order:n,subTotalValue:o,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(W,{translations:a,order:n,totalShipping:m,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(q,{translations:a,order:n,totalGiftcardValue:r,totalGiftcardCurrency:u}),c(F,{order:n}),c(U,{order:n,translations:a,renderTaxAccordion:s,totalAccordionTaxValue:y}),c(G,{translations:a,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})};export{ut as OrderCostSummary,ut as default}; +import{jsx as c,jsxs as i,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Z}from"@dropins/tools/lib.js";import{useState as g,useEffect as V}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as b}from"@dropins/tools/event-bus.js";import{s as S}from"../chunks/setTaxStatus.js";import{Price as d,Icon as E,Accordion as f,AccordionSection as D,Card as I,Header as k}from"@dropins/tools/components.js";import{u as z}from"../chunks/useGetStoreConfig.js";import"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{O as A}from"../chunks/OrderLoaders.js";import{useText as B}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const $=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),P=s=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M22 6.25H22.75C22.75 5.83579 22.4142 5.5 22 5.5V6.25ZM22 9.27L22.2514 9.97663C22.5503 9.87029 22.75 9.58731 22.75 9.27H22ZM20.26 12.92L19.5534 13.1714L19.5539 13.1728L20.26 12.92ZM22 14.66H22.75C22.75 14.3433 22.551 14.0607 22.2528 13.9539L22 14.66ZM22 17.68V18.43C22.4142 18.43 22.75 18.0942 22.75 17.68H22ZM2 17.68H1.25C1.25 18.0942 1.58579 18.43 2 18.43V17.68ZM2 14.66L1.74865 13.9534C1.44969 14.0597 1.25 14.3427 1.25 14.66H2ZM3.74 11.01L4.44663 10.7586L4.44611 10.7572L3.74 11.01ZM2 9.27H1.25C1.25 9.58675 1.44899 9.86934 1.7472 9.97611L2 9.27ZM2 6.25V5.5C1.58579 5.5 1.25 5.83579 1.25 6.25H2ZM21.25 6.25V9.27H22.75V6.25H21.25ZM21.7486 8.56337C19.8706 9.23141 18.8838 11.2889 19.5534 13.1714L20.9666 12.6686C20.5762 11.5711 21.1494 10.3686 22.2514 9.97663L21.7486 8.56337ZM19.5539 13.1728C19.9195 14.1941 20.7259 15.0005 21.7472 15.3661L22.2528 13.9539C21.6541 13.7395 21.1805 13.2659 20.9661 12.6672L19.5539 13.1728ZM21.25 14.66V17.68H22.75V14.66H21.25ZM22 16.93H2V18.43H22V16.93ZM2.75 17.68V14.66H1.25V17.68H2.75ZM2.25135 15.3666C4.12941 14.6986 5.11623 12.6411 4.44663 10.7586L3.03337 11.2614C3.42377 12.3589 2.85059 13.5614 1.74865 13.9534L2.25135 15.3666ZM4.44611 10.7572C4.08045 9.73588 3.27412 8.92955 2.2528 8.56389L1.7472 9.97611C2.34588 10.1905 2.81955 10.6641 3.03389 11.2628L4.44611 10.7572ZM2.75 9.27V6.25H1.25V9.27H2.75ZM2 7H22V5.5H2V7ZM7.31 6.74V18.17H8.81V6.74H7.31ZM17.0997 8.39967L11.0397 14.4597L12.1003 15.5203L18.1603 9.46033L17.0997 8.39967ZM12.57 9.67C12.57 9.87231 12.4159 10 12.27 10V11.5C13.2839 11.5 14.07 10.6606 14.07 9.67H12.57ZM12.27 10C12.1241 10 11.97 9.87231 11.97 9.67H10.47C10.47 10.6606 11.2561 11.5 12.27 11.5V10ZM11.97 9.67C11.97 9.46769 12.1241 9.34 12.27 9.34V7.84C11.2561 7.84 10.47 8.67938 10.47 9.67H11.97ZM12.27 9.34C12.4159 9.34 12.57 9.46769 12.57 9.67H14.07C14.07 8.67938 13.2839 7.84 12.27 7.84V9.34ZM17.22 14.32C17.22 14.5223 17.0659 14.65 16.92 14.65V16.15C17.9339 16.15 18.72 15.3106 18.72 14.32H17.22ZM16.92 14.65C16.7741 14.65 16.62 14.5223 16.62 14.32H15.12C15.12 15.3106 15.9061 16.15 16.92 16.15V14.65ZM16.62 14.32C16.62 14.1177 16.7741 13.99 16.92 13.99V12.49C15.9061 12.49 15.12 13.3294 15.12 14.32H16.62ZM16.92 13.99C17.0659 13.99 17.22 14.1177 17.22 14.32H18.72C18.72 13.3294 17.9339 12.49 16.92 12.49V13.99Z",fill:"#3D3D3D"})),W=({orderData:s,config:e})=>{const[t,n]=g(!0),[u,r]=g(s),[l,m]=g(null);return V(()=>{if(e){const{shoppingCartDisplayPrice:o,shoppingOrdersDisplayShipping:a,shoppingOrdersDisplaySubtotal:h,...y}=e;m(p=>({...p,...y,shoppingCartDisplayPrice:S(o),shoppingOrdersDisplayShipping:S(a),shoppingOrdersDisplaySubtotal:S(h)})),n(!1)}},[e]),V(()=>{const o=b.on("order/data",a=>{r(a)},{eager:!0});return()=>{o==null||o.off()}},[]),{loading:t,storeConfig:l,order:u}},mt=({withHeader:s,orderData:e,children:t,className:n,...u})=>{const r=z(),{loading:l,storeConfig:m,order:o}=W({orderData:e,config:r}),a=B({subtotal:"Order.OrderCostSummary.subtotal.title",shipping:"Order.OrderCostSummary.shipping.title",freeShipping:"Order.OrderCostSummary.shipping.freeShipping",tax:"Order.OrderCostSummary.tax.title",incl:"Order.OrderCostSummary.tax.incl",excl:"Order.OrderCostSummary.tax.excl",discount:"Order.OrderCostSummary.discount.title",discountSubtitle:"Order.OrderCostSummary.discount.subtitle",total:"Order.OrderCostSummary.total.title",accordionTitle:"Order.OrderCostSummary.tax.accordionTitle",accordionTotalTax:"Order.OrderCostSummary.tax.accordionTotalTax",totalExcludingTaxes:"Order.OrderCostSummary.tax.totalExcludingTaxes",headerText:"Order.OrderCostSummary.headerText"});return c("div",{...u,className:Z(["order-cost-summary",n]),children:c(K,{order:o,withHeader:s,loading:l,storeConfig:m,translations:a})})},q=({translations:s,order:e,subtotalInclTax:t,subtotalExclTax:n,shoppingOrdersDisplaySubtotal:u})=>{var h,y,p,x;const r=u.taxIncluded,l=u.taxExcluded,m=r&&!l?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(h=e==null?void 0:e.subtotalInclTax)==null?void 0:h.currency,amount:t})]}),c("div",{className:"order-cost-summary-content__description--subheader",children:c("span",{children:s.incl})})]}):null,o=l&&!r?i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(y=e==null?void 0:e.subtotalExclTax)==null?void 0:y.currency,amount:n})]}):null,a=l&&r?i(v,{children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.subtotal}),c(d,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(p=e==null?void 0:e.subtotalInclTax)==null?void 0:p.currency,amount:t})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[c(d,{currency:(x=e==null?void 0:e.subtotalExclTax)==null?void 0:x.currency,amount:n,size:"small",weight:"bold"})," ",c("span",{children:s.excl})]})]}):null;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[m,o,a]})},F=({translations:s,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var u,r,l,m;return t!=null&&t.isVirtual?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.shipping}),(u=t==null?void 0:t.totalShipping)!=null&&u.value?c(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:s.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?i(v,{children:[c(d,{weight:"normal",currency:(l=t==null?void 0:t.totalShipping)==null?void 0:l.currency,amount:(m=t==null?void 0:t.totalShipping)==null?void 0:m.value,size:"small"}),i("span",{children:[" ",s.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:s.incl}):null]})]})},U=({translations:s,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var r,l,m,o;const u=(r=e==null?void 0:e.discounts)==null?void 0:r.every(a=>a.amount.value===0);return!((l=e==null?void 0:e.discounts)!=null&&l.length)&&(u||!t||t<1)||(m=e==null?void 0:e.discounts)!=null&&m.length&&u?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:s.discount}),c("span",{children:(o=e==null?void 0:e.discounts)==null?void 0:o.map(({amount:a},h)=>{const p=((a==null?void 0:a.value)??0)+t;return p===0?null:c(d,{weight:"normal",sale:!0,currency:a==null?void 0:a.currency,amount:-p},`${a==null?void 0:a.value}${h}`)})})]}),t>0?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(E,{source:P,size:"16"}),c("span",{children:s.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},G=({order:s})=>{var e;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(e=s==null?void 0:s.coupons)==null?void 0:e.map((t,n)=>i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},`${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,T,w,O,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=((T=n.subtotalInclTax)==null?void 0:T.value)??0,o=((w=n.subtotalExclTax)==null?void 0:w.value)??0,a=((O=n.totalShipping)==null?void 0:O.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/OrderReturns.js b/scripts/__dropins__/storefront-order/containers/OrderReturns.js index 6a98f6c332..c4d2b9a826 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderReturns.js +++ b/scripts/__dropins__/storefront-order/containers/OrderReturns.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as d}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as l,useEffect as O}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"@dropins/tools/preact.js";import{events as g}from"@dropins/tools/event-bus.js";import{u as w}from"../chunks/useIsMobile.js";import{R as N}from"../chunks/ReturnsListContent.js";import{useText as $}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const h=({orderData:s})=>{const[i,n]=l(s),[o,u]=l([]);return O(()=>{const t=g.on("order/data",e=>{n(e),u(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:o}},A=({slots:s,className:i,orderData:n,withHeader:o,withThumbnails:u,routeReturnDetails:t,routeProductDetails:e,routeTracking:p})=>{const m=b(),{orderReturns:a}=h({orderData:n}),f=w(),r="fullSizeView",c=(m==null?void 0:m.baseMediaUrl)??"",R=$({minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return d("div",{className:L(["order-order-returns",i]),children:a.length?d(N,{placeholderImage:c,pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:f,withOrderNumber:!1,withReturnNumber:!0,orderReturns:a,translations:R,withHeader:o,withThumbnails:u,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:p,loading:!1}):null})};export{A as OrderReturns,A as default}; +import{jsx as d}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as p,useEffect as O}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"@dropins/tools/preact.js";import{events as g}from"@dropins/tools/event-bus.js";import{u as w}from"../chunks/useIsMobile.js";import{R as N}from"../chunks/ReturnsListContent.js";import{useText as $}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const h=({orderData:s})=>{const[i,n]=p(s),[o,u]=p([]);return O(()=>{const t=g.on("order/data",e=>{n(e),u(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:o}},B=({slots:s,className:i,orderData:n,withHeader:o,withThumbnails:u,routeReturnDetails:t,routeProductDetails:e,routeTracking:l})=>{const m=b(),{orderReturns:a}=h({orderData:n}),f=w(),r="fullSizeView",c=(m==null?void 0:m.baseMediaUrl)??"",R=$({minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return d("div",{className:L(["order-order-returns",i]),children:a.length?d(N,{placeholderImage:c,pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:f,withOrderNumber:!1,withReturnNumber:!0,orderReturns:a,translations:R,withHeader:o,withThumbnails:u,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:l,loading:!1}):null})};export{B as OrderReturns,B as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index e3900654b3..848af49fd4 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 s,jsxs as V}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{useState as v,useCallback as w,useEffect as F,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as U}from"../chunks/ShippingStatusCard.js";import*as _ 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,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"../chunks/GurestOrderFragment.graphql.js";import"../chunks/initialize.js";const P=r=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},_.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"})),x=r=>{try{return new URL(window.location.href).searchParams.get(r)}catch{return null}},X=({onError:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[y,u]=v({text:"",type:"success"}),[b,p]=v(!1),m=z({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=w(async e=>{const l=x("orderRef"),n=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(t){const d=await E();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):n||f(c,{orderRef:e.token})}else n||f(c,{orderRef:e==null?void 0:e.token})},[t,i,c]);F(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),F(()=>{const e=x("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):t?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[t,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:w(async(e,l)=>{if(!l)return null;p(!0);const n=H(e.target);await B(n).then(o=>{o||u({text:m.invalidSearch,type:"warning"}),N.emit("order/data",o)}).catch(async o=>{var S;let d=!0;r==null||r({error:o.message});const h=t?await E():{email:""};(h==null?void 0:h.email)===(n==null?void 0:n.email)?f(i,{orderRef:n.number}):d=a==null?void 0:a({render:h===null||((S=o==null?void 0:o.message)==null?void 0:S.includes("Please login to view the order.")),formValues:n}),d&&u({text:o.message,type:"warning"})}).finally(()=>{p(!1)})},[t,r,a,i,m.invalidSearch]),inLineAlert:y,loading:b,normalizeFieldsConfig:O}},oe=({className:r,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:y})=>{const{onSubmit:u,loading:b,inLineAlert:p,normalizeFieldsConfig:m}=X({onError:y,isAuth:t,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return s("div",{className:L(["order-order-search",r]),children:s(Z,{onSubmit:u,loading:b,inLineAlert:p,fieldsConfig:m})})},Z=({onSubmit:r,loading:t,inLineAlert:a,fieldsConfig:i})=>V(M,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(T,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(T,{id:"Order.OrderSearchForm.description"})}),a.text?s(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:s(C,{source:P})}):null,s(U,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:i,onSubmit:r,children:s("div",{className:"order-order-search-form__button-container",children:s(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{oe as OrderSearch,oe as default}; +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"../chunks/GurestOrderFragment.graphql.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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index 677e078def..3e50d674bb 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderStatus.js +++ b/scripts/__dropins__/storefront-order/containers/OrderStatus.js @@ -1,21 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as i,Fragment as _,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as j,classes as A}from"@dropins/tools/lib.js";import{Button as E,InLineAlert as z,Modal as K,Card as q,Header as H}from"@dropins/tools/components.js";import{useState as S,useEffect as U,useCallback as B}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as Q,useState as J}from"@dropins/tools/preact-compat.js";import{u as $}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as P}from"@dropins/tools/event-bus.js";import{G as X}from"../chunks/GurestOrderFragment.graphql.js";import{f as Y,h as Z}from"../chunks/fetch-graphql.js";import{c as D}from"../chunks/initialize.js";import{useText as O,Text as x}from"@dropins/tools/i18n.js";import{C as ee}from"../chunks/OrderLoaders.js";import{f as re}from"../chunks/returnOrdersHelper.js";import{f as v}from"../chunks/formatDateToLocale.js";import{r as k}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import{r as ne}from"../chunks/reorderItems.js";import"../chunks/getStoreConfig.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(y||{});const se=({className:r,orderData:t,slots:n,routeCreateReturn:e,routeOnSuccess:a,onError:s})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=Q(()=>{const o=t==null?void 0:t.availableActions,c=!!(o!=null&&o.length),u=!!(t!=null&&t.returnNumber),R=()=>{k(e,{},t)};return i(_,{children:n!=null&&n.OrderActions?i(j,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:t}):i("div",{"data-testid":"availableActionsList",className:A(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!c]]),children:o==null?void 0:o.map(f=>{switch(f){case y.CANCEL:return i(_,{children:u?null:i(ae,{orderRef:(t==null?void 0:t.token)??(t==null?void 0:t.id)})});case y.RETURN:return i(E,{variant:"secondary",onClick:R,children:u?d.createAnotherReturn:d.createReturn});case y.REORDER:return i(_,{children:u?null:i(ue,{orderData:t,onError:s,routeOnSuccess:a,children:d.reorder})})}})})})},[s,t,a,e,n,d]);return i("div",{className:A(["order-order-actions",r]),children:l})},oe=({orderData:r})=>{const[t,n]=S(r),[e,a]=S(r==null?void 0:r.status);return U(()=>{const s=P.on("order/data",d=>{n(d),a(d.status)},{eager:!0});return()=>{s==null||s.off()}},[]),{orderStatus:e,order:t}},ce=` - mutation CONFIRM_CANCEL_ORDER_MUTATION( - $orderId: ID! - $confirmationKey: String! - ) { - confirmCancelOrder( - input: { order_id: $orderId, confirmation_key: $confirmationKey } - ) { - order { - ...guestOrderData - } - errorV2 { - message - code - } - } - } - ${X} -`,ie=async(r,t)=>Y(ce,{variables:{orderId:r,confirmationKey:t}}).then(async({errors:n,data:e})=>{var d,l,o,c;const a=[...(d=e==null?void 0:e.confirmCancelOrder)!=null&&d.errorV2?[(l=e==null?void 0:e.confirmCancelOrder)==null?void 0:l.errorV2]:[],...n??[]];let s=null;return(o=e==null?void 0:e.confirmCancelOrder)!=null&&o.order&&(s=D((c=e==null?void 0:e.confirmCancelOrder)==null?void 0:c.order),P.emit("order/data",s)),a.length>0?Z(a):s}),de=({enableOrderCancellation:r})=>{const t=O({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[n,e]=S({text:"",status:void 0});return U(()=>{if(!r)return;const a=new URLSearchParams(window.location.search),s=a.get("order_id"),d=a.get("confirmation_key");s&&d&&ie(s,d).then(()=>{e({text:t.orderCancelled,status:"success"})}).catch(l=>{e({text:l.message,status:"warning"})})},[r,t.orderCancelled]),{confirmOrderCancellation:n}},$e=({slots:r,orderData:t,className:n,statusTitle:e,status:a,routeCreateReturn:s,onError:d,routeOnSuccess:l})=>{const{orderStatus:o,order:c}=oe({orderData:t}),[u,R]=J(!1),f=()=>{R(!0);const p=new URL(window.location.href),T=p.searchParams.get("order_id"),g=p.searchParams.get("confirmation_key");T&&g&&(p.searchParams.delete("order_id"),p.searchParams.delete("confirmation_key"),window.history.replaceState({},document.title,p.toString()))},h=O({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),C=$(),{confirmOrderCancellation:m}=de({enableOrderCancellation:C==null?void 0:C.orderCancellationEnabled});return N("div",{className:A(["order-order-status",n]),children:[!u&&(m==null?void 0:m.status)!==void 0&&i(z,{heading:h.cancelOrder,onDismiss:f,description:m.text,type:m.status}),c?i(le,{title:e,status:a||o,slots:r,orderData:c,routeCreateReturn:s,onError:d,routeOnSuccess:l}):i(ee,{withCard:!1})]})},ae=({orderRef:r})=>{const[t,n]=S(!1),e=()=>{n(!0)},a=()=>{n(!1)},s=$(),d=(s==null?void 0:s.orderCancellationReasons)??[],l=o=>o.map((c,u)=>({text:c==null?void 0:c.description,value:u.toString()}));return P.on("order/data",o=>{const c=String(o.status).toLocaleLowerCase();(c==="guest order cancellation requested"||c==="canceled")&&a()}),N(_,{children:[i(E,{variant:"secondary",onClick:e,"data-testid":"cancel-button",children:i(x,{id:"Order.OrderStatusContent.actions.cancel"})}),t&&i(K,{centered:!0,size:"medium",onClose:a,className:"order-order-cancel__modal",title:i("h2",{className:"order-order-cancel__title",children:i(x,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:i(te,{orderRef:r,cancelReasons:l(d)})})]})},b=r=>r&&r.charAt(0).toLocaleUpperCase()+r.slice(1).toLocaleLowerCase(),w={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"},le=({slots:r,title:t,status:n,orderData:e,routeCreateReturn:a,onError:s,routeOnSuccess:d})=>{var L,I,M;const l=!!(e!=null&&e.returnNumber),o=String(n).toLocaleLowerCase(),c=(L=e==null?void 0:e.returns)==null?void 0:L[0],u=(c==null?void 0:c.returnStatus)??"",R=(c==null?void 0:c.createdReturnAt)??"",f=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),h=O(`Order.OrderStatusContent.${w[o]}.title`),C=O(`Order.OrderStatusContent.${w[o]}.message`),m=O(`Order.OrderStatusContent.${w[o]}.messageWithoutDate`),p=O({title:`Order.OrderStatusContent.returnStatus.${re(u)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return i("div",{});const T=h!=null&&h.title?h:{title:b(o)},g=C!=null&&C.message?C:f,F=m!=null&&m.messageWithoutDate?m:f,G=e!=null&&e.orderStatusChangeDate?g==null?void 0:g.message.replace("{DATE}",v(e==null?void 0:e.orderStatusChangeDate)):F.messageWithoutDate,V=((M=(I=p==null?void 0:p.returnMessage)==null?void 0:I.replace("{ORDER_CREATE_DATE}",v(e==null?void 0:e.orderDate)))==null?void 0:M.replace("{RETURN_CREATE_DATE}",v(R)))??"",W=l?t??(p.title||b(u)):t??T.title;return N(q,{className:"order-order-status-content",variant:"secondary",children:[i(H,{title:W}),N("div",{className:"order-order-status-content__wrapper",children:[i("div",{className:A(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(r!=null&&r.OrderActions)]]),children:i("p",{children:l?V:G})}),i(se,{orderData:e,slots:r,routeCreateReturn:a,routeOnSuccess:d,onError:s})]})]})},ue=({onError:r,routeOnSuccess:t,orderData:n,children:e})=>{const[a,s]=S(!1),d=B(()=>{s(!0);const l=n==null?void 0:n.number;ne(l).then(({success:o,userInputErrors:c})=>{o&&k(t,{}),c.length&&(r==null||r(c))}).catch(o=>{r==null||r(o.message)}).finally(()=>{s(!1)})},[n,t,r]);return i(E,{type:"button",disabled:a,variant:"secondary",className:"order-reorder",onClick:d,children:e})};export{$e as OrderStatus,$e 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"../chunks/RequestReturnOrderFragment.graphql.js";import"../chunks/GurestOrderFragment.graphql.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}},He=({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{He as OrderStatus,He as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index 74da1dcd46..0f701a7577 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as p}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},er=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const f=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return p("div",{className:$(["order-returns-list",u]),children:p(A,{placeholderImage:(f==null?void 0:f.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{er as default}; +import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},tr=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const p=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",u]),children:f(A,{placeholderImage:(p==null?void 0:p.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{tr as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js index 6649338f09..e1daad6036 100644 --- a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js +++ b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as i,jsxs as S,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $,VComponent as E,Slot as q}from"@dropins/tools/lib.js";import{Card as A,Header as x,Accordion as G,AccordionSection as V,ContentGrid as B,Image as M}from"@dropins/tools/components.js";import{useState as R,useEffect as tn}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as sn}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as ln}from"@dropins/tools/event-bus.js";import{C as rn}from"../chunks/OrderLoaders.js";import{u as hn}from"../chunks/useIsMobile.js";import{Text as U,useText as un}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";var H=(s=>(s.PENDING="pending",s.SHIPPING="shipping",s.COMPLETE="complete",s.PROCESSING="processing",s.HOLD="on hold",s.CANCELED="Canceled",s.SUSPECTED_FRAUD="suspected fraud",s.PAYMENT_REVIEW="payment review",s))(H||{});const dn=({orderData:s})=>{const[r,h]=R(!0),[n,c]=R(s),[l,m]=R(!1);return tn(()=>{const u=ln.on("order/data",o=>{c(o),m(o==null?void 0:o.isVirtual),h(!1)},{eager:!0});return s!=null&&s.id&&h(!1),()=>{u==null||u.off()}},[s]),{loading:r,order:n,isVirtualProduct:l}},en=({value:s,variant:r="primary",size:h="medium",icon:n,className:c,children:l,disabled:m=!1,active:u=!1,activeChildren:o,activeIcon:b,href:e,...C})=>{let d="dropin-button";(n&&!l||n&&u&&!o||!n&&u&&b)&&(d="dropin-iconButton"),u&&o&&(d="dropin-button"),c=$([d,`${d}--${h}`,`${d}--${r}`,[`${d}--${r}--disabled`,m],l&&n&&`${d}--with-icon`,!l&&o&&n&&`${d}--with-icon`,u&&b&&`${d}--with-icon`,c]);const I=$(["dropin-button-icon",`dropin-button-icon--${r}`,[`dropin-button-icon--${r}--disabled`,m],n==null?void 0:n.props.className]),g=e?{node:i("a",{}),role:"link",href:e,...C,disabled:m,active:u,onKeyDown:y=>{m&&y.preventDefault()},tabIndex:m?-1:0}:{node:i("button",{}),role:"button",...C,value:s,disabled:m,active:u};return S(E,{...g,className:c,children:[n&&!u&&i(E,{node:n,className:I}),b&&u&&i(E,{node:b,className:I}),l&&!u&&(typeof l=="string"?i("span",{children:l}):l),u&&o&&(typeof o=="string"?i("span",{children:o}):o)]})},cn=({placeholderImage:s,slots:r,collapseThreshold:h,translations:n,returnData:c,routeTracking:l,routeProductDetails:m})=>{var b;const u=hn(),o=m?"a":"span";return S(A,{variant:"secondary",className:$(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(x,{title:n.returnOrderCardTitle}),S("div",{children:[(b=c==null?void 0:c.tracking)==null?void 0:b.map((e,C)=>{var y,O;const d={title:"",number:(e==null?void 0:e.trackingNumber)??"",carrier:((y=e==null?void 0:e.carrier)==null?void 0:y.label)??""},I=l==null?void 0:l(d),g=I?()=>{window.open(I,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(O=d.carrier)==null?void 0:O.toLocaleUpperCase()} | `,d.number]}),g?i(en,{onClick:g,children:n.trackButton}):null]},`${d.number}_${C}`)}),r!=null&&r.ReturnItemsDetails?i(q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:r==null?void 0:r.ReturnItemsDetails,context:{items:c.items}}):null,i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{defaultOpen:h>=c.items.length,title:i(U,{id:"Order.ShippingStatusCard.itemText",plural:c.items.reduce((e,C)=>e+C.requestQuantity,0),fields:{count:c.items.reduce((e,C)=>e+C.requestQuantity,0)}}),children:i(B,{maxColumns:u?3:9,emptyGridContent:i(w,{}),className:$(["order-shipping-status-card__images",["order-shipping-status-card__images-3",u]]),children:c.items.map((e,C)=>{var g,y,O,_;const d=(g=e.thumbnail)==null?void 0:g.label,I=(O=(y=e.thumbnail)==null?void 0:y.url)!=null&&O.length?(_=e.thumbnail)==null?void 0:_.url:s;return i(o,{href:(m==null?void 0:m(e))??"#","data-testid":`${C}${e.uid}`,children:i(M,{alt:d,src:I,width:85,height:114})},`${C}${e.uid}`)})})})})]})]})},mn=({placeholderImage:s,translations:r,slots:h,orderData:n,collapseThreshold:c=10,routeProductDetails:l,routeTracking:m})=>{var O,_,j,F,Q,K,W;const u=!!(n!=null&&n.returnNumber),o=n==null?void 0:n.returnNumber,b=l?"a":"span",e=(O=n==null?void 0:n.status)==null?void 0:O.toLocaleLowerCase(),d=((_=n==null?void 0:n.shipments)==null?void 0:_.length)===1&&(e==null?void 0:e.includes(H.COMPLETE)),I=(j=n==null?void 0:n.shipments)==null?void 0:j.every(p=>p.tracking.length===0),g=(F=n==null?void 0:n.items)==null?void 0:F.filter(p=>(p==null?void 0:p.quantityShipped)===0||(p==null?void 0:p.quantityShipped)<(p==null?void 0:p.quantityOrdered)),y=(Q=n==null?void 0:n.items)==null?void 0:Q.reduce((p,f)=>{const T=f.quantityOrdered-f.quantityShipped;return p+(T>0?T:0)},0);if(u&&(n!=null&&n.returns.length)){const p=n.returns.find(f=>f.returnNumber===o);return!p||p.tracking.length===0?null:i(cn,{placeholderImage:s,slots:h,collapseThreshold:c,translations:r,returnData:p,routeTracking:m,routeProductDetails:l})}return!n||e!=null&&e.includes(H.CANCELED)?null:(K=n==null?void 0:n.shipments)!=null&&K.length?I&&!(g!=null&&g.length)&&d?null:S(w,{children:[(W=n==null?void 0:n.shipments)==null?void 0:W.map(({tracking:p,items:f,id:T},pn)=>{const Y=f.reduce((t,N)=>t+((N==null?void 0:N.quantityShipped)??0),0);return S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingCardTitle}),p==null?void 0:p.map(t=>{var a;const N=m==null?void 0:m(t),L=N?()=>{window.open(N,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[r.carrier," ",(a=t==null?void 0:t.carrier)==null?void 0:a.toLocaleUpperCase()," | ",t==null?void 0:t.number]}),i("p",{children:t==null?void 0:t.title})]}),h!=null&&h.DeliveryTrackActions?i(q,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:h==null?void 0:h.DeliveryTrackActions,context:{trackInformation:t}}):L?i(en,{onClick:L,children:r.trackButton}):null]},t.number)}),d?null:i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{"data-position":pn+1,defaultOpen:c>=(f==null?void 0:f.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:Y,fields:{count:Y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:f==null?void 0:f.map(t=>{var a,z,J,X,Z,v,P,k,D,nn;const N=(J=(z=(a=t==null?void 0:t.orderItem)==null?void 0:a.product)==null?void 0:z.thumbnail)==null?void 0:J.label,L=(P=(v=(Z=(X=t==null?void 0:t.orderItem)==null?void 0:X.product)==null?void 0:Z.thumbnail)==null?void 0:v.url)!=null&&P.length?(nn=(D=(k=t==null?void 0:t.orderItem)==null?void 0:k.product)==null?void 0:D.thumbnail)==null?void 0:nn.url:s;return i(b,{href:(l==null?void 0:l(t))??"#",children:i(M,{alt:N,src:L,width:85,height:114})},t.id)})})})}),h!=null&&h.DeliveryTimeLine?i(q,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:h==null?void 0:h.DeliveryTimeLine,context:{}}):null]},T)}),g!=null&&g.length?S(A,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(x,{title:r.notYetShippedTitle}),i(G,{actionIconPosition:"right",children:i(V,{defaultOpen:c>=(g==null?void 0:g.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:g==null?void 0:g.map(p=>{var f,T;return i(b,{href:(l==null?void 0:l(p))??"#",children:i(M,{alt:(f=p.thumbnail)==null?void 0:f.label,src:((T=p.thumbnail)==null?void 0:T.url)||"",width:85,height:114})},p.id)})})})})]}):null]}):S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:r.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:r.noInfoTitle})]})})]})},wn=({slots:s,className:r,collapseThreshold:h,orderData:n,routeOrderDetails:c,routeTracking:l,routeProductDetails:m})=>{const{loading:u,order:o,isVirtualProduct:b}=dn({orderData:n}),e=sn(),C=un({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});if(!u&&b)return null;const d=(e==null?void 0:e.baseMediaUrl)??"";return i("div",{className:$(["order-shipping-status",r]),children:!u&&o?i(mn,{placeholderImage:d,translations:C,routeOrderDetails:c,routeTracking:l,slots:s,orderData:o,collapseThreshold:h,routeProductDetails:m}):i(rn,{withCard:!1})})};export{wn as ShippingStatus,wn as default}; +import{jsx as i,jsxs as S,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $,VComponent as E,Slot as q}from"@dropins/tools/lib.js";import{Card as A,Header as x,Accordion as G,AccordionSection as V,ContentGrid as B,Image as M}from"@dropins/tools/components.js";import{useState as R,useEffect as tn}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as sn}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as rn}from"@dropins/tools/event-bus.js";import{C as ln}from"../chunks/OrderLoaders.js";import{u as hn}from"../chunks/useIsMobile.js";import{Text as U,useText as un}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";var H=(s=>(s.PENDING="pending",s.SHIPPING="shipping",s.COMPLETE="complete",s.PROCESSING="processing",s.HOLD="on hold",s.CANCELED="Canceled",s.SUSPECTED_FRAUD="suspected fraud",s.PAYMENT_REVIEW="payment review",s))(H||{});const dn=({orderData:s})=>{const[l,h]=R(!0),[n,c]=R(s),[r,m]=R(!1);return tn(()=>{const u=rn.on("order/data",o=>{c(o),m(o==null?void 0:o.isVirtual),h(!1)},{eager:!0});return s!=null&&s.id&&h(!1),()=>{u==null||u.off()}},[s]),{loading:l,order:n,isVirtualProduct:r}},en=({value:s,variant:l="primary",size:h="medium",icon:n,className:c,children:r,disabled:m=!1,active:u=!1,activeChildren:o,activeIcon:b,href:e,...C})=>{let d="dropin-button";(n&&!r||n&&u&&!o||!n&&u&&b)&&(d="dropin-iconButton"),u&&o&&(d="dropin-button"),c=$([d,`${d}--${h}`,`${d}--${l}`,[`${d}--${l}--disabled`,m],r&&n&&`${d}--with-icon`,!r&&o&&n&&`${d}--with-icon`,u&&b&&`${d}--with-icon`,c]);const I=$(["dropin-button-icon",`dropin-button-icon--${l}`,[`dropin-button-icon--${l}--disabled`,m],n==null?void 0:n.props.className]),g=e?{node:i("a",{}),role:"link",href:e,...C,disabled:m,active:u,onKeyDown:y=>{m&&y.preventDefault()},tabIndex:m?-1:0}:{node:i("button",{}),role:"button",...C,value:s,disabled:m,active:u};return S(E,{...g,className:c,children:[n&&!u&&i(E,{node:n,className:I}),b&&u&&i(E,{node:b,className:I}),r&&!u&&(typeof r=="string"?i("span",{children:r}):r),u&&o&&(typeof o=="string"?i("span",{children:o}):o)]})},cn=({placeholderImage:s,slots:l,collapseThreshold:h,translations:n,returnData:c,routeTracking:r,routeProductDetails:m})=>{var b;const u=hn(),o=m?"a":"span";return S(A,{variant:"secondary",className:$(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[i(x,{title:n.returnOrderCardTitle}),S("div",{children:[(b=c==null?void 0:c.tracking)==null?void 0:b.map((e,C)=>{var y,N;const d={title:"",number:(e==null?void 0:e.trackingNumber)??"",carrier:((y=e==null?void 0:e.carrier)==null?void 0:y.label)??""},I=r==null?void 0:r(d),g=I?()=>{window.open(I,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",children:[S("div",{children:[`${n.carrier} `,`${(N=d.carrier)==null?void 0:N.toLocaleUpperCase()} | `,d.number]}),g?i(en,{onClick:g,children:n.trackButton}):null]},`${d.number}_${C}`)}),l!=null&&l.ReturnItemsDetails?i(q,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:l==null?void 0:l.ReturnItemsDetails,context:{items:c.items}}):null,i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{defaultOpen:h>=c.items.length,title:i(U,{id:"Order.ShippingStatusCard.itemText",plural:c.items.reduce((e,C)=>e+C.requestQuantity,0),fields:{count:c.items.reduce((e,C)=>e+C.requestQuantity,0)}}),children:i(B,{maxColumns:u?3:9,emptyGridContent:i(w,{}),className:$(["order-shipping-status-card__images",["order-shipping-status-card__images-3",u]]),children:c.items.map((e,C)=>{var g,y,N,_;const d=(g=e.thumbnail)==null?void 0:g.label,I=(N=(y=e.thumbnail)==null?void 0:y.url)!=null&&N.length?(_=e.thumbnail)==null?void 0:_.url:s;return i(o,{href:(m==null?void 0:m(e))??"#","data-testid":`${C}${e.uid}`,children:i(M,{alt:d,src:I,width:85,height:114})},`${C}${e.uid}`)})})})})]})]})},mn=({placeholderImage:s,translations:l,slots:h,orderData:n,collapseThreshold:c=10,routeProductDetails:r,routeTracking:m})=>{var N,_,j,F,Q,K,W;const u=!!(n!=null&&n.returnNumber),o=n==null?void 0:n.returnNumber,b=r?"a":"span",e=(N=n==null?void 0:n.status)==null?void 0:N.toLocaleLowerCase(),d=((_=n==null?void 0:n.shipments)==null?void 0:_.length)===1&&(e==null?void 0:e.includes(H.COMPLETE)),I=(j=n==null?void 0:n.shipments)==null?void 0:j.every(p=>p.tracking.length===0),g=(F=n==null?void 0:n.items)==null?void 0:F.filter(p=>(p==null?void 0:p.quantityShipped)===0||(p==null?void 0:p.quantityShipped)<(p==null?void 0:p.quantityOrdered)),y=(Q=n==null?void 0:n.items)==null?void 0:Q.reduce((p,f)=>{const T=f.quantityOrdered-f.quantityShipped;return p+(T>0?T:0)},0);if(u&&(n!=null&&n.returns.length)){const p=n.returns.find(f=>f.returnNumber===o);return!p||p.tracking.length===0?null:i(cn,{placeholderImage:s,slots:h,collapseThreshold:c,translations:l,returnData:p,routeTracking:m,routeProductDetails:r})}return!n||e!=null&&e.includes(H.CANCELED)?null:(K=n==null?void 0:n.shipments)!=null&&K.length?I&&!(g!=null&&g.length)&&d?null:S(w,{children:[(W=n==null?void 0:n.shipments)==null?void 0:W.map(({tracking:p,items:f,id:T},pn)=>{const Y=f.reduce((t,O)=>t+((O==null?void 0:O.quantityShipped)??O.orderItem.quantityShipped??0),0);return S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:l.shippingCardTitle}),p==null?void 0:p.map(t=>{var a;const O=m==null?void 0:m(t),L=O?()=>{window.open(O,"_blank","noreferrer")}:null;return S("div",{className:"order-shipping-status-card__header",role:"status",children:[S("div",{className:"order-shipping-status-card__header--content",children:[S("p",{children:[l.carrier," ",(a=t==null?void 0:t.carrier)==null?void 0:a.toLocaleUpperCase()," | ",t==null?void 0:t.number]}),i("p",{children:t==null?void 0:t.title})]}),h!=null&&h.DeliveryTrackActions?i(q,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:h==null?void 0:h.DeliveryTrackActions,context:{trackInformation:t}}):L?i(en,{onClick:L,children:l.trackButton}):null]},t.number)}),d?null:i(G,{actionIconPosition:"right","data-testid":"dropinAccordion",children:i(V,{"data-position":pn+1,defaultOpen:c>=(f==null?void 0:f.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:Y,fields:{count:Y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:f==null?void 0:f.map(t=>{var a,z,J,X,Z,v,P,k,D,nn;const O=(J=(z=(a=t==null?void 0:t.orderItem)==null?void 0:a.product)==null?void 0:z.thumbnail)==null?void 0:J.label,L=(P=(v=(Z=(X=t==null?void 0:t.orderItem)==null?void 0:X.product)==null?void 0:Z.thumbnail)==null?void 0:v.url)!=null&&P.length?(nn=(D=(k=t==null?void 0:t.orderItem)==null?void 0:k.product)==null?void 0:D.thumbnail)==null?void 0:nn.url:s;return i(b,{href:(r==null?void 0:r(t))??"#",children:i(M,{alt:O,src:L,width:85,height:114})},t.id)})})})}),h!=null&&h.DeliveryTimeLine?i(q,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:h==null?void 0:h.DeliveryTimeLine,context:{}}):null]},T)}),g!=null&&g.length?S(A,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[i(x,{title:l.notYetShippedTitle}),i(G,{actionIconPosition:"right",children:i(V,{defaultOpen:c>=(g==null?void 0:g.length),title:i(U,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:y,fields:{count:y}}),children:i(B,{maxColumns:6,emptyGridContent:i(w,{}),className:"order-shipping-status-card__images",children:g==null?void 0:g.map(p=>{var f,T;return i(b,{href:(r==null?void 0:r(p))??"#",children:i(M,{alt:(f=p.thumbnail)==null?void 0:f.label,src:((T=p.thumbnail)==null?void 0:T.url)||"",width:85,height:114})},p.id)})})})})]}):null]}):S(A,{variant:"secondary",className:"order-shipping-status-card",children:[i(x,{title:l.shippingInfoTitle}),i("div",{className:"order-shipping-status-card__header",children:S("div",{className:"order-shipping-status-card__header--content",children:[n!=null&&n.carrier?i("p",{children:n==null?void 0:n.carrier}):null,i("p",{children:l.noInfoTitle})]})})]})},wn=({slots:s,className:l,collapseThreshold:h,orderData:n,routeOrderDetails:c,routeTracking:r,routeProductDetails:m})=>{const{loading:u,order:o,isVirtualProduct:b}=dn({orderData:n}),e=sn(),C=un({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",returnOrderCardTitle:"Order.ShippingStatusCard.returnOrderCardTitle",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",noInfoTitle:"Order.ShippingStatusCard.noInfoTitle",returnNumber:"Order.ShippingStatusCard.returnNumber",orderNumber:"Order.ShippingStatusCard.orderNumber",trackButton:"Order.ShippingStatusCard.trackButton"});if(!u&&b)return null;const d=(e==null?void 0:e.baseMediaUrl)??"";return i("div",{className:$(["order-shipping-status",l]),children:!u&&o?i(mn,{placeholderImage:d,translations:C,routeOrderDetails:c,routeTracking:r,slots:s,orderData:o,collapseThreshold:h,routeProductDetails:m}):i(ln,{withCard:!1})})};export{wn as ShippingStatus,wn 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 a27ac60a28..d3805af02c 100644 --- a/scripts/__dropins__/storefront-order/data/models/order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/order-details.d.ts @@ -154,7 +154,8 @@ export type OrderDataModel = { totalGiftcard: MoneyProps; grandTotal: MoneyProps; totalShipping?: MoneyProps; - subtotal: MoneyProps; + subtotalExclTax: MoneyProps; + subtotalInclTax: MoneyProps; totalTax: MoneyProps; shippingAddress: OrderAddressModel; billingAddress: OrderAddressModel; diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useConfirmCancelOrder.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useConfirmCancelOrder.d.ts deleted file mode 100644 index 19c36d2d36..0000000000 --- a/scripts/__dropins__/storefront-order/hooks/containers/useConfirmCancelOrder.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ConfirmCancelOrderProps } from '../../types'; - -export declare const useConfirmCancelOrder: ({ enableOrderCancellation, }: ConfirmCancelOrderProps) => { - confirmOrderCancellation: { - text: string; - status: 'success' | 'error' | 'warning' | undefined; - }; -}; -//# sourceMappingURL=useConfirmCancelOrder.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts index dedc3def4d..2c174c4258 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useCreateReturn.d.ts @@ -39,7 +39,8 @@ export declare const useCreateReturn: ({ onSuccess, onError, handleSetInLineAler totalGiftcard?: import('../../types').MoneyProps | undefined; grandTotal?: import('../../types').MoneyProps | undefined; totalShipping?: import('../../types').MoneyProps | undefined; - subtotal?: import('../../types').MoneyProps | undefined; + subtotalExclTax?: import('../../types').MoneyProps | undefined; + subtotalInclTax?: import('../../types').MoneyProps | undefined; totalTax?: import('../../types').MoneyProps | undefined; shippingAddress?: import('../../data/models').OrderAddressModel | undefined; billingAddress?: import('../../data/models').OrderAddressModel | undefined; diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useOrderActions.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useOrderActions.d.ts new file mode 100644 index 0000000000..ac7b11d630 --- /dev/null +++ b/scripts/__dropins__/storefront-order/hooks/containers/useOrderActions.d.ts @@ -0,0 +1,12 @@ +import { UseOrderActionsProps } from '../../types'; + +export declare const useOrderActions: ({ enableOrderCancellation, }: UseOrderActionsProps) => { + orderActionStatus: { + heading: string; + text: string; + status: 'success' | 'error' | 'warning' | undefined; + }; + isDismissed: boolean; + onDismiss: () => void; +}; +//# sourceMappingURL=useOrderActions.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/index.d.ts b/scripts/__dropins__/storefront-order/hooks/index.d.ts index eeec23d318..a67ffe6df1 100644 --- a/scripts/__dropins__/storefront-order/hooks/index.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/index.d.ts @@ -7,6 +7,7 @@ export * from './containers/useOrderSearch'; export * from './containers/useOrderStatus'; export * from './containers/useReturnsList'; export * from './containers/useShippingStatus'; +export * from './containers/useOrderActions'; export * from './useInLineAlert'; export * from './useIsMobile'; export * from './api/useGetStoreConfig'; diff --git a/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts index 6a4befce7d..130bf4e825 100644 --- a/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts @@ -183,6 +183,8 @@ declare const _default: { }, "actions": { "cancel": "Cancel order", + "confirmGuestReturn": "Return request confirmed", + "confirmGuestReturnMessage": "Your return request has been successfully confirmed.", "createReturn": "Return or replace", "createAnotherReturn": "Start another return", "reorder": "Reorder" @@ -232,7 +234,7 @@ declare const _default: { "messageWithoutDate": "Your order is processing. Check back for more details when your order ships." }, "guestOrderCancellationRequested": { - "title": "cancellation requested", + "title": "Cancellation requested", "message": "The cancellation has been requested on {DATE}. Check your email for further instructions.", "messageWithoutDate": "The cancellation has been requested. Check your email for further instructions." }, diff --git a/scripts/__dropins__/storefront-order/lib/getQueryParam.d.ts b/scripts/__dropins__/storefront-order/lib/getQueryParam.d.ts index cb9f254ed4..8089cdd4f0 100644 --- a/scripts/__dropins__/storefront-order/lib/getQueryParam.d.ts +++ b/scripts/__dropins__/storefront-order/lib/getQueryParam.d.ts @@ -1,2 +1,2 @@ -export declare const getQueryParam: (param: string) => string | null; +export declare const getQueryParam: (param: string) => string; //# sourceMappingURL=getQueryParam.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/lib/removeQueryParams.d.ts b/scripts/__dropins__/storefront-order/lib/removeQueryParams.d.ts new file mode 100644 index 0000000000..5f56141e93 --- /dev/null +++ b/scripts/__dropins__/storefront-order/lib/removeQueryParams.d.ts @@ -0,0 +1,2 @@ +export declare const removeQueryParams: (params: string[]) => void; +//# sourceMappingURL=removeQueryParams.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/render.js b/scripts/__dropins__/storefront-order/render.js index 94a3765951..1365495e93 100644 --- a/scripts/__dropins__/storefront-order/render.js +++ b/scripts/__dropins__/storefront-order/render.js @@ -1,5 +1,5 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ (function(n,e){try{if(typeof document<"u"){const r=document.createElement("style"),a=e.styleId;for(const t in e.attributes)r.setAttribute(t,e.attributes[t]);r.setAttribute("data-dropin",a),r.appendChild(document.createTextNode(n));const o=document.querySelector('style[data-dropin="sdk"]');if(o)o.after(r);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(r):document.head.append(r)}}}catch(r){console.error("dropin-styles (injectCodeFunction)",r)}})(`.dropin-button,.dropin-iconButton{border:0 none;cursor:pointer;white-space:normal}.dropin-button{border-radius:var(--shape-border-radius-3);font-size:var(--type-button-1-font);font-weight:var(--type-button-1-font);padding:var(--spacing-xsmall) var(--spacing-medium);display:flex;justify-content:center;align-items:center;text-align:left;word-wrap:break-word}.dropin-iconButton{height:var(--spacing-xbig);width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button:disabled,.dropin-iconButton:disabled{pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button:not(:disabled),.dropin-iconButton:not(:disabled){cursor:pointer}.dropin-button:focus,.dropin-iconButton:focus{outline:none}.dropin-button:focus-visible,.dropin-iconButton:focus-visible{outline:var(--spacing-xxsmall) solid var(--color-button-focus)}.dropin-button--primary,a.dropin-button--primary,.dropin-iconButton--primary{border:none;background:var(--color-brand-500) 0 0% no-repeat padding-box;color:var(--color-neutral-50);text-align:left;margin-right:0}.dropin-iconButton--primary{border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button--primary--disabled,a.dropin-button--primary--disabled,.dropin-iconButton--primary--disabled{background:var(--color-neutral-300) 0 0% no-repeat padding-box;color:var(--color-neutral-500);fill:var(--color-neutral-300);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--primary:hover,a.dropin-button--primary:hover,.dropin-iconButton--primary:hover,.dropin-button--primary:focus:hover,.dropin-iconButton--primary:focus:hover{background-color:var(--color-button-hover);text-decoration:none}.dropin-button--primary:focus,.dropin-iconButton--primary:focus{background-color:var(--color-brand-500)}.dropin-button--primary:hover:active,.dropin-iconButton--primary:hover:active{background-color:var(--color-button-active)}.dropin-button--secondary,a.dropin-button--secondary,.dropin-iconButton--secondary{border:var(--shape-border-width-2) solid var(--color-brand-500);background:none 0 0% no-repeat padding-box;color:var(--color-brand-500);padding-top:calc(var(--spacing-xsmall) - var(--shape-border-width-2));padding-left:calc(var(--spacing-medium) - var(--shape-border-width-2))}.dropin-iconButton--secondary{border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall);padding-top:calc(var(--spacing-xsmall) - var(--shape-border-width-2));padding-left:calc(var(--spacing-xsmall) - var(--shape-border-width-2))}.dropin-button--secondary--disabled,a.dropin-button--secondary--disabled,.dropin-iconButton--secondary--disabled{border:var(--shape-border-width-2) solid var(--color-neutral-300);background:none 0 0% no-repeat padding-box;color:var(--color-neutral-500);fill:var(--color-neutral-300);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--secondary:hover,a.dropin-button--secondary:hover,.dropin-iconButton--secondary:hover{border:var(--shape-border-width-2) solid var(--color-button-hover);color:var(--color-button-hover);text-decoration:none}.dropin-button--secondary:active,.dropin-iconButton--secondary:active{border:var(--shape-border-width-2) solid var(--color-button-active);color:var(--color-button-active)}.dropin-button--tertiary,a.dropin-button--tertiary,.dropin-iconButton--tertiary{border:none;background:none 0 0% no-repeat padding-box;color:var(--color-brand-500)}.dropin-iconButton--tertiary{border:none;border-radius:var(--spacing-xbig);min-height:var(--spacing-xbig);min-width:var(--spacing-xbig);padding:var(--spacing-xsmall)}.dropin-button--tertiary--disabled,a.dropin-button--tertiary--disabled,.dropin-iconButton--tertiary--disabled{border:none;color:var(--color-neutral-500);pointer-events:none;-webkit-user-select:none;user-select:none}.dropin-button--tertiary:hover,a.dropin-button--tertiary:hover,.dropin-iconButton--tertiary:hover{color:var(--color-button-hover);text-decoration:none}.dropin-button--tertiary:active,.dropin-iconButton--tertiary:active{color:var(--color-button-active)}.dropin-button--tertiary:focus-visible,.dropin-iconButton--tertiary:focus-visible{-webkit-box-shadow:inset 0 0 0 2px var(--color-neutral-800);-moz-box-shadow:inset 0 0 0 2px var(--color-neutral-800);box-shadow:inset 0 0 0 2px var(--color-neutral-800)}.dropin-button--large{font:var(--type-button-1-font);letter-spacing:var(--type-button-1-letter-spacing)}.dropin-button--medium{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.dropin-button-icon{height:24px}.dropin-button--with-icon{column-gap:var(--spacing-xsmall);row-gap:var(--spacing-xsmall)} -.order-customer-details-content .dropin-card__content{gap:0}.order-customer-details-content__container{display:block;flex-direction:column}.order-customer-details-content__container-shipping_address,.order-customer-details-content__container-billing_address{margin:var(--spacing-medium) 0}@media (min-width: 768px){.order-customer-details-content__container{display:grid;grid-template-columns:auto;grid-template-rows:auto auto auto;grid-auto-flow:row}.order-customer-details-content__container-email{grid-area:1 / 1 / 2 / 2}.order-customer-details-content__container--no-margin p{margin-bottom:0}.order-customer-details-content__container-shipping_address{grid-area:2 / 1 / 3 / 2;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address,.order-customer-details-content__container-return-information{grid-area:2 / 2 / 3 / 3;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address--fullwidth{grid-area:2 / 1 / 3 / 3}.order-customer-details-content__container-shipping_methods{grid-area:3 / 1 / 4 / 2}.order-customer-details-content__container-payment_methods{grid-area:3 / 2 / 4 / 3}.order-customer-details-content__container-payment_methods--fullwidth{grid-area:3 / 1 / 4 / 3}}.order-customer-details-content__container-title{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.order-customer-details-content__container p{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:0}.order-customer-details-content__container-payment_methods p{display:grid;gap:0;grid-template-columns:auto 1fr}.order-customer-details-content__container-payment_methods p.order-customer-details-content__container-payment_methods--icon{gap:0 var(--spacing-xsmall)}.order-customer-details-content__container-description p{margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-big);padding:0}.order-customer-details-content__container-description p:nth-child(1),.order-customer-details-content__container-description p:nth-child(3),.order-customer-details-content__container-description p:nth-child(4),.order-customer-details-content__container-description p:nth-child(6){float:left}.order-customer-details-content__container-return-information .order-customer-details-content__container-description p{float:none;display:block}.order-empty-list{margin-bottom:var(--spacing-small)}.order-empty-list.order-empty-list--minified,.order-empty-list .dropin-card{border:none}.order-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.order-empty-list.order-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.order-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.order-empty-list.order-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.order-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list--empty-box .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.order-order-actions__wrapper{display:flex;justify-content:space-between;gap:0 var(--spacing-small);margin-bottom:var(--spacing-small);margin-top:var(--spacing-medium)}.order-order-actions__wrapper button{width:100%;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing);cursor:pointer}.order-order-actions__wrapper--empty{display:none}.order-order-cancel-reasons-form__text{text-align:left;color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel-reasons-form__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}.order-order-cancel__modal{margin:auto}.order-order-cancel__modal .dropin-modal__header{display:grid;grid-template-columns:1fr auto}.order-order-cancel__title{color:var(--color-neutral-900);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-order-cancel__text{color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel__modal .dropin-modal__header-close-button{align-self:center}.order-order-cancel__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}@media only screen and (min-width: 768px){.dropin-modal__body--medium.order-order-cancel__modal>.dropin-modal__header-title{margin:0 var(--spacing-xxbig) var(--spacing-medium)}}.order-order-loaders--card-loader{margin-bottom:var(--spacing-small)}.order-cost-summary-content .dropin-card__content{gap:0}.order-cost-summary-content__description{margin-bottom:var(--spacing-xsmall)}.order-cost-summary-content__description .order-cost-summary-content__description--header,.order-cost-summary-content__description .order-cost-summary-content__description--subheader{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__description .order-cost-summary-content__description--header span{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-cost-summary-content__description--subheader{margin-top:var(--spacing-xxsmall)}.order-cost-summary-content__description--subheader span{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-brand-700)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader{display:flex;justify-content:flex-start;align-items:center;gap:0 var(--spacing-xxsmall)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader .dropin-price,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-overline-font)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--header span:last-child{color:var(--color-alert-800)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child{display:flex;justify-content:flex-start;align-items:flex-end;gap:0 var(--spacing-xsmall)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child span{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-neutral-700)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-alert-800)}.order-cost-summary-content__description--total{margin-top:var(--spacing-medium)}.order-cost-summary-content__description--total .order-cost-summary-content__description--header span{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.order-cost-summary-content__accordion .dropin-accordion-section .dropin-accordion-section__content-container{gap:var(--spacing-small);margin:var(--spacing-small) 0}.order-cost-summary-content__accordion-row{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__accordion-row p{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-cost-summary-content__accordion-row p:first-child{color:var(--color-neutral-700)}.order-cost-summary-content__accordion .order-cost-summary-content__accordion-row.order-cost-summary-content__accordion-total p:first-child{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-header{text-align:center;padding:var(--spacing-xxbig)}.order-header__icon{margin-bottom:var(--spacing-small)}.order-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-header__title:first-letter{text-transform:uppercase}.order-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-header .success-icon{color:var(--color-positive-500)}.order-header-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-header-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-header-create-account__button{display:flex;margin:0 auto;text-align:center}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin:0 0 var(--spacing-medium) 0;padding:0}.order-order-product-list-content .dropin-card__content{gap:0}.order-order-product-list-content__items .dropin-card__content{gap:var(--spacing-xsmall)}.order-order-product-list-content .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-order-product-list-content .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-cart-summary-item{margin-bottom:var(--spacing-medium)}}.order-order-search-form{gap:var(--spacing-small);border-color:transparent}.order-order-search-form .dropin-card__content{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}.order-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-order-search-form__wrapper{display:grid;grid-template-columns:1fr;grid-template-rows:auto;grid-template-areas:"email" "lastname" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--lastname{grid-area:lastname}.order-order-search-form__wrapper__item--number{grid-area:number}.order-order-search-form__button-container{display:flex;justify-content:flex-end;grid-area:button}.order-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}@media (min-width: 768px){.order-order-search-form__wrapper{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;grid-template-areas:"email lastname" "number number" "button button"}}.order-order-status-content .dropin-card__content{gap:0}.order-order-status-content__wrapper .order-order-status-content__wrapper-description p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.order-order-status-content__wrapper-description--actions-slot{margin-bottom:0}.order-return-order-message p{margin:0;padding:0}.order-return-order-message a{max-width:162px;padding:var(--spacing-xsmall)}.order-return-order-message .order-return-order-message__title{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800);margin-bottom:var(--spacing-small)}.order-return-order-message .order-return-order-message__subtitle{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-bottom:var(--spacing-xlarge)}.order-create-return .order-create-return_notification{margin-bottom:var(--spacing-medium)}.order-return-order-product-list{list-style:none;margin:0;padding:0}.order-return-order-product-list .order-return-order-product-list__item{display:grid;grid-template-columns:auto 1fr;align-items:start;margin-bottom:var(--spacing-medium);position:relative}.order-return-order-product-list__item--blur:before{content:"";position:absolute;width:100%;height:100%;background-color:var(--color-opacity-24);z-index:1}.order-return-order-product-list>.order-return-order-product-list__item:last-child{display:flex;justify-content:flex-end}.order-return-order-product-list>.order-return-order-product-list__item .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-return-order-product-list>.order-return-order-product-list__item .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-create-return .dropin-cart-item__footer .dropin-incrementer.dropin-incrementer--medium{max-width:160px}.order-return-order-product-list .dropin-incrementer__button-container{margin:0}@media only screen and (min-width: 320px) and (max-width: 768px){.order-return-order-product-list>.order-return-order-product-list__item{margin-bottom:var(--spacing-medium)}}.order-return-reason-form .dropin-cart-item,.order-return-reason-form form .dropin-field{margin-bottom:var(--spacing-medium)}.order-return-reason-form .order-return-reason-form__actions{display:flex;gap:0 var(--spacing-medium);justify-content:flex-end;margin-bottom:0}.order-returns-list-content .order-returns__header--minified{margin-bottom:var(--spacing-small)}.order-returns-list-content .order-returns__header--full-size{margin-bottom:0}.order-returns-list-content__cards-list{margin-bottom:var(--spacing-small)}.order-returns-list-content__cards-list .dropin-card__content{gap:0}.order-returns-list-content__cards-grid{display:grid;grid-template-columns:1fr 1fr auto;gap:0px 0px;grid-template-areas:"descriptions descriptions actions" "images images actions"}.order-returns-list-content__descriptions{grid-area:descriptions}.order-returns-list-content__descriptions p{margin:0 0 var(--spacing-small) 0;padding:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);color:var(--color-neutral-800)}.order-returns-list-content__descriptions p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-returns-list-content__descriptions p a:hover{color:var(--color-brand-800)}.order-returns-list-content__descriptions .order-returns-list-content__return-status{font:var(--type-button-2-font);font-weight:500;color:var(--color-neutral-800)}.order-returns-list-content .order-returns-list-content__actions{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.order-returns-list-content a.order-returns-list-content__actions{display:inline-block;width:100%}.order-returns-list-content .order-returns-list-content__actions:hover{text-decoration:none;color:var(--color-brand-500)}.order-returns-list-content__card .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.order-returns-list-content__card .order-returns-list-content__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.order-returns-list-content__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.order-returns-list-content__card-wrapper svg{color:var(--color-neutral-800)}.order-returns-list-content__images{margin-top:var(--spacing-small);grid-area:images}.order-returns-list-content__actions{grid-area:actions;align-self:center}.order-returns-list-content .order-returns-list-content__images{overflow:auto}.order-returns-list-content .order-returns-list-content__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-returns-list-content .order-returns-list-content__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.order-returns-list-content .order-returns-list-content__images img{object-fit:contain;width:85px;height:114px}.order-shipping-status-card .dropin-card__content{gap:0}.order-shipping-status-card--count-steper{font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-shipping-status-card__header{display:grid;grid-template-columns:1fr auto;justify-items:self-start;align-items:center;margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card__header button{max-height:40px}.order-shipping-status-card__header--content p,.order-shipping-status-card--return-order p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card--return-order p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-shipping-status-card--return-order p a:hover{text-decoration:none;color:var(--color-brand-800)}.order-shipping-status-card .order-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-shipping-status-card.order-shipping-status-card--return-order .dropin-content-grid.order-shipping-status-card__images{overflow:auto!important}.order-shipping-status-card .order-shipping-status-card__images img{object-fit:contain;width:85px;height:114px}`,{styleId:"order"}); -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as n,useEffect as d}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const u={CreateReturn:{headerText:"Return items",downloadableCount:"Files",returnedItems:"Returned items:",configurationsList:{quantity:"Quantity"},stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},giftCard:{sender:"Sender",recipient:"Recipient",message:"Note"},success:{title:"Return submitted",message:"Your return request has been successfully submitted."},buttons:{nextStep:"Continue",backStep:"Back",submit:"Submit return",backStore:"Back to order"}},OrderCostSummary:{headerText:"Order summary",headerReturnText:"Return summary",subtotal:{title:"Subtotal"},shipping:{title:"Shipping",freeShipping:"Free shipping"},tax:{accordionTitle:"Taxes",accordionTotalTax:"Tax Total",totalExcludingTaxes:"Total excluding taxes",title:"Tax",incl:"Including taxes",excl:"Excluding taxes"},discount:{title:"Discount",subtitle:"discounted"},total:{title:"Total"}},Returns:{minifiedView:{returnsList:{viewAllOrdersButton:"View all returns",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Recent returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}},fullSizeView:{returnsList:{viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}}},OrderProductListContent:{cancelledTitle:"Cancelled",allOrdersTitle:"Your order",returnedTitle:"Returned",refundedTitle:"Your refunded",downloadableCount:"Files",stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},GiftCard:{sender:"Sender",recipient:"Recipient",message:"Note"}},OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",lastname:"Last Name",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{orderNumber:"Order number:",returnNumber:"Return number:",itemText:{none:"",one:"Package contents ({{count}} item)",many:"Package contents ({{count}} items)"},trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",returnOrderCardTitle:"Package details",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping information",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:{singular:"Package contents ({{count}} item)",plural:"Package contents ({{count}} items)"}},OrderStatusContent:{noInfoTitle:"Check back later for more details.",returnMessage:"The order was placed on {ORDER_CREATE_DATE} and your return process started on {RETURN_CREATE_DATE}",returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},actions:{cancel:"Cancel order",createReturn:"Return or replace",createAnotherReturn:"Start another return",reorder:"Reorder"},orderPlaceholder:{title:"",message:"Your order has been in its current status since {DATE}.",messageWithoutDate:"Your order has been in its current status for some time."},orderPending:{title:"Pending",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderProcessing:{title:"Processing",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderOnHold:{title:"On hold",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderReceived:{title:"Order received",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderComplete:{title:"Complete",message:"Your order is complete. Need help with your order? Contact us at support@adobe.com"},orderCanceled:{title:"Canceled",message:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days.",messageWithoutDate:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days."},orderSuspectedFraud:{title:"Suspected fraud",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderPaymentReview:{title:"Payment Review",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},guestOrderCancellationRequested:{title:"cancellation requested",message:"The cancellation has been requested on {DATE}. Check your email for further instructions.",messageWithoutDate:"The cancellation has been requested. Check your email for further instructions."},orderPendingPayment:{title:"Pending Payment",message:"The order was successfully placed on {DATE}, but it is awaiting payment. Please complete the payment so we can start processing your order.",messageWithoutDate:"Your order is awaiting payment. Please complete the payment so we can start processing your order."},orderRejected:{title:"Rejected",message:"Your order was rejected on {DATE}. Please contact us for more information.",messageWithoutDate:"Your order was rejected. Please contact us for more information."},orderAuthorized:{title:"Authorized",message:"Your order was successfully authorized on {DATE}. We will begin processing your order shortly.",messageWithoutDate:"Your order was successfully authorized. We will begin processing your order shortly."},orderPaypalCanceledReversal:{title:"PayPal Canceled Reversal",message:"The PayPal transaction reversal was canceled on {DATE}. Please check your order details for more information.",messageWithoutDate:"The PayPal transaction reversal was canceled. Please check your order details for more information."},orderPendingPaypal:{title:"Pending PayPal",message:"Your order is awaiting PayPal payment confirmation since {DATE}. Please check your PayPal account for the payment status.",messageWithoutDate:"Your order is awaiting PayPal payment confirmation. Please check your PayPal account for the payment status."},orderPaypalReversed:{title:"PayPal Reversed",message:"The PayPal payment was reversed on {DATE}. Please contact us for further details.",messageWithoutDate:"The PayPal payment was reversed. Please contact us for further details."},orderClosed:{title:"Closed",message:"The order placed on {DATE} has been closed. For any further assistance, please contact support.",messageWithoutDate:"Your order has been closed. For any further assistance, please contact support."}},CustomerDetails:{headerText:"Customer information",freeShipping:"Free shipping",orderReturnLabels:{createdReturnAt:"Return requested on: ",returnStatusLabel:"Return status: ",orderNumberLabel:"Order number: "},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},paymentMethods:{title:"Payment method"},returnInformation:{title:"Return details"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details."},OrderCancel:{buttonText:"Cancel Order"},OrderCancelForm:{title:"Cancel order",description:"Select a reason for canceling the order",label:"Reason for cancel",button:"Submit Cancellation",errorHeading:"Error",errorDescription:"There was an error processing your order cancellation."},OrderHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},p={Order:u},m={default:p},h=({children:t})=>{const[o,a]=n("en_US");return d(()=>{const e=c.on("locale",s=>{a(s)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},T=new i(r(h,{}));export{T as render}; +.order-customer-details-content .dropin-card__content{gap:0}.order-customer-details-content__container{display:block;flex-direction:column}.order-customer-details-content__container-shipping_address,.order-customer-details-content__container-billing_address{margin:var(--spacing-medium) 0}@media (min-width: 768px){.order-customer-details-content__container{display:grid;grid-template-columns:auto;grid-template-rows:auto auto auto;grid-auto-flow:row}.order-customer-details-content__container-email{grid-area:1 / 1 / 2 / 2}.order-customer-details-content__container--no-margin p{margin-bottom:0}.order-customer-details-content__container-shipping_address{grid-area:2 / 1 / 3 / 2;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address,.order-customer-details-content__container-return-information{grid-area:2 / 2 / 3 / 3;margin:var(--spacing-medium) 0}.order-customer-details-content__container-billing_address--fullwidth{grid-area:2 / 1 / 3 / 3}.order-customer-details-content__container-shipping_methods{grid-area:3 / 1 / 4 / 2}.order-customer-details-content__container-payment_methods{grid-area:3 / 2 / 4 / 3}.order-customer-details-content__container-payment_methods--fullwidth{grid-area:3 / 1 / 4 / 3}}.order-customer-details-content__container-title{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.order-customer-details-content__container p{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:0}.order-customer-details-content__container-payment_methods p{display:grid;gap:0;grid-template-columns:auto 1fr}.order-customer-details-content__container-payment_methods p.order-customer-details-content__container-payment_methods--icon{gap:0 var(--spacing-xsmall)}.order-customer-details-content__container-description p{margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-big);padding:0}.order-customer-details-content__container-description p:nth-child(1),.order-customer-details-content__container-description p:nth-child(3),.order-customer-details-content__container-description p:nth-child(4),.order-customer-details-content__container-description p:nth-child(6){float:left}.order-customer-details-content__container-return-information .order-customer-details-content__container-description p{float:none;display:block}.order-empty-list{margin-bottom:var(--spacing-small)}.order-empty-list.order-empty-list--minified,.order-empty-list .dropin-card{border:none}.order-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.order-empty-list.order-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.order-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.order-empty-list.order-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.order-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list--empty-box .dropin-card__content svg path{fill:var(--color-neutral-500)}.order-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.order-empty-list.order-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.order-order-actions__wrapper{display:flex;justify-content:space-between;gap:0 var(--spacing-small);margin-bottom:var(--spacing-small);margin-top:var(--spacing-medium)}.order-order-actions__wrapper button{width:100%;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing);cursor:pointer}.order-order-actions__wrapper--empty{display:none}.order-order-cancel-reasons-form__text{text-align:left;color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel-reasons-form__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}.order-order-cancel__modal{margin:auto}.order-order-cancel__modal .dropin-modal__header{display:grid;grid-template-columns:1fr auto}.order-order-cancel__title{color:var(--color-neutral-900);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-order-cancel__text{color:var(--color-neutral-800);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);padding-bottom:var(--spacing-xsmall)}.order-order-cancel__modal .dropin-modal__header-close-button{align-self:center}.order-order-cancel__button-container{display:grid;margin-top:var(--spacing-xbig);justify-content:end}@media only screen and (min-width: 768px){.dropin-modal__body--medium.order-order-cancel__modal>.dropin-modal__header-title{margin:0 var(--spacing-xxbig) var(--spacing-medium)}}.order-order-loaders--card-loader{margin-bottom:var(--spacing-small)}.order-cost-summary-content .dropin-card__content{gap:0}.order-cost-summary-content__description{margin-bottom:var(--spacing-xsmall)}.order-cost-summary-content__description .order-cost-summary-content__description--header,.order-cost-summary-content__description .order-cost-summary-content__description--subheader{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__description .order-cost-summary-content__description--header span{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-cost-summary-content__description--subheader{margin-top:var(--spacing-xxsmall)}.order-cost-summary-content__description--subheader span{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-brand-700)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader{display:flex;justify-content:flex-start;align-items:center;gap:0 var(--spacing-xxsmall)}.order-cost-summary-content__description--subtotal .order-cost-summary-content__description--subheader .dropin-price,.order-cost-summary-content__description--shipping .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-overline-font);font-weight:700}.order-cost-summary-content__description--discount .order-cost-summary-content__description--header span:last-child{color:var(--color-alert-800)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child{display:flex;justify-content:flex-start;align-items:flex-end;gap:0 var(--spacing-xsmall)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader span:first-child span{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-neutral-700)}.order-cost-summary-content__description--discount .order-cost-summary-content__description--subheader .dropin-price{font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);color:var(--color-alert-800)}.order-cost-summary-content__description--total{margin-top:var(--spacing-medium)}.order-cost-summary-content__description--total .order-cost-summary-content__description--header span{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.order-cost-summary-content__accordion .dropin-accordion-section .dropin-accordion-section__content-container{gap:var(--spacing-small);margin:var(--spacing-small) 0}.order-cost-summary-content__accordion-row{display:flex;justify-content:space-between;align-items:center}.order-cost-summary-content__accordion-row p{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.order-cost-summary-content__accordion-row p:first-child{color:var(--color-neutral-700)}.order-cost-summary-content__accordion .order-cost-summary-content__accordion-row.order-cost-summary-content__accordion-total p:first-child{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-header{text-align:center;padding:var(--spacing-xxbig)}.order-header__icon{margin-bottom:var(--spacing-small)}.order-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-header__title:first-letter{text-transform:uppercase}.order-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-header .success-icon{color:var(--color-positive-500)}.order-header-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-header-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-header-create-account__button{display:flex;margin:0 auto;text-align:center}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin:0 0 var(--spacing-medium) 0;padding:0}.order-order-product-list-content .dropin-card__content{gap:0}.order-order-product-list-content__items .dropin-card__content{gap:var(--spacing-xsmall)}.order-order-product-list-content .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-order-product-list-content .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}@media only screen and (min-width: 320px) and (max-width: 768px){.order-confirmation-cart-summary-item{margin-bottom:var(--spacing-medium)}}.order-order-search-form{gap:var(--spacing-small);border-color:transparent}.order-order-search-form .dropin-card__content{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}.order-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.order-order-search-form__wrapper{display:grid;grid-template-columns:1fr;grid-template-rows:auto;grid-template-areas:"email" "lastname" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--lastname{grid-area:lastname}.order-order-search-form__wrapper__item--number{grid-area:number}.order-order-search-form__button-container{display:flex;justify-content:flex-end;grid-area:button}.order-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}@media (min-width: 768px){.order-order-search-form__wrapper{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;grid-template-areas:"email lastname" "number number" "button button"}}.order-order-status-content .dropin-card__content{gap:0}.order-order-status-content__wrapper .order-order-status-content__wrapper-description p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.order-order-status-content__wrapper-description--actions-slot{margin-bottom:0}.order-return-order-message p{margin:0;padding:0}.order-return-order-message a{max-width:162px;padding:var(--spacing-xsmall)}.order-return-order-message .order-return-order-message__title{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800);margin-bottom:var(--spacing-small)}.order-return-order-message .order-return-order-message__subtitle{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-bottom:var(--spacing-xlarge)}.order-create-return .order-create-return_notification{margin-bottom:var(--spacing-medium)}.order-return-order-product-list{list-style:none;margin:0;padding:0}.order-return-order-product-list .order-return-order-product-list__item{display:grid;grid-template-columns:auto 1fr;align-items:start;margin-bottom:var(--spacing-medium);position:relative}.order-return-order-product-list__item--blur:before{content:"";position:absolute;width:100%;height:100%;background-color:var(--color-opacity-24);z-index:1}.order-return-order-product-list>.order-return-order-product-list__item:last-child{display:flex;justify-content:flex-end}.order-return-order-product-list>.order-return-order-product-list__item .dropin-cart-item__alert{margin-top:var(--spacing-xsmall)}.order-return-order-product-list>.order-return-order-product-list__item .cart-summary-item__title--strikethrough{text-decoration:line-through;color:var(--color-neutral-500);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-create-return .dropin-cart-item__footer .dropin-incrementer.dropin-incrementer--medium{max-width:160px}.order-return-order-product-list .dropin-incrementer__button-container{margin:0}@media only screen and (min-width: 320px) and (max-width: 768px){.order-return-order-product-list>.order-return-order-product-list__item{margin-bottom:var(--spacing-medium)}}.order-return-reason-form .dropin-cart-item,.order-return-reason-form form .dropin-field{margin-bottom:var(--spacing-medium)}.order-return-reason-form .order-return-reason-form__actions{display:flex;gap:0 var(--spacing-medium);justify-content:flex-end;margin-bottom:0}.order-returns-list-content .order-returns__header--minified{margin-bottom:var(--spacing-small)}.order-returns-list-content .order-returns__header--full-size{margin-bottom:0}.order-returns-list-content__cards-list{margin-bottom:var(--spacing-small)}.order-returns-list-content__cards-list .dropin-card__content{gap:0}.order-returns-list-content__cards-grid{display:grid;grid-template-columns:1fr 1fr auto;gap:0px 0px;grid-template-areas:"descriptions descriptions actions" "images images actions"}.order-returns-list-content__descriptions{grid-area:descriptions}.order-returns-list-content__descriptions p{margin:0 0 var(--spacing-small) 0;padding:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);color:var(--color-neutral-800)}.order-returns-list-content__descriptions p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-returns-list-content__descriptions p a:hover{color:var(--color-brand-800)}.order-returns-list-content__descriptions .order-returns-list-content__return-status{font:var(--type-button-2-font);font-weight:500;color:var(--color-neutral-800)}.order-returns-list-content .order-returns-list-content__actions{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.order-returns-list-content a.order-returns-list-content__actions{display:inline-block;width:100%}.order-returns-list-content .order-returns-list-content__actions:hover{text-decoration:none;color:var(--color-brand-500)}.order-returns-list-content__card .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.order-returns-list-content__card .order-returns-list-content__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.order-returns-list-content__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.order-returns-list-content__card-wrapper svg{color:var(--color-neutral-800)}.order-returns-list-content__images{margin-top:var(--spacing-small);grid-area:images}.order-returns-list-content__actions{grid-area:actions;align-self:center}.order-returns-list-content .order-returns-list-content__images{overflow:auto}.order-returns-list-content .order-returns-list-content__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-returns-list-content .order-returns-list-content__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.order-returns-list-content .order-returns-list-content__images img{object-fit:contain;width:85px;height:114px}.order-shipping-status-card .dropin-card__content{gap:0}.order-shipping-status-card--count-steper{font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.order-shipping-status-card__header{display:grid;grid-template-columns:1fr auto;justify-items:self-start;align-items:center;margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card__header button{max-height:40px}.order-shipping-status-card__header--content p,.order-shipping-status-card--return-order p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card--return-order p a{display:inline-block;font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-brand-800)}.order-shipping-status-card--return-order p a:hover{text-decoration:none;color:var(--color-brand-800)}.order-shipping-status-card .order-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.order-shipping-status-card.order-shipping-status-card--return-order .dropin-content-grid.order-shipping-status-card__images{overflow:auto!important}.order-shipping-status-card .order-shipping-status-card__images img{object-fit:contain;width:85px;height:114px}`,{styleId:"order"}); +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as n,useEffect as d}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const u={CreateReturn:{headerText:"Return items",downloadableCount:"Files",returnedItems:"Returned items:",configurationsList:{quantity:"Quantity"},stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},giftCard:{sender:"Sender",recipient:"Recipient",message:"Note"},success:{title:"Return submitted",message:"Your return request has been successfully submitted."},buttons:{nextStep:"Continue",backStep:"Back",submit:"Submit return",backStore:"Back to order"}},OrderCostSummary:{headerText:"Order summary",headerReturnText:"Return summary",subtotal:{title:"Subtotal"},shipping:{title:"Shipping",freeShipping:"Free shipping"},tax:{accordionTitle:"Taxes",accordionTotalTax:"Tax Total",totalExcludingTaxes:"Total excluding taxes",title:"Tax",incl:"Including taxes",excl:"Excluding taxes"},discount:{title:"Discount",subtitle:"discounted"},total:{title:"Total"}},Returns:{minifiedView:{returnsList:{viewAllOrdersButton:"View all returns",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Recent returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}},fullSizeView:{returnsList:{viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",emptyOrdersListMessage:"No returns",minifiedViewTitle:"Returns",orderNumber:"Order number:",returnNumber:"Return number:",carrier:"Carrier:",itemText:{none:"",one:"item",many:"items"},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"}}}},OrderProductListContent:{cancelledTitle:"Cancelled",allOrdersTitle:"Your order",returnedTitle:"Returned",refundedTitle:"Your refunded",downloadableCount:"Files",stockStatus:{inStock:"In stock",outOfStock:"Out of stock"},GiftCard:{sender:"Sender",recipient:"Recipient",message:"Note"}},OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",lastname:"Last Name",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{orderNumber:"Order number:",returnNumber:"Return number:",itemText:{none:"",one:"Package contents ({{count}} item)",many:"Package contents ({{count}} items)"},trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",returnOrderCardTitle:"Package details",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping information",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:{singular:"Package contents ({{count}} item)",plural:"Package contents ({{count}} items)"}},OrderStatusContent:{noInfoTitle:"Check back later for more details.",returnMessage:"The order was placed on {ORDER_CREATE_DATE} and your return process started on {RETURN_CREATE_DATE}",returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},actions:{cancel:"Cancel order",confirmGuestReturn:"Return request confirmed",confirmGuestReturnMessage:"Your return request has been successfully confirmed.",createReturn:"Return or replace",createAnotherReturn:"Start another return",reorder:"Reorder"},orderPlaceholder:{title:"",message:"Your order has been in its current status since {DATE}.",messageWithoutDate:"Your order has been in its current status for some time."},orderPending:{title:"Pending",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderProcessing:{title:"Processing",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderOnHold:{title:"On hold",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderReceived:{title:"Order received",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},orderComplete:{title:"Complete",message:"Your order is complete. Need help with your order? Contact us at support@adobe.com"},orderCanceled:{title:"Canceled",message:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days.",messageWithoutDate:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days."},orderSuspectedFraud:{title:"Suspected fraud",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information.",messageWithoutDate:"We’ve run into an issue while processing your order. Please check back later or contact us at support@adobe.com for more information."},orderPaymentReview:{title:"Payment Review",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships.",messageWithoutDate:"Your order is processing. Check back for more details when your order ships."},guestOrderCancellationRequested:{title:"Cancellation requested",message:"The cancellation has been requested on {DATE}. Check your email for further instructions.",messageWithoutDate:"The cancellation has been requested. Check your email for further instructions."},orderPendingPayment:{title:"Pending Payment",message:"The order was successfully placed on {DATE}, but it is awaiting payment. Please complete the payment so we can start processing your order.",messageWithoutDate:"Your order is awaiting payment. Please complete the payment so we can start processing your order."},orderRejected:{title:"Rejected",message:"Your order was rejected on {DATE}. Please contact us for more information.",messageWithoutDate:"Your order was rejected. Please contact us for more information."},orderAuthorized:{title:"Authorized",message:"Your order was successfully authorized on {DATE}. We will begin processing your order shortly.",messageWithoutDate:"Your order was successfully authorized. We will begin processing your order shortly."},orderPaypalCanceledReversal:{title:"PayPal Canceled Reversal",message:"The PayPal transaction reversal was canceled on {DATE}. Please check your order details for more information.",messageWithoutDate:"The PayPal transaction reversal was canceled. Please check your order details for more information."},orderPendingPaypal:{title:"Pending PayPal",message:"Your order is awaiting PayPal payment confirmation since {DATE}. Please check your PayPal account for the payment status.",messageWithoutDate:"Your order is awaiting PayPal payment confirmation. Please check your PayPal account for the payment status."},orderPaypalReversed:{title:"PayPal Reversed",message:"The PayPal payment was reversed on {DATE}. Please contact us for further details.",messageWithoutDate:"The PayPal payment was reversed. Please contact us for further details."},orderClosed:{title:"Closed",message:"The order placed on {DATE} has been closed. For any further assistance, please contact support.",messageWithoutDate:"Your order has been closed. For any further assistance, please contact support."}},CustomerDetails:{headerText:"Customer information",freeShipping:"Free shipping",orderReturnLabels:{createdReturnAt:"Return requested on: ",returnStatusLabel:"Return status: ",orderNumberLabel:"Order number: "},returnStatus:{pending:"Pending",authorized:"Authorized",partiallyAuthorized:"Partially authorized",received:"Received",partiallyReceived:"Partially received",approved:"Approved",partiallyApproved:"Partially approved",rejected:"Rejected",partiallyRejected:"Partially rejected",denied:"Denied",processedAndClosed:"Processed and closed",closed:"Closed"},email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},paymentMethods:{title:"Payment method"},returnInformation:{title:"Return details"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details."},OrderCancel:{buttonText:"Cancel Order"},OrderCancelForm:{title:"Cancel order",description:"Select a reason for canceling the order",label:"Reason for cancel",button:"Submit Cancellation",errorHeading:"Error",errorDescription:"There was an error processing your order cancellation."},OrderHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},p={Order:u},m={default:p},h=({children:t})=>{const[o,a]=n("en_US");return d(()=>{const e=c.on("locale",s=>{a(s)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},T=new i(r(h,{}));export{T as render}; diff --git a/scripts/__dropins__/storefront-order/types/api/confirmGuestReturn.types.d.ts b/scripts/__dropins__/storefront-order/types/api/confirmGuestReturn.types.d.ts new file mode 100644 index 0000000000..f78068c721 --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/api/confirmGuestReturn.types.d.ts @@ -0,0 +1,18 @@ +import { OrderDataModel } from '../../data/models'; +import { ReturnProps } from './requestReturn.types'; + +interface ErrorsProps { + message: string; +} +export interface GuestConfirmReturnResponse { + data: { + confirmReturn: { + return: ReturnProps & { + order: OrderDataModel; + }; + }; + }; + errors?: ErrorsProps[]; +} +export {}; +//# sourceMappingURL=confirmGuestReturn.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts b/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts index ed9233bb5b..b9227060f0 100644 --- a/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/api/requestReturn.types.d.ts @@ -1,5 +1,5 @@ export interface RequestReturnProps { - orderUid: string; + orderUid?: string; contactEmail: string; items: { orderItemUid: string; @@ -14,20 +14,34 @@ export interface RequestReturnProps { }[]; }[]; } +export interface RequestGuestReturnProps extends RequestReturnProps { + token: string; + commentText: string; +} export interface ReturnProps { uid: string; number: string; status: string; created_at: string; } +interface ErrorsProps { + message: string; +} export interface RequestReturnResponse { data: { requestReturn: { return: ReturnProps; }; }; - errors?: { - message: string; - }[]; + errors?: ErrorsProps[]; +} +export interface RequestGuestReturnResponse { + data: { + requestGuestReturn: { + return: ReturnProps; + }; + }; + errors?: ErrorsProps[]; } +export {}; //# sourceMappingURL=requestReturn.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/index.d.ts b/scripts/__dropins__/storefront-order/types/index.d.ts index 4322eb4855..b1b829585e 100644 --- a/scripts/__dropins__/storefront-order/types/index.d.ts +++ b/scripts/__dropins__/storefront-order/types/index.d.ts @@ -8,6 +8,7 @@ export * from './api/guestOrderByToken.types'; export * from './api/placeOrder.types'; export * from './api/reorderItems.types'; export * from './api/requestReturn.types'; +export * from './api/confirmGuestReturn.types'; export * from './createReturn.types'; export * from './customerDetails.types'; export * from './emptyList.types'; @@ -22,4 +23,5 @@ export * from './orderStatus.types'; export * from './reorder.types'; export * from './returnsList.types'; export * from './shippingStatus.types'; +export * from './orderEmailActionHandler.types'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderCancel.types.d.ts b/scripts/__dropins__/storefront-order/types/orderCancel.types.d.ts index fe679f4a61..d475f88d9a 100644 --- a/scripts/__dropins__/storefront-order/types/orderCancel.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/orderCancel.types.d.ts @@ -10,7 +10,7 @@ export interface OrderCancelFormProps { submitButtonProps?: ButtonProps; cancelReasons: PickerOption[]; } -export interface ConfirmCancelOrderProps { +export interface UseOrderActionsProps { enableOrderCancellation: boolean | undefined; } //# sourceMappingURL=orderCancel.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderEmailActionHandler.types.d.ts b/scripts/__dropins__/storefront-order/types/orderEmailActionHandler.types.d.ts new file mode 100644 index 0000000000..3210948ee1 --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/orderEmailActionHandler.types.d.ts @@ -0,0 +1,4 @@ +export interface OrderEmailActionHandlerProps { + routeRedirect: (orderToken: string, orderNumber: string, orderData: any) => string; +} +//# sourceMappingURL=orderEmailActionHandler.types.d.ts.map \ No newline at end of file From 7c0c9a11bf44ca86f7799e78f3a6a34e6b32725b Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Mon, 9 Dec 2024 14:11:31 +0100 Subject: [PATCH 5/5] Bump order & account to latest beta versions --- package-lock.json | 16 +- package.json | 4 +- scripts/__dropins__/storefront-account/api.js | 2 +- .../chunks/CustomerInformationCard.js | 2 +- .../chunks/getOrderHistoryList.js | 61 +--- .../chunks/getStoreConfig.js | 4 +- .../chunks/removeCustomerAddress.js | 2 +- .../chunks/updateCustomer.js | 24 +- .../containers/CustomerInformation.js | 2 +- .../containers/OrdersList.js | 2 +- .../storefront-account/fragments.d.ts | 1 + .../storefront-account/fragments.js | 68 ++++ scripts/__dropins__/storefront-order/api.js | 8 +- .../api/{fragment.d.ts => fragments.d.ts} | 2 +- .../chunks/GurestOrderFragment.graphql.js | 99 ------ .../RequestReturnOrderFragment.graphql.js | 11 - .../chunks/confirmCancelOrder.js | 12 +- .../chunks/getCustomerOrdersReturn.js | 6 +- .../storefront-order/chunks/getGuestOrder.js | 2 +- .../storefront-order/chunks/initialize.js | 209 +----------- .../chunks/requestGuestOrderCancel.js | 8 +- .../chunks/requestGuestReturn.js | 8 +- .../containers/CreateReturn.js | 2 +- .../containers/OrderCancelForm.js | 2 +- .../containers/OrderSearch.js | 2 +- .../containers/OrderStatus.js | 2 +- .../containers/ReturnsList.js | 2 +- .../storefront-order/fragments.d.ts | 1 + .../__dropins__/storefront-order/fragments.js | 306 ++++++++++++++++++ 29 files changed, 436 insertions(+), 434 deletions(-) create mode 100644 scripts/__dropins__/storefront-account/fragments.d.ts create mode 100644 scripts/__dropins__/storefront-account/fragments.js rename scripts/__dropins__/storefront-order/api/{fragment.d.ts => fragments.d.ts} (93%) delete mode 100644 scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js delete mode 100644 scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js create mode 100644 scripts/__dropins__/storefront-order/fragments.d.ts create mode 100644 scripts/__dropins__/storefront-order/fragments.js diff --git a/package-lock.json b/package-lock.json index 2b58d1611f..10721d4d6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "1.0.0-beta2", + "@dropins/storefront-account": "1.0.0-beta3", "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "1.0.0-beta1", + "@dropins/storefront-order": "1.0.0-beta2", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" }, @@ -765,9 +765,9 @@ } }, "node_modules/@dropins/storefront-account": { - "version": "1.0.0-beta2", - "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-1.0.0-beta2.tgz", - "integrity": "sha512-kXTjWeNc9SyJ2HtG3Ev6nrR6GsxiHcM4IEMRY1L8/yX5qFwpR8p+iFsUhzRGstGH5MErj2IeAnaiAJ1QMoqtcA==" + "version": "1.0.0-beta3", + "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-1.0.0-beta3.tgz", + "integrity": "sha512-4U6791f+nyE5MvAE3FyYWGU9vhHUyxF1TtjnfjaQmxsHfTqEn1k9z7FF9RgK4TGGF9guTAR9DryKtbJLp7lb6w==" }, "node_modules/@dropins/storefront-auth": { "version": "1.0.0-beta2", @@ -783,9 +783,9 @@ "integrity": "sha512-w/6Me6NL1ImA8E3jSzazRihI6kLazVcOWTyXVycr0AgYz8Q2pBSCt9KlMzWZnFT9VsRuIn+wwMd8AsbQqQpetg==" }, "node_modules/@dropins/storefront-order": { - "version": "1.0.0-beta1", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.0-beta1.tgz", - "integrity": "sha512-FIuwWkVS2e8rvgqwZXZdAkQJ6JC9kHPYt5hArRhJCqZzoI8BaJDYM1GgWT/FN5hmnDRw0Xg4HbBDCU5eaBfA+A==" + "version": "1.0.0-beta2", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.0-beta2.tgz", + "integrity": "sha512-J1lvOdyMvxcIy0eQ9UFjI9Mriaw8YDgh8qp6WbuJwHrSFpqijmM3Z6kdNdNbkve8b/3BFTIwm9ZyePDSVB/Oeg==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0-beta3", diff --git a/package.json b/package.json index 694360a296..76fc666272 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "1.0.0-beta2", + "@dropins/storefront-account": "1.0.0-beta3", "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "0.10.0", "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "1.0.0-beta1", + "@dropins/storefront-order": "1.0.0-beta2", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.36.0" } diff --git a/scripts/__dropins__/storefront-account/api.js b/scripts/__dropins__/storefront-account/api.js index 9b5c62e921..d7caabd4ee 100644 --- a/scripts/__dropins__/storefront-account/api.js +++ b/scripts/__dropins__/storefront-account/api.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as o,g as d,i}from"./chunks/getStoreConfig.js";import{d as g,f as p,c as u,g as C,h as f,e as h,i as c,j as n,r as l,s as A,a as x,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as Q,b,a as v,u as E}from"./chunks/updateCustomer.js";import{g as w}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";export{o as config,g as createCustomerAddress,p as fetchGraphQl,u as getAttributesForm,C as getConfig,f as getCountries,Q as getCustomer,h as getCustomerAddress,w as getOrderHistoryList,c as getRegions,d as getStoreConfig,i as initialize,n as removeCustomerAddress,l as removeFetchGraphQlHeader,A as setEndpoint,x as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,b as updateCustomer,G as updateCustomerAddress,v as updateCustomerEmail,E as updateCustomerPassword}; +import{c as i,g as m,i as d}from"./chunks/getStoreConfig.js";import{d as g,f as u,c as C,g as f,h,e as c,i as n,j as l,r as A,s as x,a as F,b as G,u as H}from"./chunks/removeCustomerAddress.js";import{g as b,b as v,a as E,u as j}from"./chunks/updateCustomer.js";import{g as y}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"./fragments.js";export{i as config,g as createCustomerAddress,u as fetchGraphQl,C as getAttributesForm,f as getConfig,h as getCountries,b as getCustomer,c as getCustomerAddress,y as getOrderHistoryList,n as getRegions,m as getStoreConfig,d as initialize,l as removeCustomerAddress,A as removeFetchGraphQlHeader,x as setEndpoint,F as setFetchGraphQlHeader,G as setFetchGraphQlHeaders,v as updateCustomer,H as updateCustomerAddress,E as updateCustomerEmail,j as updateCustomerPassword}; diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js index 8b0c990a19..f8254caed3 100644 --- a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as xe,TextArea as De,Card as he,Skeleton as we,SkeletonRow as D,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as _,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{m as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as _e}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var S,H;const{requiredFieldError:d,lengthTextError:o,numericError:i,alphaNumWithSpacesError:l,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:O}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((S=s==null?void 0:s.validateRules)!=null&&S.length))return x;const t=it(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,N=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+A,+f)&&!(N||T))return{[L]:o.replace("{min}",A).replace("{max}",f)};if(!At(e,+N,+T)&&(N||T))return{[L]:O.replace("{min}",Te(N)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((H=r[L])!=null&&H.length)?{[L]:z.error}:x},Be=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const i=o[1],l=parseInt(o[2],10);n[i]||(n[i]=[]),n[i].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((o,i)=>o.index-i.index),s[r]=d.map(o=>o.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Ve(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Mt(bt(n));if(!s)return r;const[d,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...o&&{regionId:+o}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).length?Object.keys(e).every(r=>r in s&&s[r]!==""):!1,ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:o})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Qe(null),[c,u]=_({}),[p,y]=_({}),[g,O]=_({}),[L,x]=_(!0),[t,A]=_(!1),[f,N]=_(!1),[T,Z]=_(!0),[z,S]=_(!1);ee(()=>{const h=()=>{if(l.current){const b=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,M=l.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const H=k((h=!1)=>{let v=!0;const b={...p};let M=null;for(const[I,m]of Object.entries(c)){const $=e==null?void 0:e.find(w=>w.customUpperCode.includes(I)),U=ye(m.toString(),$,i,b);U[I]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(w=>b[w])||null)}if(h||y(b),M&&l.current&&!h){const I=l.current.elements.namedItem(M);I==null||I.focus()}return v},[p,e,c,i]),C=k((h,v,b,M)=>{const I={...me(l),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(I,!0),isDataValid:Ze(b,I)};S(m.isDataValid),H(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},M)},[H,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=vt(e);u(b=>({...h,...b})),y(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const h=me(l),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:M},{},null),S(M),N(!0)}},[c,g]),ee(()=>{var I;if(!T)return;const h=me(l),v=!!(h!=null&&h.countryCode),b=!!((I=h==null?void 0:h.region)!=null&&I.length);h&&v&&!b&&ze(n)&&!o&&C(h==null?void 0:h.region,"region",g,null)},[T,L,e,l,n,C,g,t,o]);const B=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M;u(R=>{const te={...R,[b]:$};return b==="countryCode"&&(te.region="",x(!0),A(!1)),te}),r==null||r({[b]:$}),N(!0);const U=e==null?void 0:e.find(R=>R.customUpperCode.includes(b));let w=v?{...v}:{...p};if(U){const R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}C($,b,g,h)},[r,e,p,i,C,g,L]),q=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M,U=e==null?void 0:e.find(w=>w.customUpperCode===b);if(U){const w=v?{...v}:{...p},R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}},[p,e,i]),K=k(h=>{h.preventDefault();const v=H();s==null||s(h,v)},[H,s]);return{isDataValid:z,formData:c,errors:p,formRef:l,handleInputChange:B,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:H}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const Nt=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:o,onBlur:i,onFocus:l,slots:c})=>{const u=`${d}__field`,p=(t,A)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:i,handleOnFocus:l,errorMessage:A,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,A,f)=>{var T;const N=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??A??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:l,handleSelect:o,defaultValue:N,value:N})},t.id)})},g=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:l,onChange:o})},t.id)}),O=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:A||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:A||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)}),x=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,A):g(t,f,A);case se.MULTILINE:return g(t,f,A);case se.SELECT:return y(t,f,A);case se.DATE:return O(t,f,A);case se.BOOLEAN:return L(t,f,A);case se.TEXTAREA:return x(t,f,A);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(we,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},_t=()=>j(we,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:o,children:i,className:l="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:A,formData:f,errors:N,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:S,handleValidationSubmit:H,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const B=me(T);return{handleValidationSubmit:H,formData:ae(B,!0),isDataValid:A}}),n||!(c!=null&&c.length)?a(_t,{}):j("form",{className:X(["account-form",l]),onSubmit:S,name:d,ref:T,children:[a(Nt,{className:l,loading:o,fields:c,onChange:Z,onBlur:z,errors:N,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:B=>{Z(B),L==null||L(B)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:i,addressData:l,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=o?"minifiedView":"fullSizeView",O=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),x=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=Ne(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),N=Ne(()=>{u==null||u(l==null?void 0:l.id),y==null||y()},[y,l==null?void 0:l.id,u]),T=be(()=>{if(!i)return[];const{region:C,...B}=l,q={...B,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,i]),{shippingLabel:Z,billingLabel:z,hideShipping:S,hideBilling:H}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:O.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:N,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,B)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${B}`,children:q},B)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:x}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!S&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!H&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>G.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",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.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"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),Ot=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return j(l,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},It=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:o,closeModal:i})=>{const l=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${l}.Addresses.removeAddressModal.title`,description:`Account.${l}.Addresses.removeAddressModal.description`,actionCancel:`Account.${l}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${l}.Addresses.removeAddressModal.actionConfirm`});return r?j(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:o,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",o=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Ot,text:a("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!i.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],r1=["email","firstname","lastname","middlename","gender","date_of_birth","prefix","suffix","fax"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:i})=>{const[l,c]=_(""),[u,p]=_(!1),[y,g]=_(!1),[O,L]=_(!1),[x,t]=_(!1),[A,f]=_(!1),[N,T]=_(""),[Z,z]=_([]),[S,H]=_([]),C=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(m=>{const[$,U]=m;if($){const w=$.map(({name:R,orderNumber:te,label:re})=>({name:rt(R),orderNumber:te,label:St.includes(R)?null:re}));H(w)}if(U)if(d){const w=U.filter(R=>!!R.defaultShipping||!!R.defaultBilling);z(w)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var m;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(w=>+w.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((m=$==null?void 0:$.id)==null?void 0:m.toString())),r==null||r(U)}},[Z,n,r,s,e]);const B=k(m=>{T(m),f(!1)},[]),q=k((m,$)=>{const U=(m==null?void 0:m.target).value,w=(m==null?void 0:m.target).nextSibling;c(U);const R={data:ae($),isDataValid:!ve(ae($))};r==null||r(R),f(U==="0"),w&&(w.focus(),window.scrollBy(0,100))},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),h=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(N,Z),st(+N).then(()=>{C(),K()}).finally(()=>{t(!1)})},[Z,N,K,C]),b=k(()=>{f(!1)},[]),M=k(()=>{ze(o)&&d&&!A?window.location.href=o():(f(!0),T(""))},[A,o,d]),I=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:S,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:O,addNewAddress:A,addressesList:Z,addressId:N,handleRenderForm:P,handleRenderModal:h,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:B,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:I,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:o="",showFormLoader:i=!1,onAddressData:l,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:O=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:N,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:S=!0,routeAddressesPage:H,onSuccess:C,onError:B})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:I,addressesList:m,addressId:$,handleRenderForm:U,handleRenderModal:w,removeAddress:R,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:o,minifiedView:t,routeAddressesPage:H,onSuccess:C,onAddressData:l,selectShipping:g,selectBilling:O}),V=s??(g&&O?"selectedAddress":g?"selectedShippingAddress":O?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(m,g,O))==null?void 0:J.map((E,Y)=>j(_e,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:V,id:`${V}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${V}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:O,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:V,id:`${V}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${V}_addressActions`,className:"account-addresses-wrapper__label",children:I?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",I]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:V,showFormLoader:i,isOpen:I,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l})}):m!=null&&m.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:I,routeAddressesPage:ie}):null})]}):j(Q,{children:[m.map(E=>a(_e,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:te,onSuccess:re,onError:B})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&A||!t&&f?w:void 0,handleRenderForm:t&&A||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:I?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:I,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:oe,onSuccess:re,onError:B})}):a(Fe,{minifiedView:t,addNewAddress:I,routeAddressesPage:ie})})]});return j("div",{children:[a("div",{children:x?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(It,{minifiedView:t,addressData:m==null?void 0:m.find(E=>E.id===$),keysSortOrder:K,submitLoading:h,open:v,closeModal:te,onRemoveAddress:R}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:V,isOpen:!(m!=null&&m.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l}):a(xt,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const o=r[n.customUpperCode];n.customUpperCode==="region"&&typeof o=="object"?d.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:d.defaultValue=o}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:o,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(o=>{n.includes(o)?r[o]=e[o]:d.push({attribute_code:Ve(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Ie=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=Be(x)),s.includes(L)&&r.push(x)}const{street:o,streetMultiline_2:i,streetMultiline_1:l,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const o=s.find(i=>(i==null?void 0:i.id)===d.regionId);o?n[r]={...d,text:o.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((o,i)=>{n[`${r}Multiline_${i+2}`]=o})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:i,showBillingCheckBox:l,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[O,L]=_({text:"",type:"success"}),[x,t]=_(e??!1),[A,f]=_(r||""),[N,T]=_([]),[Z,z]=_([]),[S,H]=_([]),[C,B]=_([]),[q,P]=_([]),[K,h]=_(!1),[v,b]=_(!1),[M,I]=_(()=>{var V,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(V=JSON.parse(F))==null?void 0:V.data)==null?void 0:W.countryCode}:c}),[m,$]=_(!1),[U,w]=_(!1),[R,te]=_(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[A]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:V,optionalZipCountries:W})=>{z(F),B(V),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),w(!0);const F=M==null?void 0:M.countryCode;at(F).then(V=>{H(V);const W=C.find(E=>E===F),J=q.find(E=>E===F);h(!!W),b(!J),$(!1),w(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,V)=>{if(!V)return null;t(!0);const W=Oe(F.target),J=Ie(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,V)=>{if(!V)return;t(!0);const{saveAddressBook:W,...J}=Oe(F.target),E=Ie(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=et(()=>{if(!N.length)return[];const F={...Vt,defaultValue:o,isHidden:s&&!R?!0:!i},V={...Ht,defaultValue:d,isHidden:s&&!R?!0:!l},W=[...N,F,V],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,S):{},Y=Bt(qt(E,c),W);return zt({fields:Y,addressId:A,countryOptions:Z,disableField:m,regionOptions:S,isRequiredRegion:K,isRequiredPostCode:v})},[N,o,s,R,i,d,l,g,S,c,A,Z,m,K,v]),ue=k(F=>{I(V=>({...V,...F}))},[]);return{isWaitingForResponse:U,regionOptions:S,saveCheckBoxAddress:R,inLineAlert:O,addressId:A,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},jt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(s[o.code]=o.value)});const{customAttributes:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:S,addressId:H,submitLoading:C,normalizeFieldsConfig:B,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:N,onCloseBtnClick:A,formName:s});return x?j("div",{className:X(["account-address-form-wrapper",c]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,S.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:S.type,variant:"secondary",heading:S.text,icon:S.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:o,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:B,onSubmit:t||(H?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[H?a("input",{type:"hidden",name:"addressId",value:H,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:H}}):a(Q,{children:r?null:j(Q,{children:[a(de,{type:"button",onClick:K,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,xt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Oe as g,Ut as n}; +import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as xe,TextArea as De,Card as he,Skeleton as we,SkeletonRow as D,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as _,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{k as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as _e}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var S,H;const{requiredFieldError:d,lengthTextError:o,numericError:i,alphaNumWithSpacesError:l,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:O}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((S=s==null?void 0:s.validateRules)!=null&&S.length))return x;const t=it(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,N=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+A,+f)&&!(N||T))return{[L]:o.replace("{min}",A).replace("{max}",f)};if(!At(e,+N,+T)&&(N||T))return{[L]:O.replace("{min}",Te(N)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((H=r[L])!=null&&H.length)?{[L]:z.error}:x},Be=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const i=o[1],l=parseInt(o[2],10);n[i]||(n[i]=[]),n[i].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((o,i)=>o.index-i.index),s[r]=d.map(o=>o.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Ve(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Mt(bt(n));if(!s)return r;const[d,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...o&&{regionId:+o}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).length?Object.keys(e).every(r=>r in s&&s[r]!==""):!1,ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:o})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Qe(null),[c,u]=_({}),[p,y]=_({}),[g,O]=_({}),[L,x]=_(!0),[t,A]=_(!1),[f,N]=_(!1),[T,Z]=_(!0),[z,S]=_(!1);ee(()=>{const h=()=>{if(l.current){const b=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,M=l.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const H=k((h=!1)=>{let v=!0;const b={...p};let M=null;for(const[I,m]of Object.entries(c)){const $=e==null?void 0:e.find(w=>w.customUpperCode.includes(I)),U=ye(m.toString(),$,i,b);U[I]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(w=>b[w])||null)}if(h||y(b),M&&l.current&&!h){const I=l.current.elements.namedItem(M);I==null||I.focus()}return v},[p,e,c,i]),C=k((h,v,b,M)=>{const I={...me(l),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(I,!0),isDataValid:Ze(b,I)};S(m.isDataValid),H(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},M)},[H,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=vt(e);u(b=>({...h,...b})),y(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const h=me(l),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:M},{},null),S(M),N(!0)}},[c,g]),ee(()=>{var I;if(!T)return;const h=me(l),v=!!(h!=null&&h.countryCode),b=!!((I=h==null?void 0:h.region)!=null&&I.length);h&&v&&!b&&ze(n)&&!o&&C(h==null?void 0:h.region,"region",g,null)},[T,L,e,l,n,C,g,t,o]);const B=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M;u(R=>{const te={...R,[b]:$};return b==="countryCode"&&(te.region="",x(!0),A(!1)),te}),r==null||r({[b]:$}),N(!0);const U=e==null?void 0:e.find(R=>R.customUpperCode.includes(b));let w=v?{...v}:{...p};if(U){const R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}C($,b,g,h)},[r,e,p,i,C,g,L]),q=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((h,v)=>{const{name:b,value:M,type:I,checked:m}=h==null?void 0:h.target,$=I==="checkbox"?m:M,U=e==null?void 0:e.find(w=>w.customUpperCode===b);if(U){const w=v?{...v}:{...p},R=ye($.toString(),U,i,w);R&&Object.assign(w,R),y(w)}},[p,e,i]),K=k(h=>{h.preventDefault();const v=H();s==null||s(h,v)},[H,s]);return{isDataValid:z,formData:c,errors:p,formRef:l,handleInputChange:B,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:H}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const Nt=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:o,onBlur:i,onFocus:l,slots:c})=>{const u=`${d}__field`,p=(t,A)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:i,handleOnFocus:l,errorMessage:A,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,A,f)=>{var T;const N=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??A??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:l,handleSelect:o,defaultValue:N,value:N})},t.id)})},g=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:l,onChange:o})},t.id)}),O=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:A||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:A||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)}),x=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,A):g(t,f,A);case se.MULTILINE:return g(t,f,A);case se.SELECT:return y(t,f,A);case se.DATE:return O(t,f,A);case se.BOOLEAN:return L(t,f,A);case se.TEXTAREA:return x(t,f,A);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(we,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},_t=()=>j(we,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:o,children:i,className:l="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:A,formData:f,errors:N,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:S,handleValidationSubmit:H,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const B=me(T);return{handleValidationSubmit:H,formData:ae(B,!0),isDataValid:A}}),n||!(c!=null&&c.length)?a(_t,{}):j("form",{className:X(["account-form",l]),onSubmit:S,name:d,ref:T,children:[a(Nt,{className:l,loading:o,fields:c,onChange:Z,onBlur:z,errors:N,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:B=>{Z(B),L==null||L(B)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:i,addressData:l,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=o?"minifiedView":"fullSizeView",O=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),x=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=Ne(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),N=Ne(()=>{u==null||u(l==null?void 0:l.id),y==null||y()},[y,l==null?void 0:l.id,u]),T=be(()=>{if(!i)return[];const{region:C,...B}=l,q={...B,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,i]),{shippingLabel:Z,billingLabel:z,hideShipping:S,hideBilling:H}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:O.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:N,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,B)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${B}`,children:q},B)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:x}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!S&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!H&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>G.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",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.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"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),Ot=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return j(l,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},It=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:o,closeModal:i})=>{const l=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${l}.Addresses.removeAddressModal.title`,description:`Account.${l}.Addresses.removeAddressModal.description`,actionCancel:`Account.${l}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${l}.Addresses.removeAddressModal.actionConfirm`});return r?j(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:o,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",o=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Ot,text:a("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!i.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],r1=["email","firstname","lastname","middlename","gender","date_of_birth","prefix","suffix","fax"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:i})=>{const[l,c]=_(""),[u,p]=_(!1),[y,g]=_(!1),[O,L]=_(!1),[x,t]=_(!1),[A,f]=_(!1),[N,T]=_(""),[Z,z]=_([]),[S,H]=_([]),C=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(m=>{const[$,U]=m;if($){const w=$.map(({name:R,orderNumber:te,label:re})=>({name:rt(R),orderNumber:te,label:St.includes(R)?null:re}));H(w)}if(U)if(d){const w=U.filter(R=>!!R.defaultShipping||!!R.defaultBilling);z(w)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var m;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(w=>+w.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((m=$==null?void 0:$.id)==null?void 0:m.toString())),r==null||r(U)}},[Z,n,r,s,e]);const B=k(m=>{T(m),f(!1)},[]),q=k((m,$)=>{const U=(m==null?void 0:m.target).value,w=(m==null?void 0:m.target).nextSibling;c(U);const R={data:ae($),isDataValid:!ve(ae($))};r==null||r(R),f(U==="0"),w&&(w.focus(),window.scrollBy(0,100))},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),h=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(N,Z),st(+N).then(()=>{C(),K()}).finally(()=>{t(!1)})},[Z,N,K,C]),b=k(()=>{f(!1)},[]),M=k(()=>{ze(o)&&d&&!A?window.location.href=o():(f(!0),T(""))},[A,o,d]),I=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:S,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:O,addNewAddress:A,addressesList:Z,addressId:N,handleRenderForm:P,handleRenderModal:h,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:B,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:I,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:o="",showFormLoader:i=!1,onAddressData:l,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:O=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:N,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:S=!0,routeAddressesPage:H,onSuccess:C,onError:B})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:I,addressesList:m,addressId:$,handleRenderForm:U,handleRenderModal:w,removeAddress:R,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:o,minifiedView:t,routeAddressesPage:H,onSuccess:C,onAddressData:l,selectShipping:g,selectBilling:O}),V=s??(g&&O?"selectedAddress":g?"selectedShippingAddress":O?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(m,g,O))==null?void 0:J.map((E,Y)=>j(_e,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:V,id:`${V}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${V}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:O,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:V,id:`${V}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${V}_addressActions`,className:"account-addresses-wrapper__label",children:I?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",I]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:V,showFormLoader:i,isOpen:I,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l})}):m!=null&&m.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:I,routeAddressesPage:ie}):null})]}):j(Q,{children:[m.map(E=>a(_e,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:te,onSuccess:re,onError:B})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&A||!t&&f?w:void 0,handleRenderForm:t&&A||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:I?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:I,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:z,billingCheckBoxValue:S,onCloseBtnClick:oe,onSuccess:re,onError:B})}):a(Fe,{minifiedView:t,addNewAddress:I,routeAddressesPage:ie})})]});return j("div",{children:[a("div",{children:x?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(It,{minifiedView:t,addressData:m==null?void 0:m.find(E=>E.id===$),keysSortOrder:K,submitLoading:h,open:v,closeModal:te,onRemoveAddress:R}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:V,isOpen:!(m!=null&&m.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:S,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:B,onChange:l}):a(xt,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const o=r[n.customUpperCode];n.customUpperCode==="region"&&typeof o=="object"?d.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:d.defaultValue=o}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:o,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(o=>{n.includes(o)?r[o]=e[o]:d.push({attribute_code:Ve(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Ie=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=Be(x)),s.includes(L)&&r.push(x)}const{street:o,streetMultiline_2:i,streetMultiline_1:l,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const o=s.find(i=>(i==null?void 0:i.id)===d.regionId);o?n[r]={...d,text:o.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((o,i)=>{n[`${r}Multiline_${i+2}`]=o})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:i,showBillingCheckBox:l,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[O,L]=_({text:"",type:"success"}),[x,t]=_(e??!1),[A,f]=_(r||""),[N,T]=_([]),[Z,z]=_([]),[S,H]=_([]),[C,B]=_([]),[q,P]=_([]),[K,h]=_(!1),[v,b]=_(!1),[M,I]=_(()=>{var V,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(V=JSON.parse(F))==null?void 0:V.data)==null?void 0:W.countryCode}:c}),[m,$]=_(!1),[U,w]=_(!1),[R,te]=_(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[A]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:V,optionalZipCountries:W})=>{z(F),B(V),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),w(!0);const F=M==null?void 0:M.countryCode;at(F).then(V=>{H(V);const W=C.find(E=>E===F),J=q.find(E=>E===F);h(!!W),b(!J),$(!1),w(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,V)=>{if(!V)return null;t(!0);const W=Oe(F.target),J=Ie(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,V)=>{if(!V)return;t(!0);const{saveAddressBook:W,...J}=Oe(F.target),E=Ie(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=et(()=>{if(!N.length)return[];const F={...Vt,defaultValue:o,isHidden:s&&!R?!0:!i},V={...Ht,defaultValue:d,isHidden:s&&!R?!0:!l},W=[...N,F,V],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,S):{},Y=Bt(qt(E,c),W);return zt({fields:Y,addressId:A,countryOptions:Z,disableField:m,regionOptions:S,isRequiredRegion:K,isRequiredPostCode:v})},[N,o,s,R,i,d,l,g,S,c,A,Z,m,K,v]),ue=k(F=>{I(V=>({...V,...F}))},[]);return{isWaitingForResponse:U,regionOptions:S,saveCheckBoxAddress:R,inLineAlert:O,addressId:A,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},jt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(s[o.code]=o.value)});const{customAttributes:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:S,addressId:H,submitLoading:C,normalizeFieldsConfig:B,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:N,onCloseBtnClick:A,formName:s});return x?j("div",{className:X(["account-address-form-wrapper",c]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,S.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:S.type,variant:"secondary",heading:S.text,icon:S.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:o,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:B,onSubmit:t||(H?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[H?a("input",{type:"hidden",name:"addressId",value:H,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:H}}):a(Q,{children:r?null:j(Q,{children:[a(de,{type:"button",onClick:K,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,xt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Oe as g,Ut as n}; diff --git a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js index 12b10de16d..bb5909ad2a 100644 --- a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js +++ b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js @@ -1,59 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{t as T,m as s,f as A,l as M}from"./removeCustomerAddress.js";import{c as C}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as v}from"@dropins/tools/lib.js";const I=(t,r="en-US",a={})=>{const e={...{day:"2-digit",month:"2-digit",year:"numeric"},...a},d=new Date(t);return isNaN(d.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,e).format(d)},N=t=>{var m,u,l,_,f,g,p,R,E,S,n,y;if(!((u=(m=t.data)==null?void 0:m.customer)!=null&&u.orders))return null;const{page_info:r,total_count:a,date_of_first_order:i}=t.data.customer.orders,e=((_=(l=t==null?void 0:t.data)==null?void 0:l.customer)==null?void 0:_.returns)??[],c={items:(((p=(g=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:g.orders)==null?void 0:p.items)??[]).map(o=>{var O;const D={...o,returns:(O=e==null?void 0:e.items)==null?void 0:O.filter(h=>h.order.id===o.id),order_date:I(o.order_date),shipping_address:T(o.shipping_address),billing_address:T(o.billing_address)};return s(D,"camelCase",{})}),pageInfo:s(r,"camelCase",{}),totalCount:s(a,"camelCase",{}),dateOfFirstOrder:s(i,"camelCase",{})};return v(c,(y=(n=(S=(E=(R=C)==null?void 0:R.getConfig())==null?void 0:E.models)==null?void 0:S.OrderHistoryModel)==null?void 0:n.transformer)==null?void 0:y.call(n,t.data))},b=` - fragment ADDRESS_FRAGMENT on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id - } -`,G=` - fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { - __typename - grand_total { - value - currency - } - subtotal { - currency - value - } - taxes { - amount { - currency - value - } - rate - title - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { - currency - value - } - label - } - } -`,F=` +import{t as h,k as d,f as A,l as C}from"./removeCustomerAddress.js";import{c as I}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as M}from"@dropins/tools/lib.js";import{ADDRESS_FRAGMENT as N,ORDER_SUMMARY_FRAGMENT as $}from"../fragments.js";const b=(t,e="en-US",a={})=>{const r={...{day:"2-digit",month:"2-digit",year:"numeric"},...a},n=new Date(t);return isNaN(n.getTime())?"Invalid Date":new Intl.DateTimeFormat(e,r).format(n)},G=t=>{var c,_,l,u,f,g,p,R,S,E,s,O;if(!((_=(c=t.data)==null?void 0:c.customer)!=null&&_.orders))return null;const{page_info:e,total_count:a,date_of_first_order:i}=t.data.customer.orders,r=((u=(l=t==null?void 0:t.data)==null?void 0:l.customer)==null?void 0:u.returns)??[],m={items:(((p=(g=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:g.orders)==null?void 0:p.items)??[]).map(o=>{var T;const D={...o,returns:(T=r==null?void 0:r.items)==null?void 0:T.filter(y=>y.order.id===o.id),order_date:b(o.order_date),shipping_address:h(o.shipping_address),billing_address:h(o.billing_address)};return d(D,"camelCase",{})}),pageInfo:d(e,"camelCase",{}),totalCount:d(a,"camelCase",{}),dateOfFirstOrder:d(i,"camelCase",{})};return M(m,(O=(s=(E=(S=(R=I)==null?void 0:R.getConfig())==null?void 0:S.models)==null?void 0:E.OrderHistoryModel)==null?void 0:s.transformer)==null?void 0:O.call(s,t.data))},F=` query GET_CUSTOMER_ORDERS_LIST( $currentPage: Int $pageSize: Int @@ -133,6 +80,6 @@ import{t as T,m as s,f as A,l as M}from"./removeCustomerAddress.js";import{c as } } } - ${b} - ${G} -`,$={sort_direction:"DESC",sort_field:"CREATED_AT"},L=async(t,r,a)=>{const i=r.includes("viewAll")?{}:{order_date:JSON.parse(r)};return await A(F,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:a,filter:i,sort:$}}).then(e=>N(e)).catch(M)};export{L as g}; + ${N} + ${$} +`,k={sort_direction:"DESC",sort_field:"CREATED_AT"},z=async(t,e,a)=>{const i=e.includes("viewAll")?{}:{order_date:JSON.parse(e)};return await A(F,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:a,filter:i,sort:k}}).then(r=>G(r)).catch(C)};export{z as g}; diff --git a/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js index f4d640d7a5..de40cc9465 100644 --- a/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{Initializer as f}from"@dropins/tools/lib.js";import{f as h,k as _,l as g}from"./removeCustomerAddress.js";const c=new f({init:async t=>{const r={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};c.config.setConfig({...r,...t})},listeners:()=>[]}),C=c.config,l=t=>{var r,a,i,e,o,n;return{baseMediaUrl:(a=(r=t==null?void 0:t.data)==null?void 0:r.storeConfig)==null?void 0:a.base_media_url,minLength:+((e=(i=t==null?void 0:t.data)==null?void 0:i.storeConfig)==null?void 0:e.minimum_password_length)||3,requiredCharacterClasses:+((n=(o=t==null?void 0:t.data)==null?void 0:o.storeConfig)==null?void 0:n.required_character_classes_number)||0}},m=` +import{Initializer as f}from"@dropins/tools/lib.js";import{f as h,m as _,l as m}from"./removeCustomerAddress.js";const c=new f({init:async t=>{const r={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};c.config.setConfig({...r,...t})},listeners:()=>[]}),C=c.config,g=t=>{var r,a,i,e,o,n;return{baseMediaUrl:(a=(r=t==null?void 0:t.data)==null?void 0:r.storeConfig)==null?void 0:a.base_media_url,minLength:+((e=(i=t==null?void 0:t.data)==null?void 0:i.storeConfig)==null?void 0:e.minimum_password_length)||3,requiredCharacterClasses:+((n=(o=t==null?void 0:t.data)==null?void 0:o.storeConfig)==null?void 0:n.required_character_classes_number)||0}},l=` query GET_STORE_CONFIG { storeConfig { base_media_url @@ -9,4 +9,4 @@ import{Initializer as f}from"@dropins/tools/lib.js";import{f as h,k as _,l as g} required_character_classes_number } } -`,s=async()=>await h(m,{method:"GET",cache:"force-cache"}).then(t=>{var r;return(r=t.errors)!=null&&r.length?_(t.errors):l(t)}).catch(g);export{C as c,s as g,c as i}; +`,s=async()=>await h(l,{method:"GET",cache:"force-cache"}).then(t=>{var r;return(r=t.errors)!=null&&r.length?_(t.errors):g(t)}).catch(m);export{C as c,s as g,c as i}; diff --git a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js index ddfc72ff9a..acb1d2cdb3 100644 --- a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js +++ b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js @@ -118,4 +118,4 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) { deleteCustomerAddress(id: $id) } -`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,f as k,_ as l,g as m,S as n,p as o,J as r,k as s,$ as t,Y as u}; +`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,g as k,_ as l,f as m,S as n,p as o,J as r,k as s,$ as t,Y as u}; diff --git a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js index 5452afb2cd..d8a07a8c88 100644 --- a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js +++ b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js @@ -1,18 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";import{c as y}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as V}from"@dropins/tools/lib.js";const B=t=>{var r,u,i,d,f,o,e,E,h,S,T,g,w,O,A,P,M,R,U,N,n,b,$,G,c,I;const m=(i=(u=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:u.custom_attributes)==null?void 0:i.reduce((v,x)=>(v[D(x.code)]=x.value??"",v),{}),a={email:((f=(d=t==null?void 0:t.data)==null?void 0:d.customer)==null?void 0:f.email)||"",firstName:((e=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:e.firstname)||"",lastName:((h=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:h.lastname)||"",middleName:((T=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:T.middlename)||"",gender:((w=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:w.gender)||"1",dateOfBirth:((A=(O=t==null?void 0:t.data)==null?void 0:O.customer)==null?void 0:A.date_of_birth)||"",prefix:((M=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:M.prefix)||"",suffix:((U=(R=t==null?void 0:t.data)==null?void 0:R.customer)==null?void 0:U.suffix)||"",createdAt:((n=(N=t==null?void 0:t.data)==null?void 0:N.customer)==null?void 0:n.created_at)||"",...m};return V(a,(I=(c=(G=($=(b=y)==null?void 0:b.getConfig())==null?void 0:$.models)==null?void 0:G.CustomerDataModelShort)==null?void 0:c.transformer)==null?void 0:I.call(c,t.data))},k=` - fragment BASIC_CUSTOMER_INFO_FRAGMENT on Customer { - date_of_birth - email - firstname - gender - lastname - middlename - prefix - suffix - created_at - } -`,L=` +import{n as y,f as l,m as C,l as o,k as x}from"./removeCustomerAddress.js";import{BASIC_CUSTOMER_INFO_FRAGMENT as F}from"../fragments.js";import{c as V}from"./getStoreConfig.js";import"@dropins/tools/event-bus.js";import{merge as k}from"@dropins/tools/lib.js";const B=t=>{var r,u,i,d,h,E,_,f,S,T,w,g,O,P,e,A,M,U,R,N,b,$,G,v,c,D;const m=(i=(u=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:u.custom_attributes)==null?void 0:i.reduce((I,n)=>(I[y(n.code)]=n.value??"",I),{}),a={email:((h=(d=t==null?void 0:t.data)==null?void 0:d.customer)==null?void 0:h.email)||"",firstName:((_=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:_.firstname)||"",lastName:((S=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:S.lastname)||"",middleName:((w=(T=t==null?void 0:t.data)==null?void 0:T.customer)==null?void 0:w.middlename)||"",gender:((O=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:O.gender)||"1",dateOfBirth:((e=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:e.date_of_birth)||"",prefix:((M=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:M.prefix)||"",suffix:((R=(U=t==null?void 0:t.data)==null?void 0:U.customer)==null?void 0:R.suffix)||"",createdAt:((b=(N=t==null?void 0:t.data)==null?void 0:N.customer)==null?void 0:b.created_at)||"",...m};return k(a,(D=(c=(v=(G=($=V)==null?void 0:$.getConfig())==null?void 0:G.models)==null?void 0:v.CustomerDataModelShort)==null?void 0:c.transformer)==null?void 0:D.call(c,t.data))},L=` query GET_CUSTOMER { customer { ...BASIC_CUSTOMER_INFO_FRAGMENT @@ -25,8 +13,8 @@ import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";impor } } } - ${k} -`,J=async()=>await l(L,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?C(t.errors):B(t)}).catch(_),H=` + ${F} +`,X=async()=>await l(L,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?C(t.errors):B(t)}).catch(o),H=` mutation CHANGE_CUSTOMER_PASSWORD( $currentPassword: String! $newPassword: String! @@ -38,7 +26,7 @@ import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";impor email } } -`,X=async({currentPassword:t,newPassword:m})=>await l(H,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var r,u,i;return(r=a.errors)!=null&&r.length?C(a.errors):((i=(u=a==null?void 0:a.data)==null?void 0:u.changeCustomerPassword)==null?void 0:i.email)||""}).catch(_),W=` +`,Y=async({currentPassword:t,newPassword:m})=>await l(H,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var r,u,i;return(r=a.errors)!=null&&r.length?C(a.errors):((i=(u=a==null?void 0:a.data)==null?void 0:u.changeCustomerPassword)==null?void 0:i.email)||""}).catch(o),W=` mutation UPDATE_CUSTOMER_EMAIL($email: String!, $password: String!) { updateCustomerEmail(email: $email, password: $password) { customer { @@ -46,7 +34,7 @@ import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";impor } } } -`,Y=async({email:t,password:m})=>await l(W,{method:"POST",variables:{email:t,password:m}}).then(a=>{var r,u,i,d;return(r=a.errors)!=null&&r.length?C(a.errors):((d=(i=(u=a==null?void 0:a.data)==null?void 0:u.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(_),q=` +`,Z=async({email:t,password:m})=>await l(W,{method:"POST",variables:{email:t,password:m}}).then(a=>{var r,u,i,d;return(r=a.errors)!=null&&r.length?C(a.errors):((d=(i=(u=a==null?void 0:a.data)==null?void 0:u.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(o),q=` mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) { updateCustomerV2(input: $input) { customer { @@ -54,4 +42,4 @@ import{n as D,f as l,k as C,l as _,m as F}from"./removeCustomerAddress.js";impor } } } -`,Z=async t=>await l(q,{method:"POST",variables:{input:F(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,r,u,i;return(a=m.errors)!=null&&a.length?C(m.errors):((i=(u=(r=m==null?void 0:m.data)==null?void 0:r.updateCustomerV2)==null?void 0:u.customer)==null?void 0:i.email)||""}).catch(_);export{Y as a,Z as b,J as g,X as u}; +`,s=async t=>await l(q,{method:"POST",variables:{input:x(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,r,u,i;return(a=m.errors)!=null&&a.length?C(m.errors):((i=(u=(r=m==null?void 0:m.data)==null?void 0:r.updateCustomerV2)==null?void 0:u.customer)==null?void 0:i.email)||""}).catch(o);export{Z as a,s as b,X as g,Y as u}; diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js index f1c2c438af..db9bbfacd8 100644 --- a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ce}from"../chunks/getStoreConfig.js";import{u as Pe,g as pe,b as ee,a as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Je=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Je as CustomerInformation,Je as default}; +import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ce}from"../chunks/getStoreConfig.js";import{u as Pe,g as pe,b as ee,a as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Ge=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Ge as CustomerInformation,Ge as default}; diff --git a/scripts/__dropins__/storefront-account/containers/OrdersList.js b/scripts/__dropins__/storefront-account/containers/OrdersList.js index 4b594a5824..f60dfd8242 100644 --- a/scripts/__dropins__/storefront-account/containers/OrdersList.js +++ b/scripts/__dropins__/storefront-account/containers/OrdersList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as s,jsxs as u,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as j}from"@dropins/tools/lib.js";import{S as B,c as m,E as U,C as Q}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,ContentGrid as R,Image as J,Header as X,Picker as Z,Pagination as rr}from"@dropins/tools/components.js";import{useText as z}from"@dropins/tools/i18n.js";import{useState as S,useEffect as P,useMemo as tr,useCallback as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as sr}from"../chunks/getOrderHistoryList.js";import{g as er}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const V={size:"32",stroke:"2"},W=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:L})=>{const n=a?"minifiedView":"fullSizeView",h=z({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:h.viewAllOrdersButton}),s(F,{source:B,...V})]})})}):s("a",{"aria-label":`${h.ariaLabelLink} ${c??r}`,href:m(L)?L(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(F,{source:B,...V})})},ar=()=>{const[a,c]=S(window.innerWidth<768);return P(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},cr=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:L,slots:n,routeTracking:h,routeOrderProduct:O,routeReturnDetails:A,...b})=>{var p,$,_,k,w,I,x,f,M;const o=c?"minifiedView":"fullSizeView",g=z({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=ar(),y=m(O);return u(G,{variant:"secondary",...b,className:C(["account-orders-list-card",["account-orders-list-card--full",((p=r==null?void 0:r.items)==null?void 0:p.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(j,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):u(N,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[g.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[g.orderNumber," ",r.number]}),($=r==null?void 0:r.shipments)==null?void 0:$.map(t=>{var l;return(l=t==null?void 0:t.tracking)==null?void 0:l.map(i=>{const v=h==null?void 0:h(i);return u("p",{"data-testid":i.number,children:[s("span",{children:`${g.carrier} ${i.carrier.toLocaleUpperCase()} `}),v?s("a",{href:v,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:i.number}):s("span",{className:"account-orders-list-card__content--track_number",children:i.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[g.returnsText," "]}),(k=r==null?void 0:r.returns)==null?void 0:k.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(A==null?void 0:A({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,u("p",{children:["$",(w=r==null?void 0:r.total)==null?void 0:w.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[(I=r==null?void 0:r.items)!=null&&I.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((t,l)=>{const i=(l==null?void 0:l.quantityOrdered)||0;return t+i},0):0," ",g.itemsAmount]}),(f=r==null?void 0:r.items)==null?void 0:f.map((t,l)=>{if(l>=0&&l<10)return u("p",{className:"account-orders-list-card__content--product-name",children:[u("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${l}_${t.id}`);if(l===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((M=r==null?void 0:r.items)!=null&&M.length)?s(R,{maxColumns:d?3:9,emptyGridContent:s(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,l)=>{var Y,D,E,H,q;const i=(E=(D=(Y=t==null?void 0:t.product)==null?void 0:Y.smallImage)==null?void 0:D.url)!=null&&E.length?(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url:a,v=(t==null?void 0:t.productName)??"";return y?s("a",{href:(O==null?void 0:O(t))??"",target:"_blank",rel:"noreferrer",children:s(J,{src:i,width:65,height:65,alt:v})},t.id+l):s(J,{src:i,width:65,height:65,alt:v},t.id+l)})}):null,s("div",{className:"account-orders-list-card__actions",children:L})]})},nr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:L,handleSetFirstOrderDate:n})=>{const[h,O]=S([]),[A,b]=S({totalPages:1,currentPage:1,pageSize:1}),[o,g]=S(!1),[d,y]=S("");return P(()=>{er().then(p=>{y(p.baseMediaUrl)})},[]),P(()=>{g(!0),sr(c?a:r,e,L).then(p=>{!p||!p.items||(b(p.pageInfo),O(p.items),n==null||n(p.dateOfFirstOrder))}).finally(()=>{g(!1)})},[n,c,a,r,e,L]),{loading:o,orderHistoryListItems:h,pageInfo:A,placeholderImage:d}},T=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},or=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},dr=()=>{const a=z({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=S(),[e,L]=S(JSON.stringify(T("sixMonthsAgo",6))),[n,h]=S(1);P(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const O=tr(()=>{const o=[{value:JSON.stringify(T("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(T("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...or(d))}return o},[a,c]),A=K(o=>{r(o)},[]),b=K(o=>{const d=o.target.value;L(d),h(1)},[]);return{selectableDateList:O,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:h,handleSetFirstOrderDate:A}},ir=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:L=!0,ordersInMinifiedView:n=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>{const y=r?"minifiedView":"fullSizeView",p=z({containerTitle:`Account.${y}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${y}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:I,handleSetFirstOrderDate:x}=dr(),{pageInfo:f,loading:M,orderHistoryListItems:t,placeholderImage:l}=nr({minifiedView:r,pageSize:h,ordersInMinifiedView:n,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:x});return u("div",{children:[c?s(X,{"aria-label":p.containerTitle,role:"region",title:p.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",a]),children:[!r&&L?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:p.dateOrderPlaced}),s(Z,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,M?s(N,{children:Array.from(Array(f==null?void 0:f.pageSize).keys()).map(i=>s(Q,{testId:"orderSkeletonLoader",withCard:!1},i))}):s(N,{children:t.length?s(N,{children:t.map((i,v)=>s(cr,{placeholderImage:l,routeTracking:o,routeOrderProduct:g,routeReturnDetails:b,minifiedView:r,item:i,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(j,{"data-testid":`ordersListActionSlot_${v}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:i}}):s(W,{minifiedView:r,orderNumber:i.number,orderToken:i.token,routeOrderDetails:A})},v))}):s(U,{isEmpty:!t.length,typeList:"orders",minifiedView:r})}),!r&&(f==null?void 0:f.totalPages)>1?s(rr,{totalPages:f==null?void 0:f.totalPages,currentPage:w,onChange:I}):null,r?s(W,{minifiedView:r,routeOrdersList:O}):null]})]})},_r=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>s("div",{className:C(["account-orders-list",a]),"data-testid":"ordersListId",children:s(ir,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})});export{_r as OrdersList,_r as default}; +import{jsx as s,jsxs as u,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as W}from"@dropins/tools/lib.js";import{S as B,c as j,E as U,C as Q}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,ContentGrid as R,Image as m,Header as X,Picker as Z,Pagination as rr}from"@dropins/tools/components.js";import{useText as z}from"@dropins/tools/i18n.js";import{useState as S,useEffect as P,useMemo as tr,useCallback as J}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as sr}from"../chunks/getOrderHistoryList.js";import{g as er}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";import"../fragments.js";const K={size:"32",stroke:"2"},V=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:L})=>{const n=a?"minifiedView":"fullSizeView",h=z({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:h.viewAllOrdersButton}),s(F,{source:B,...K})]})})}):s("a",{"aria-label":`${h.ariaLabelLink} ${c??r}`,href:j(L)?L(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(F,{source:B,...K})})},ar=()=>{const[a,c]=S(window.innerWidth<768);return P(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},cr=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:L,slots:n,routeTracking:h,routeOrderProduct:O,routeReturnDetails:A,...b})=>{var g,$,_,k,w,I,x,f,M;const o=c?"minifiedView":"fullSizeView",p=z({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=ar(),y=j(O);return u(G,{variant:"secondary",...b,className:C(["account-orders-list-card",["account-orders-list-card--full",((g=r==null?void 0:r.items)==null?void 0:g.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(W,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):u(N,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[p.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[p.orderNumber," ",r.number]}),($=r==null?void 0:r.shipments)==null?void 0:$.map(t=>{var l;return(l=t==null?void 0:t.tracking)==null?void 0:l.map(i=>{const v=h==null?void 0:h(i);return u("p",{"data-testid":i.number,children:[s("span",{children:`${p.carrier} ${i.carrier.toLocaleUpperCase()} `}),v?s("a",{href:v,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:i.number}):s("span",{className:"account-orders-list-card__content--track_number",children:i.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[p.returnsText," "]}),(k=r==null?void 0:r.returns)==null?void 0:k.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(A==null?void 0:A({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,u("p",{children:["$",(w=r==null?void 0:r.total)==null?void 0:w.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[(I=r==null?void 0:r.items)!=null&&I.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((t,l)=>{const i=(l==null?void 0:l.quantityOrdered)||0;return t+i},0):0," ",p.itemsAmount]}),(f=r==null?void 0:r.items)==null?void 0:f.map((t,l)=>{if(l>=0&&l<10)return u("p",{className:"account-orders-list-card__content--product-name",children:[u("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${l}_${t.id}`);if(l===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((M=r==null?void 0:r.items)!=null&&M.length)?s(R,{maxColumns:d?3:9,emptyGridContent:s(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,l)=>{var Y,D,E,H,q;const i=(E=(D=(Y=t==null?void 0:t.product)==null?void 0:Y.smallImage)==null?void 0:D.url)!=null&&E.length?(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url:a,v=(t==null?void 0:t.productName)??"";return y?s("a",{href:(O==null?void 0:O(t))??"",target:"_blank",rel:"noreferrer",children:s(m,{src:i,width:65,height:65,alt:v})},t.id+l):s(m,{src:i,width:65,height:65,alt:v},t.id+l)})}):null,s("div",{className:"account-orders-list-card__actions",children:L})]})},nr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:L,handleSetFirstOrderDate:n})=>{const[h,O]=S([]),[A,b]=S({totalPages:1,currentPage:1,pageSize:1}),[o,p]=S(!1),[d,y]=S("");return P(()=>{er().then(g=>{y(g.baseMediaUrl)})},[]),P(()=>{p(!0),sr(c?a:r,e,L).then(g=>{!g||!g.items||(b(g.pageInfo),O(g.items),n==null||n(g.dateOfFirstOrder))}).finally(()=>{p(!1)})},[n,c,a,r,e,L]),{loading:o,orderHistoryListItems:h,pageInfo:A,placeholderImage:d}},T=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},or=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},dr=()=>{const a=z({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=S(),[e,L]=S(JSON.stringify(T("sixMonthsAgo",6))),[n,h]=S(1);P(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const O=tr(()=>{const o=[{value:JSON.stringify(T("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(T("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...or(d))}return o},[a,c]),A=J(o=>{r(o)},[]),b=J(o=>{const d=o.target.value;L(d),h(1)},[]);return{selectableDateList:O,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:h,handleSetFirstOrderDate:A}},ir=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:L=!0,ordersInMinifiedView:n=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:p,slots:d})=>{const y=r?"minifiedView":"fullSizeView",g=z({containerTitle:`Account.${y}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${y}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:I,handleSetFirstOrderDate:x}=dr(),{pageInfo:f,loading:M,orderHistoryListItems:t,placeholderImage:l}=nr({minifiedView:r,pageSize:h,ordersInMinifiedView:n,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:x});return u("div",{children:[c?s(X,{"aria-label":g.containerTitle,role:"region",title:g.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",a]),children:[!r&&L?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:g.dateOrderPlaced}),s(Z,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,M?s(N,{children:Array.from(Array(f==null?void 0:f.pageSize).keys()).map(i=>s(Q,{testId:"orderSkeletonLoader",withCard:!1},i))}):s(N,{children:t.length?s(N,{children:t.map((i,v)=>s(cr,{placeholderImage:l,routeTracking:o,routeOrderProduct:p,routeReturnDetails:b,minifiedView:r,item:i,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(W,{"data-testid":`ordersListActionSlot_${v}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:i}}):s(V,{minifiedView:r,orderNumber:i.number,orderToken:i.token,routeOrderDetails:A})},v))}):s(U,{isEmpty:!t.length,typeList:"orders",minifiedView:r})}),!r&&(f==null?void 0:f.totalPages)>1?s(rr,{totalPages:f==null?void 0:f.totalPages,currentPage:w,onChange:I}):null,r?s(V,{minifiedView:r,routeOrdersList:O}):null]})]})},wr=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:p,slots:d})=>s("div",{className:C(["account-orders-list",a]),"data-testid":"ordersListId",children:s(ir,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:p,slots:d})});export{wr as OrdersList,wr as default}; diff --git a/scripts/__dropins__/storefront-account/fragments.d.ts b/scripts/__dropins__/storefront-account/fragments.d.ts new file mode 100644 index 0000000000..4d0b3af3f9 --- /dev/null +++ b/scripts/__dropins__/storefront-account/fragments.d.ts @@ -0,0 +1 @@ +export * from './api/fragments' diff --git a/scripts/__dropins__/storefront-account/fragments.js b/scripts/__dropins__/storefront-account/fragments.js new file mode 100644 index 0000000000..d5bb645651 --- /dev/null +++ b/scripts/__dropins__/storefront-account/fragments.js @@ -0,0 +1,68 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const e=` + fragment BASIC_CUSTOMER_INFO_FRAGMENT on Customer { + date_of_birth + email + firstname + gender + lastname + middlename + prefix + suffix + created_at + } +`,t=` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id + } +`,a=` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + __typename + grand_total { + value + currency + } + subtotal { + currency + value + } + taxes { + amount { + currency + value + } + rate + title + } + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value + } + label + } + } +`;export{t as ADDRESS_FRAGMENT,e as BASIC_CUSTOMER_INFO_FRAGMENT,a as ORDER_SUMMARY_FRAGMENT}; diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 6de3ff0c18..955e04c737 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as q,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as Y,r as z,s as j,a as J,b as K}from"./chunks/fetch-graphql.js";import{g as Z}from"./chunks/getAttributesForm.js";import{g as te,a as re,r as ae}from"./chunks/requestGuestReturn.js";import{g as ne,a as se}from"./chunks/getGuestOrder.js";import{g as pe}from"./chunks/getCustomerOrdersReturn.js";import{c as T,P as R,a as A,G as D,O as g,B as O,b as h,A as C}from"./chunks/initialize.js";import{e as ue,g as de,d as le,i as me}from"./chunks/initialize.js";import{g as _e}from"./chunks/getStoreConfig.js";import{h as f}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{a as Re,c as Ae,r as De}from"./chunks/confirmCancelOrder.js";import"./chunks/GurestOrderFragment.graphql.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"./chunks/RequestReturnOrderFragment.graphql.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` +import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as ce,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as Ee}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -82,11 +82,11 @@ import{c as q,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as E,h a } } } - ${R} - ${A} ${D} + ${A} ${g} ${O} ${h} + ${f} ${C} -`,Q=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(f)};export{q as cancelOrder,ue as config,Re as confirmCancelOrder,Ae as confirmGuestReturn,E as fetchGraphQl,Z as getAttributesForm,te as getAttributesList,Y as getConfig,ne as getCustomer,pe as getCustomerOrdersReturn,se as getGuestOrder,de as getOrderDetailsById,_e as getStoreConfig,le as guestOrderByToken,me as initialize,Q as placeOrder,z as removeFetchGraphQlHeader,De as reorderItems,X as requestGuestOrderCancel,re as requestGuestReturn,ae as requestReturn,j as setEndpoint,J as setFetchGraphQlHeader,K as setFetchGraphQlHeaders}; +`,k=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,ce as config,Te as confirmCancelOrder,Re as confirmGuestReturn,E as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,Ee as getStoreConfig,de as guestOrderByToken,le as initialize,k as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/fragment.d.ts b/scripts/__dropins__/storefront-order/api/fragments.d.ts similarity index 93% rename from scripts/__dropins__/storefront-order/api/fragment.d.ts rename to scripts/__dropins__/storefront-order/api/fragments.d.ts index 9275ced8a6..3901508e5b 100644 --- a/scripts/__dropins__/storefront-order/api/fragment.d.ts +++ b/scripts/__dropins__/storefront-order/api/fragments.d.ts @@ -4,4 +4,4 @@ export { PRODUCT_DETAILS_FRAGMENT, PRICE_DETAILS_FRAGMENT, GIFT_CARD_DETAILS_FRA export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql'; export { RETURNS_FRAGMENT } from './graphql/ReturnsFragment.graphql'; export { GUEST_ORDER_FRAGMENT } from './graphql/GurestOrderFragment.graphql'; -//# sourceMappingURL=fragment.d.ts.map \ No newline at end of file +//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js deleted file mode 100644 index b3f1d975cb..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js +++ /dev/null @@ -1,99 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{P as _,a as e,G as E,O as R,B as t,b as r,A as T,R as a}from"./initialize.js";const d=` - fragment GUEST_ORDER_FRAGMENT on CustomerOrder { - email - id - number - order_date - order_status_change_date - status - token - carrier - shipping_method - printed_card_included - gift_receipt_included - available_actions - is_virtual - items_eligible_for_return { - ...ORDER_ITEM_DETAILS_FRAGMENT - } - returns { - ...RETURNS_FRAGMENT - } - payment_methods { - name - type - } - applied_coupons { - code - } - shipments { - id - tracking { - title - number - carrier - } - comments { - message - timestamp - } - items { - __typename - id - product_sku - product_name - order_item { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - } - } - } - payment_methods { - name - type - } - shipping_address { - ...ADDRESS_FRAGMENT - } - billing_address { - ...ADDRESS_FRAGMENT - } - items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } - total { - ...ORDER_SUMMARY_FRAGMENT - } - } - ${_} - ${e} - ${E} - ${R} - ${t} - ${r} - ${T} - ${a} -`;export{d as G}; diff --git a/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js deleted file mode 100644 index fbf77e337f..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js +++ /dev/null @@ -1,11 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -const R=` - fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { - __typename - uid - status - number - created_at - } -`;export{R}; diff --git a/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js index 0c05980aae..dce1a5dfeb 100644 --- a/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js +++ b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql.js";import{R as I}from"./RequestReturnOrderFragment.graphql.js";import{G as a}from"./GurestOrderFragment.graphql.js";import{c as O}from"./initialize.js";import{events as T}from"@dropins/tools/event-bus.js";const N=` +import{h as f}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql.js";import{REQUEST_RETURN_ORDER_FRAGMENT as I,GUEST_ORDER_FRAGMENT as O}from"../fragments.js";import{a}from"./initialize.js";import{events as T}from"@dropins/tools/event-bus.js";const N=` mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { reorderItems(orderNumber: $orderNumber) { cart { @@ -17,7 +17,7 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } } -`,$=async E=>await u(N,{method:"POST",variables:{orderNumber:E}}).then(t=>{var n,o,i,c,m,R;if((n=t.errors)!=null&&n.length)return _(t.errors);const e=!!((c=(i=(o=t==null?void 0:t.data)==null?void 0:o.reorderItems)==null?void 0:i.cart)!=null&&c.itemsV2.items.length),r=((R=(m=t==null?void 0:t.data)==null?void 0:m.reorderItems)==null?void 0:R.userInputErrors)??[];return{success:e,userInputErrors:r}}).catch(d),l=` +`,$=async E=>await u(N,{method:"POST",variables:{orderNumber:E}}).then(t=>{var n,o,i,c,m,R;if((n=t.errors)!=null&&n.length)return _(t.errors);const e=!!((c=(i=(o=t==null?void 0:t.data)==null?void 0:o.reorderItems)==null?void 0:i.cart)!=null&&c.itemsV2.items.length),r=((R=(m=t==null?void 0:t.data)==null?void 0:m.reorderItems)==null?void 0:R.userInputErrors)??[];return{success:e,userInputErrors:r}}).catch(f),l=` mutation CONFIRM_RETURN_GUEST_ORDER( $orderId: ID! $confirmationKey: String! @@ -34,8 +34,8 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } ${I} - ${a} -`,s=async(E,t)=>await u(l,{method:"POST",variables:{orderId:E,confirmationKey:t}}).then(e=>{var r,n,o,i,c,m,R;if((r=e.errors)!=null&&r.length)return _(e.errors);if((i=(o=(n=e==null?void 0:e.data)==null?void 0:n.confirmReturn)==null?void 0:o.return)!=null&&i.order){const f=O((R=(m=(c=e==null?void 0:e.data)==null?void 0:c.confirmReturn)==null?void 0:m.return)==null?void 0:R.order);return T.emit("order/data",f),f}return null}).catch(d),h=` + ${O} +`,G=async(E,t)=>await u(l,{method:"POST",variables:{orderId:E,confirmationKey:t}}).then(e=>{var r,n,o,i,c,m,R;if((r=e.errors)!=null&&r.length)return _(e.errors);if((i=(o=(n=e==null?void 0:e.data)==null?void 0:n.confirmReturn)==null?void 0:o.return)!=null&&i.order){const d=a((R=(m=(c=e==null?void 0:e.data)==null?void 0:c.confirmReturn)==null?void 0:m.return)==null?void 0:R.order);return T.emit("order/data",d),d}return null}).catch(f),h=` mutation CONFIRM_CANCEL_ORDER_MUTATION( $orderId: ID! $confirmationKey: String! @@ -52,5 +52,5 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } } - ${a} -`,y=async(E,t)=>u(h,{variables:{orderId:E,confirmationKey:t}}).then(async({errors:e,data:r})=>{var i,c,m,R;const n=[...(i=r==null?void 0:r.confirmCancelOrder)!=null&&i.errorV2?[(c=r==null?void 0:r.confirmCancelOrder)==null?void 0:c.errorV2]:[],...e??[]];let o=null;return(m=r==null?void 0:r.confirmCancelOrder)!=null&&m.order&&(o=O((R=r==null?void 0:r.confirmCancelOrder)==null?void 0:R.order),T.emit("order/data",o)),n.length>0?_(n):o});export{y as a,s as c,$ as r}; + ${O} +`,y=async(E,t)=>u(h,{variables:{orderId:E,confirmationKey:t}}).then(async({errors:e,data:r})=>{var i,c,m,R;const n=[...(i=r==null?void 0:r.confirmCancelOrder)!=null&&i.errorV2?[(c=r==null?void 0:r.confirmCancelOrder)==null?void 0:c.errorV2]:[],...e??[]];let o=null;return(m=r==null?void 0:r.confirmCancelOrder)!=null&&m.order&&(o=a((R=r==null?void 0:r.confirmCancelOrder)==null?void 0:R.order),T.emit("order/data",o)),n.length>0?_(n):o});export{y as a,G as c,$ as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js index 2d67bd0baf..6117fe0a7b 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as R}from"./network-error.js";import{R as E,P as T,a as _,G as c,O as s,t as o}from"./initialize.js";import{f as n}from"./fetch-graphql.js";const u=` +import{h as R}from"./network-error.js";import{RETURNS_FRAGMENT as E,PRODUCT_DETAILS_FRAGMENT as T,PRICE_DETAILS_FRAGMENT as _,GIFT_CARD_DETAILS_FRAGMENT as o,ORDER_ITEM_DETAILS_FRAGMENT as c}from"../fragments.js";import{t as n}from"./initialize.js";import{f as u}from"./fetch-graphql.js";const m=` query GET_CUSTOMER_ORDERS_RETURN($currentPage: Int, $pageSize: Int) { customer { returns(currentPage: $currentPage, pageSize: $pageSize) { @@ -16,6 +16,6 @@ import{h as R}from"./network-error.js";import{R as E,P as T,a as _,G as c,O as s ${E} ${T} ${_} + ${o} ${c} - ${s} -`,G=async(e=10,t=1)=>await n(u,{method:"GET",cache:"force-cache",variables:{pageSize:e,currentPage:t}}).then(r=>{var a;return o((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{G as g}; +`,A=async(e=10,a=1)=>await u(m,{method:"GET",cache:"force-cache",variables:{pageSize:e,currentPage:a}}).then(r=>{var t;return n((t=r==null?void 0:r.data)==null?void 0:t.customer.returns)}).catch(R);export{A as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js index d7d2442923..bb37f3d188 100644 --- a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js +++ b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as E}from"./network-error.js";import{f as i,h}from"./fetch-graphql.js";import{G as n}from"./GurestOrderFragment.graphql.js";import{f as o}from"./initialize.js";const G=t=>{var a,r,m,c,u,e;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:c.firstname)||"",lastname:((e=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:e.lastname)||""}},f=` +import{h as E}from"./network-error.js";import{f as i,h}from"./fetch-graphql.js";import{GUEST_ORDER_FRAGMENT as n}from"../fragments.js";import{d as o}from"./initialize.js";const G=t=>{var a,r,m,c,u,e;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:c.firstname)||"",lastname:((e=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:e.lastname)||""}},f=` query GET_CUSTOMER { customer { firstname diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js index ed56d3ced3..aeab4e7dc4 100644 --- a/scripts/__dropins__/storefront-order/chunks/initialize.js +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -1,205 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as q}from"@dropins/tools/event-bus.js";import{a as ta,h as Y}from"./network-error.js";import{f as Q}from"./fetch-graphql.js";const K=` - fragment ADDRESS_FRAGMENT on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id - } -`,j=` - fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { - __typename - canonical_url - url_key - uid - name - sku - only_x_left_in_stock - stock_status - thumbnail { - label - url - } - price_range { - maximum_price { - regular_price { - currency - value - } - } - } - } -`,H=` - fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { - prices { - price_including_tax { - value - currency - } - original_price { - value - currency - } - original_price_including_tax { - value - currency - } - price { - value - currency - } - } - } -`,J=` - fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { - ...PRICE_DETAILS_FRAGMENT - gift_message { - message - } - gift_card { - recipient_name - recipient_email - sender_name - sender_email - message - } - } -`,V=` - fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { - __typename - status - product_sku - eligible_for_return - product_name - product_url_key - id - quantity_ordered - quantity_shipped - quantity_canceled - quantity_invoiced - quantity_refunded - quantity_return_requested - product_sale_price { - value - currency - } - selected_options { - label - value - } - product { - ...PRODUCT_DETAILS_FRAGMENT - } - ...PRICE_DETAILS_FRAGMENT - } -`,W=` - fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { - ...PRICE_DETAILS_FRAGMENT - bundle_options { - uid - label - values { - uid - product_name - } - } - } -`,X=` - fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { - grand_total { - value - currency - } - total_giftcard { - currency - value - } - subtotal_excl_tax { - currency - value - } - subtotal_incl_tax { - currency - value - } - taxes { - amount { - currency - value - } - rate - title - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { - currency - value - } - label - } - } -`,Z=` - fragment RETURNS_FRAGMENT on Returns { - __typename - items { - number - status - created_at - shipping { - tracking { - status { - text - type - } - carrier { - uid - label - } - tracking_number - } - } - order { - number - token - } - items { - uid - quantity - status - request_quantity - order_item { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - } - } - } - } -`,_a=a=>a||0,ua=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)||""}}},ea=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},ia=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(e=>e.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},sa=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,la=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 E,c,r,O,d,g,N,M,A,D,u,y,T,p,S,o,f,G,h,F,C,L,k,U,B,$,P,x,m,w;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R}=la(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:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((O=(r=(c=(E=n==null?void 0:n.product)==null?void 0:E.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)!==((d=n==null?void 0:n.product_sale_price)==null?void 0:d.value)*(n==null?void 0:n.quantity_ordered),total:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.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:((y=n==null?void 0:n.product_sale_price)==null?void 0:y.value)||0,currency:(T=n==null?void 0:n.product_sale_price)==null?void 0:T.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(f=(o=(S=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:S.maximum_price)==null?void 0:o.regular_price)==null?void 0:f.value,currency:(C=(F=(h=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:h.maximum_price)==null?void 0:F.regular_price)==null?void 0:C.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((k=(L=n==null?void 0:n.product)==null?void 0:L.thumbnail)==null?void 0:k.label)||"",url:((B=(U=n==null?void 0:n.product)==null?void 0:U.thumbnail)==null?void 0:B.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:(($=n.gift_card)==null?void 0:$.sender_name)||"",senderEmail:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((x=n.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((m=n.gift_card)==null?void 0:m.recipient_name)||"",message:((w=n.gift_card)==null?void 0:w.message)||""}:void 0,configurableOptions:ea(n),bundleOptions:n.__typename==="BundleOrderItem"?ia(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?sa(n==null?void 0:n.downloadable_links):null}}),v=(a,n)=>{var O,d,g,N,M,A,D,u,y;const t=I(a.items),_=((O=ra(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],e=n?_.filter(T=>T.returnNumber===n):_,{total:i,...s}=ta({...a,items:t,returns:e},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(d=a==null?void 0:a.payment_methods)==null?void 0:d[0],R=(l==null?void 0:l.type)||"",E=(l==null?void 0:l.name)||"",c=(g=s==null?void 0:s.items)==null?void 0:g.reduce((T,p)=>T+(p==null?void 0:p.totalQuantity),0),r={...i,...s,totalQuantity:c,shipping:{amount:((N=i==null?void 0:i.totalShipping)==null?void 0:N.value)??0,currency:((M=i==null?void 0:i.totalShipping)==null?void 0:M.currency)||"",code:s.shippingMethod??""},payments:[{code:R,name:E}]};return z(r,(y=(u=(D=(A=b==null?void 0:b.getConfig())==null?void 0:A.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:y.call(u,a))},ca=(a,n,t)=>{var _,e,i,s,l,R,E;if((s=(i=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:i.items)!=null&&s.length&&a==="orderData"){const c=(E=(R=(l=n==null?void 0:n.data)==null?void 0:l.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return v(c,t)}return null},ra=a=>{var i,s,l,R,E;if(!((i=a==null?void 0:a.items)!=null&&i.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,e={ordersReturn:[...n].sort((c,r)=>+r.number-+c.number).map(c=>{var A,D;const{order:r,status:O,number:d,created_at:g}=c,N=((D=(A=c==null?void 0:c.shipping)==null?void 0:A.tracking)==null?void 0:D.map(u=>{const{status:y,carrier:T,tracking_number:p}=u;return{status:y,carrier:T,trackingNumber:p}}))??[],M=c.items.map(u=>{var G;const y=u==null?void 0:u.quantity,T=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,S=u==null?void 0:u.uid,o=u==null?void 0:u.order_item,f=((G=I([o]))==null?void 0:G.reduce((h,F)=>F,{}))??{};return{uid:S,quantity:y,status:T,requestQuantity:p,...f}});return{createdReturnAt:g,returnStatus:O,token:r==null?void 0:r.token,orderNumber:r==null?void 0:r.number,returnNumber:d,items:M,tracking:N}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return z(e,(E=(R=(l=(s=b==null?void 0:b.getConfig())==null?void 0:s.models)==null?void 0:l.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Ma=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrder;return v(t,n)},Ra=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrderByToken;return v(t,n)},Ea=` +import{merge as Q,Initializer as na}from"@dropins/tools/lib.js";import{events as L}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}from"./fetch-graphql.js";const _a=a=>a||0,ua=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)||""}}},ia=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},sa=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},la=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,e,R,N,b,r,M,S,D,O,u,A,p,y,G,f,F,h,C,q,v,d,B,$,U,w,P,o,z,Y;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:i,quantityRefunded:s,quantityReturned:l,quantityShipped:c,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:c,quantityReturnRequested:E,id:n==null?void 0:n.id,discounted:((N=(R=(e=(T=n==null?void 0:n.product)==null?void 0:T.price_range)==null?void 0:e.maximum_price)==null?void 0:R.regular_price)==null?void 0:N.value)*(n==null?void 0:n.quantity_ordered)!==((b=n==null?void 0:n.product_sale_price)==null?void 0:b.value)*(n==null?void 0:n.quantity_ordered),total:{value:((r=n==null?void 0:n.product_sale_price)==null?void 0:r.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.currency)||""},totalInclTax:{value:((S=n==null?void 0:n.product_sale_price)==null?void 0:S.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(D=n==null?void 0:n.product_sale_price)==null?void 0:D.currency},price:{value:((O=n==null?void 0:n.product_sale_price)==null?void 0:O.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:(p=n==null?void 0:n.product_sale_price)==null?void 0:p.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(F=(f=(G=(y=n==null?void 0:n.product)==null?void 0:y.price_range)==null?void 0:G.maximum_price)==null?void 0:f.regular_price)==null?void 0:F.value,currency:(v=(q=(C=(h=n==null?void 0:n.product)==null?void 0:h.price_range)==null?void 0:C.maximum_price)==null?void 0:q.regular_price)==null?void 0:v.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((B=(d=n==null?void 0:n.product)==null?void 0:d.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:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((o=n.gift_card)==null?void 0:o.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:ia(n),bundleOptions:n.__typename==="BundleOrderItem"?sa(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?la(n==null?void 0:n.downloadable_links):null}}),k=(a,n)=>{var N,b,r,M,S,D,O,u,A;const t=I(a.items),_=((N=Ra(a==null?void 0:a.returns))==null?void 0:N.ordersReturn)??[],i=n?_.filter(p=>p.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"}),c=(b=a==null?void 0:a.payment_methods)==null?void 0:b[0],E=(c==null?void 0:c.type)||"",T=(c==null?void 0:c.name)||"",e=(r=l==null?void 0:l.items)==null?void 0:r.reduce((p,y)=>p+(y==null?void 0:y.totalQuantity),0),R={...s,...l,totalQuantity:e,shipping:{amount:((M=s==null?void 0:s.totalShipping)==null?void 0:M.value)??0,currency:((S=s==null?void 0:s.totalShipping)==null?void 0:S.currency)||"",code:l.shippingMethod??""},payments:[{code:E,name:T}]};return Q(R,(A=(u=(O=(D=g==null?void 0:g.getConfig())==null?void 0:D.models)==null?void 0:O.OrderDataModel)==null?void 0:u.transformer)==null?void 0:A.call(u,a))},ea=(a,n,t)=>{var _,i,s,l,c,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 e=(T=(E=(c=n==null?void 0:n.data)==null?void 0:c.customer)==null?void 0:E.orders)==null?void 0:T.items[0];return k(e,t)}return null},Ra=a=>{var s,l,c,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((e,R)=>+R.number-+e.number).map(e=>{var D,O;const{order:R,status:N,number:b,created_at:r}=e,M=((O=(D=e==null?void 0:e.shipping)==null?void 0:D.tracking)==null?void 0:O.map(u=>{const{status:A,carrier:p,tracking_number:y}=u;return{status:A,carrier:p,trackingNumber:y}}))??[],S=e.items.map(u=>{var h;const A=u==null?void 0:u.quantity,p=u==null?void 0:u.status,y=u==null?void 0:u.request_quantity,G=u==null?void 0:u.uid,f=u==null?void 0:u.order_item,F=((h=I([f]))==null?void 0:h.reduce((C,q)=>q,{}))??{};return{uid:G,quantity:A,status:p,requestQuantity:y,...F}});return{createdReturnAt:r,returnStatus:N,token:R==null?void 0:R.token,orderNumber:R==null?void 0:R.number,returnNumber:b,items:S,tracking:M}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return Q(i,(T=(E=(c=(l=g==null?void 0:g.getConfig())==null?void 0:l.models)==null?void 0:c.CustomerOrdersReturnModel)==null?void 0:E.transformer)==null?void 0:T.call(E,{...n,...t}))},ga=(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 k(t,n)},Ea=(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 k(t,n)},Ta=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders(filter: { number: { eq: $orderNumber } }) { @@ -303,15 +104,15 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${K} ${j} ${H} ${J} ${V} ${W} ${X} - ${K} ${Z} -`,Ta=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await Q(Ea,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(e=>ca(t??"orderData",e,n)).catch(Y),pa=` +`,pa=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await m(Ta,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(i=>ea(t??"orderData",i,n)).catch(x),ya=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -400,12 +201,12 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${K} ${j} ${H} ${J} ${V} ${W} ${X} - ${K} ${Z} -`,ya=async(a,n)=>await Q(pa,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>Ra(t,n)).catch(Y),Aa="orderData",Da=async a=>{var s;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"&&((s=a==null?void 0:a.orderRef)==null?void 0:s.length)>20,e=(a==null?void 0:a.orderData)??null;if(e){q.emit("order/data",{...e,returnNumber:t});return}if(!n)return;const i=_?await ya(n,t):await Ta({orderId:n,returnRef:t,queryType:Aa});i?q.emit("order/data",{...i,returnNumber:t}):q.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}),Da(a).catch(console.error)},listeners:()=>[]}),b=aa.config;export{K as A,W as B,J as G,V as O,j as P,Z as R,H as a,X as b,v as c,ya as d,b as e,Ma as f,Ta as g,aa as i,ra as t}; +`,Aa=async(a,n)=>await m(ya,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>Ea(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){L.emit("order/data",{...i,returnNumber:t});return}if(!n)return;const s=_?await Aa(n,t):await pa({orderId:n,returnRef:t,queryType:Da});s?L.emit("order/data",{...s,returnNumber:t}):L.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:()=>[]}),g=aa.config;export{k as a,Aa as b,g as c,ga as d,pa as g,aa as i,Ra as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js index f135fe1bcb..93660ac157 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize.js";import{f as s,h as R}from"./fetch-graphql.js";import{G}from"./GurestOrderFragment.graphql.js";const O=` +import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAILS_FRAGMENT as i,ORDER_ITEM_DETAILS_FRAGMENT as A,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as D,ORDER_SUMMARY_FRAGMENT as c,ADDRESS_FRAGMENT as u,GUEST_ORDER_FRAGMENT as G}from"../fragments.js";import{f as a,h as R}from"./fetch-graphql.js";import{a as T}from"./initialize.js";const N=` mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { cancelOrder(input: { order_id: $orderId, reason: $reason }) { error @@ -79,14 +79,14 @@ import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize } } } - ${T} ${d} + ${s} ${i} ${A} ${D} ${c} ${u} -`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return s(O,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const a=E(n.cancelOrder.order);_(a)}).catch(()=>t())},N=` +`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return a(N,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const E=T(n.cancelOrder.order);_(E)}).catch(()=>t())},O=` mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION( $token: String! $reason: String! @@ -99,4 +99,4 @@ import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize } } ${G} -`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return s(N,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const a=E(n.requestGuestOrderCancel.order);_(a)}).catch(()=>t())};export{M as c,S as r}; +`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return a(O,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const E=T(n.requestGuestOrderCancel.order);_(E)}).catch(()=>t())};export{M as c,S as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js index 445a3d5263..353739859b 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 s,h as o}from"./fetch-graphql.js";import{t as d}from"./transform-attributes-form.js";import{R as m}from"./RequestReturnOrderFragment.graphql.js";import{merge as l}from"@dropins/tools/lib.js";import{e as f}from"./initialize.js";const h=r=>{var u,n,E,c,R,T;if(!((n=(u=r==null?void 0:r.data)==null?void 0:u.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,a={...t,createdAt:e};return l(a,(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,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{c 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 { @@ -33,7 +33,7 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } } -`,g=async r=>await s(U,{method:"GET",cache:"force-cache",variables:{entityType:r}}).then(e=>{var t,a,u;return(t=e.errors)!=null&&t.length?o(e.errors):d((u=(a=e==null?void 0:e.data)==null?void 0:a.attributesList)==null?void 0:u.items)}).catch(i),q=` +`,g=async r=>await o(U,{method:"GET",cache:"force-cache",variables:{entityType:r}}).then(e=>{var t,u,a;return(t=e.errors)!=null&&t.length?s(e.errors):d((a=(u=e==null?void 0:e.data)==null?void 0:u.attributesList)==null?void 0:a.items)}).catch(i),q=` mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { requestReturn(input: $input) { return { @@ -42,7 +42,7 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } ${m} -`,O=async r=>{const e=_(r,"snakeCase",{});return await s(q,{method:"POST",variables:{input:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?o(t.errors):h(t)}).catch(i)},S=` +`,O=async r=>{const e=_(r,"snakeCase",{});return await o(q,{method:"POST",variables:{input:e}}).then(t=>{var u;return(u=t.errors)!=null&&u.length?s(t.errors):h(t)}).catch(i)},S=` mutation REQUEST_RETURN_GUEST_ORDER($input: RequestGuestReturnInput!) { requestGuestReturn(input: $input) { return { @@ -51,4 +51,4 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } ${m} -`,v=async r=>{const e=_(r,"snakeCase",{});return await s(S,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return o(t.errors);const{created_at:a,...u}=t.data.requestGuestReturn.return;return{...u,createdAt:a}}).catch(i)};export{v as a,g,O as r}; +`,v=async r=>{const e=_(r,"snakeCase",{});return await o(S,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return s(t.errors);const{created_at:u,...a}=t.data.requestGuestReturn.return;return{...a,createdAt:u}}).catch(i)};export{v as a,g,O as r}; diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index a4eda97a2b..df04cdc644 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"../chunks/RequestReturnOrderFragment.graphql.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 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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js index a148b2ddf6..0933505eac 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/initialize.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/GurestOrderFragment.graphql.js";export{C as OrderCancelForm,F as default}; +import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/requestGuestOrderCancel.js";import"../fragments.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../chunks/network-error.js";export{C as OrderCancelForm,F as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index 848af49fd4..e391860b18 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"../chunks/GurestOrderFragment.graphql.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 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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index 3e50d674bb..1e1d15df87 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"../chunks/RequestReturnOrderFragment.graphql.js";import"../chunks/GurestOrderFragment.graphql.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}},He=({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{He as OrderStatus,He 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/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index 0f701a7577..f185864eb6 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},tr=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const p=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",u]),children:f(A,{placeholderImage:(p==null?void 0:p.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{tr as default}; +import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.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/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},ir=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const p=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",u]),children:f(A,{placeholderImage:(p==null?void 0:p.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{ir as default}; diff --git a/scripts/__dropins__/storefront-order/fragments.d.ts b/scripts/__dropins__/storefront-order/fragments.d.ts new file mode 100644 index 0000000000..4d0b3af3f9 --- /dev/null +++ b/scripts/__dropins__/storefront-order/fragments.d.ts @@ -0,0 +1 @@ +export * from './api/fragments' diff --git a/scripts/__dropins__/storefront-order/fragments.js b/scripts/__dropins__/storefront-order/fragments.js new file mode 100644 index 0000000000..5908a7657e --- /dev/null +++ b/scripts/__dropins__/storefront-order/fragments.js @@ -0,0 +1,306 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const R=` + fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { + __typename + uid + status + number + created_at + } +`,e=` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id + } +`,t=` + fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { + __typename + canonical_url + url_key + uid + name + sku + only_x_left_in_stock + stock_status + thumbnail { + label + url + } + price_range { + maximum_price { + regular_price { + currency + value + } + } + } + } +`,_=` + fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { + prices { + price_including_tax { + value + currency + } + original_price { + value + currency + } + original_price_including_tax { + value + currency + } + price { + value + currency + } + } + } +`,r=` + fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { + ...PRICE_DETAILS_FRAGMENT + gift_message { + message + } + gift_card { + recipient_name + recipient_email + sender_name + sender_email + message + } + } +`,n=` + fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { + __typename + status + product_sku + eligible_for_return + product_name + product_url_key + id + quantity_ordered + quantity_shipped + quantity_canceled + quantity_invoiced + quantity_refunded + quantity_return_requested + product_sale_price { + value + currency + } + selected_options { + label + value + } + product { + ...PRODUCT_DETAILS_FRAGMENT + } + ...PRICE_DETAILS_FRAGMENT + } +`,a=` + fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { + ...PRICE_DETAILS_FRAGMENT + bundle_options { + uid + label + values { + uid + product_name + } + } + } +`,i=` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + grand_total { + value + currency + } + total_giftcard { + currency + value + } + subtotal_excl_tax { + currency + value + } + subtotal_incl_tax { + currency + value + } + taxes { + amount { + currency + value + } + rate + title + } + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value + } + label + } + } +`,E=` + fragment RETURNS_FRAGMENT on Returns { + __typename + items { + number + status + created_at + shipping { + tracking { + status { + text + type + } + carrier { + uid + label + } + tracking_number + } + } + order { + number + token + } + items { + uid + quantity + status + request_quantity + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + } +`,u=` + fragment GUEST_ORDER_FRAGMENT on CustomerOrder { + email + id + number + order_date + order_status_change_date + status + token + carrier + shipping_method + printed_card_included + gift_receipt_included + available_actions + is_virtual + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + } + returns { + ...RETURNS_FRAGMENT + } + payment_methods { + name + type + } + applied_coupons { + code + } + shipments { + id + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + __typename + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + ${t} + ${_} + ${r} + ${n} + ${a} + ${i} + ${e} + ${E} +`;export{e as ADDRESS_FRAGMENT,a as BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT,r as GIFT_CARD_DETAILS_FRAGMENT,u as GUEST_ORDER_FRAGMENT,n as ORDER_ITEM_DETAILS_FRAGMENT,i as ORDER_SUMMARY_FRAGMENT,_ as PRICE_DETAILS_FRAGMENT,t as PRODUCT_DETAILS_FRAGMENT,R as REQUEST_RETURN_ORDER_FRAGMENT,E as RETURNS_FRAGMENT};