diff --git a/blocks/commerce-account-sidebar/commerce-account-sidebar.css b/blocks/commerce-account-sidebar/commerce-account-sidebar.css index 5a9fcd520c..ab089b9806 100644 --- a/blocks/commerce-account-sidebar/commerce-account-sidebar.css +++ b/blocks/commerce-account-sidebar/commerce-account-sidebar.css @@ -9,8 +9,8 @@ align-items: center; padding: var(--spacing-medium); margin-bottom: var(--spacing-small); - border: var(--shape-border-width-1) solid var(--color-neutral-400); - border-radius: var(--shape-border-radius-1); + border: var(--shape-border-width-2) solid var(--color-neutral-400); + border-radius: var(--shape-border-radius-2); text-decoration: none; } diff --git a/blocks/commerce-customer-details/commerce-customer-details.css b/blocks/commerce-customer-details/commerce-customer-details.css index 0a07336c49..f11c1b9c4d 100644 --- a/blocks/commerce-customer-details/commerce-customer-details.css +++ b/blocks/commerce-customer-details/commerce-customer-details.css @@ -1,2 +1,6 @@ /* .commerce-customer-details { } */ + +.commerce-customer-details { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-customer-information/commerce-customer-information.css b/blocks/commerce-customer-information/commerce-customer-information.css new file mode 100644 index 0000000000..ff7112406e --- /dev/null +++ b/blocks/commerce-customer-information/commerce-customer-information.css @@ -0,0 +1 @@ +/* stylelint-disable no-empty-source */ diff --git a/blocks/commerce-customer-information/commerce-customer-information.js b/blocks/commerce-customer-information/commerce-customer-information.js new file mode 100644 index 0000000000..f8c434b62d --- /dev/null +++ b/blocks/commerce-customer-information/commerce-customer-information.js @@ -0,0 +1,17 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import CustomerInformation from '@dropins/storefront-account/containers/CustomerInformation.js'; +import { render as accountRenderer } from '@dropins/storefront-account/render.js'; +import { checkIsAuthenticated } from '../../scripts/configs.js'; +import { CUSTOMER_LOGIN_PATH } from '../../scripts/constants.js'; + +// Initialize +import '../../scripts/initializers/account.js'; + +export default async function decorate(block) { + if (!checkIsAuthenticated()) { + window.location.href = CUSTOMER_LOGIN_PATH; + } else { + await accountRenderer.render(CustomerInformation, {})(block); + } +} diff --git a/blocks/commerce-order-cost-summary/commerce-order-cost-summary.css b/blocks/commerce-order-cost-summary/commerce-order-cost-summary.css new file mode 100644 index 0000000000..be0b41730c --- /dev/null +++ b/blocks/commerce-order-cost-summary/commerce-order-cost-summary.css @@ -0,0 +1,6 @@ +/* .commerce-customer-details { +} */ + +.commerce-order-cost-summary { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-order-cost-summary/commerce-order-cost-summary.js b/blocks/commerce-order-cost-summary/commerce-order-cost-summary.js new file mode 100644 index 0000000000..eb93aab273 --- /dev/null +++ b/blocks/commerce-order-cost-summary/commerce-order-cost-summary.js @@ -0,0 +1,11 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import { render as orderRenderer } from '@dropins/storefront-order/render.js'; +import { OrderCostSummary } from '@dropins/storefront-order/containers/OrderCostSummary.js'; + +// Initialize +import '../../scripts/initializers/order.js'; + +export default async function decorate(block) { + await orderRenderer.render(OrderCostSummary, {})(block); +} diff --git a/blocks/commerce-order-header/commerce-order-header.css b/blocks/commerce-order-header/commerce-order-header.css index 0d63f51840..7b3d52bfb4 100644 --- a/blocks/commerce-order-header/commerce-order-header.css +++ b/blocks/commerce-order-header/commerce-order-header.css @@ -1,3 +1,7 @@ +body:not(.columns) main div.commerce-order-header-wrapper { + margin-top: var(--spacing-large); +} + body.columns main > .section > div.commerce-order-header-wrapper { margin-bottom: 0; } diff --git a/blocks/commerce-order-header/commerce-order-header.js b/blocks/commerce-order-header/commerce-order-header.js index 4f2817bb3c..843eb6e0fe 100644 --- a/blocks/commerce-order-header/commerce-order-header.js +++ b/blocks/commerce-order-header/commerce-order-header.js @@ -3,6 +3,7 @@ import { events } from '@dropins/tools/event-bus.js'; import { Header, provider as uiProvider } from '@dropins/tools/components.js'; import { CUSTOMER_ORDER_DETAILS_PATH, CUSTOMER_ORDERS_PATH } from '../../scripts/constants.js'; +import { fetchPlaceholders } from '../../scripts/aem.js'; export default async function decorate(block) { block.innerHTML = ''; @@ -11,10 +12,11 @@ export default async function decorate(block) { await uiProvider.render(Header, { title: 'Order' })(headerContainer); if (window.location.href.includes(CUSTOMER_ORDER_DETAILS_PATH)) { + const placeholders = await fetchPlaceholders(); + const link = document.createElement('a'); - // TODO: Add i18n when appropriate functionality will be introduced in boilerplate - link.innerText = '< Back to all orders'; + link.innerText = placeholders?.Custom?.CommerceOrderHeader?.backToAllOrders; link.href = CUSTOMER_ORDERS_PATH; link.classList.add('orders-list-link'); diff --git a/blocks/commerce-order-product-list/commerce-order-product-list.css b/blocks/commerce-order-product-list/commerce-order-product-list.css new file mode 100644 index 0000000000..2e272a7a4f --- /dev/null +++ b/blocks/commerce-order-product-list/commerce-order-product-list.css @@ -0,0 +1,10 @@ +/* .commerce-customer-details { +} */ + +.commerce-order-product-list { + margin-bottom: var(--spacing-small); +} + +.commerce-order-product-list .dropin-cart-item a:hover { + text-decoration: none; +} diff --git a/blocks/commerce-order-product-list/commerce-order-product-list.js b/blocks/commerce-order-product-list/commerce-order-product-list.js new file mode 100644 index 0000000000..20e641d248 --- /dev/null +++ b/blocks/commerce-order-product-list/commerce-order-product-list.js @@ -0,0 +1,13 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import { render as orderRenderer } from '@dropins/storefront-order/render.js'; +import { OrderProductList } from '@dropins/storefront-order/containers/OrderProductList.js'; + +// Initialize +import '../../scripts/initializers/order.js'; + +export default async function decorate(block) { + await orderRenderer.render(OrderProductList, { + routeProductDetails: (product) => `/products/${product.productUrlKey}/${product.product.sku}`, + })(block); +} diff --git a/blocks/commerce-order-returns/commerce-order-returns.css b/blocks/commerce-order-returns/commerce-order-returns.css new file mode 100644 index 0000000000..7a3037abf9 --- /dev/null +++ b/blocks/commerce-order-returns/commerce-order-returns.css @@ -0,0 +1,6 @@ +/* .commerce-customer-details { +} */ + +.commerce-order-returns { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-order-returns/commerce-order-returns.js b/blocks/commerce-order-returns/commerce-order-returns.js new file mode 100644 index 0000000000..0a92e89e63 --- /dev/null +++ b/blocks/commerce-order-returns/commerce-order-returns.js @@ -0,0 +1,32 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import { render as orderRenderer } from '@dropins/storefront-order/render.js'; +import { OrderReturns } from '@dropins/storefront-order/containers/OrderReturns.js'; +import { checkIsAuthenticated } from '../../scripts/configs.js'; +import { + CUSTOMER_RETURN_DETAILS_PATH, + RETURN_DETAILS_PATH, +} from '../../scripts/constants.js'; + +// Initialize +import '../../scripts/initializers/order.js'; + +export default async function decorate(block) { + const isAuthenticated = checkIsAuthenticated(); + const returnDetailsPath = isAuthenticated + ? CUSTOMER_RETURN_DETAILS_PATH + : RETURN_DETAILS_PATH; + + await orderRenderer.render(OrderReturns, { + routeReturnDetails: ({ orderNumber, returnNumber, token }) => { + const { searchParams } = new URL(window.location.href); + const orderRefFromUrl = searchParams.get('orderRef'); + const newOrderRef = isAuthenticated ? orderNumber : token; + + const encodedOrderRef = encodeURIComponent(orderRefFromUrl || newOrderRef); + + return `${returnDetailsPath}?orderRef=${encodedOrderRef}&returnRef=${returnNumber}`; + }, + routeProductDetails: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'), + })(block); +} diff --git a/blocks/commerce-order-status/commerce-order-status.css b/blocks/commerce-order-status/commerce-order-status.css index ff7112406e..2aa436e294 100644 --- a/blocks/commerce-order-status/commerce-order-status.css +++ b/blocks/commerce-order-status/commerce-order-status.css @@ -1 +1,5 @@ /* stylelint-disable no-empty-source */ + +.commerce-order-status { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-order-status/commerce-order-status.js b/blocks/commerce-order-status/commerce-order-status.js index a6b61dc16e..d47b0061a6 100644 --- a/blocks/commerce-order-status/commerce-order-status.js +++ b/blocks/commerce-order-status/commerce-order-status.js @@ -2,10 +2,14 @@ /* eslint-disable import/no-extraneous-dependencies */ import { render as orderRenderer } from '@dropins/storefront-order/render.js'; import { OrderStatus } from '@dropins/storefront-order/containers/OrderStatus.js'; +import { checkIsAuthenticated } from '../../scripts/configs.js'; // Initialize import '../../scripts/initializers/order.js'; export default async function decorate(block) { - await orderRenderer.render(OrderStatus, {})(block); + await orderRenderer.render(OrderStatus, { + routeCreateReturn: (orderData) => (checkIsAuthenticated() ? `/customer/create-return?orderId=${orderData.id}` : `/create-return?orderId=${orderData.id}`), + routeOnSuccess: () => '/cart', + })(block); } diff --git a/blocks/commerce-orders-list/commerce-orders-list.js b/blocks/commerce-orders-list/commerce-orders-list.js index 3cbf636f87..9a67857031 100644 --- a/blocks/commerce-orders-list/commerce-orders-list.js +++ b/blocks/commerce-orders-list/commerce-orders-list.js @@ -4,7 +4,12 @@ import { render as accountRenderer } from '@dropins/storefront-account/render.js import { OrdersList } from '@dropins/storefront-account/containers/OrdersList.js'; import { readBlockConfig } from '../../scripts/aem.js'; import { checkIsAuthenticated } from '../../scripts/configs.js'; -import { CUSTOMER_LOGIN_PATH, CUSTOMER_ORDER_DETAILS_PATH, CUSTOMER_ORDERS_PATH } from '../../scripts/constants.js'; +import { + CUSTOMER_LOGIN_PATH, + CUSTOMER_ORDER_DETAILS_PATH, + CUSTOMER_ORDERS_PATH, + CUSTOMER_RETURN_DETAILS_PATH, +} from '../../scripts/constants.js'; // Initialize import '../../scripts/initializers/account.js'; @@ -19,14 +24,8 @@ export default async function decorate(block) { minifiedView: minifiedViewConfig === 'true', routeOrdersList: () => CUSTOMER_ORDERS_PATH, routeOrderDetails: (orderNumber) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`, - slots: { - // OrdersListCard: (ctx) => { - // console.log('OrdersListCard', ctx); - // }, - // OrdersListAction: (ctx) => { - // console.log('OrdersListAction', ctx); - // }, - }, + routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`, + routeOrderProduct: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'), })(block); } } diff --git a/blocks/commerce-return-header/commerce-return-header.css b/blocks/commerce-return-header/commerce-return-header.css new file mode 100644 index 0000000000..2dfd0ba836 --- /dev/null +++ b/blocks/commerce-return-header/commerce-return-header.css @@ -0,0 +1,12 @@ +body:not(.columns) main div.commerce-return-header { + margin-top: var(--spacing-large); +} + +body.columns main > .section > div.commerce-return-header { + margin-bottom: 0; +} + +.returns-list-header { + display: inline-block; + margin-bottom: var(--spacing-medium); +} diff --git a/blocks/commerce-return-header/commerce-return-header.js b/blocks/commerce-return-header/commerce-return-header.js new file mode 100644 index 0000000000..47bf19ea4f --- /dev/null +++ b/blocks/commerce-return-header/commerce-return-header.js @@ -0,0 +1,34 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import { events } from '@dropins/tools/event-bus.js'; +import { Header, provider as uiProvider } from '@dropins/tools/components.js'; +import { CUSTOMER_RETURN_DETAILS_PATH, CUSTOMER_RETURNS_PATH } from '../../scripts/constants.js'; +import { fetchPlaceholders } from '../../scripts/aem.js'; + +export default async function decorate(block) { + block.innerHTML = ''; + + const headerContainer = document.createElement('div'); + await uiProvider.render(Header, { title: 'Return' })(headerContainer); + + if (window.location.href.includes(CUSTOMER_RETURN_DETAILS_PATH)) { + const placeholders = await fetchPlaceholders(); + + const link = document.createElement('a'); + + link.innerText = placeholders?.Custom?.CommerceReturnHeader?.backToAllReturns; + link.href = CUSTOMER_RETURNS_PATH; + link.classList.add('returns-list-header'); + + block.appendChild(link); + } + + block.appendChild(headerContainer); + + events.on('order/data', (orderData) => { + const urlParams = new URLSearchParams(window.location.search); + const returnNumber = urlParams.get('returnRef'); + const returnData = orderData.returns.find((item) => item.returnNumber === returnNumber); + uiProvider.render(Header, { title: `Return ${returnData.returnNumber}` })(headerContainer); + }, { eager: true }); +} diff --git a/blocks/commerce-returns-list/commerce-returns-list.css b/blocks/commerce-returns-list/commerce-returns-list.css new file mode 100644 index 0000000000..ff7112406e --- /dev/null +++ b/blocks/commerce-returns-list/commerce-returns-list.css @@ -0,0 +1 @@ +/* stylelint-disable no-empty-source */ diff --git a/blocks/commerce-returns-list/commerce-returns-list.js b/blocks/commerce-returns-list/commerce-returns-list.js new file mode 100644 index 0000000000..db7f57295e --- /dev/null +++ b/blocks/commerce-returns-list/commerce-returns-list.js @@ -0,0 +1,33 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/no-extraneous-dependencies */ +import { render as orderRenderer } from '@dropins/storefront-order/render.js'; +import ReturnsList from '@dropins/storefront-order/containers/ReturnsList.js'; +import { readBlockConfig } from '../../scripts/aem.js'; +import { checkIsAuthenticated } from '../../scripts/configs.js'; +import { + CUSTOMER_LOGIN_PATH, + CUSTOMER_RETURN_DETAILS_PATH, + CUSTOMER_ORDER_DETAILS_PATH, + CUSTOMER_RETURNS_PATH, +} from '../../scripts/constants.js'; + +// Initialize +import '../../scripts/initializers/order.js'; + +export default async function decorate(block) { + const { + 'minified-view': minifiedViewConfig = 'false', + } = readBlockConfig(block); + + if (!checkIsAuthenticated()) { + window.location.href = CUSTOMER_LOGIN_PATH; + } else { + await orderRenderer.render(ReturnsList, { + minifiedView: minifiedViewConfig === 'true', + routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`, + routeOrderDetails: ({ orderNumber }) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`, + routeReturnsList: () => CUSTOMER_RETURNS_PATH, + routeProductDetails: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'), + })(block); + } +} diff --git a/blocks/commerce-search-order/commerce-search-order.css b/blocks/commerce-search-order/commerce-search-order.css index 1398247231..e5c7ce2618 100644 --- a/blocks/commerce-search-order/commerce-search-order.css +++ b/blocks/commerce-search-order/commerce-search-order.css @@ -3,3 +3,15 @@ main .commerce-search-order-container { margin: 40px auto; width: 100%; } + +.commerce-search-order .dropin-in-line-alert { + margin-bottom: var(--spacing-small); +} + +.commerce-search-order .dropin-card h2 { + margin-bottom: var(--spacing-small); +} + +.commerce-search-order .dropin-card p { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-shipping-status/commerce-shipping-status.css b/blocks/commerce-shipping-status/commerce-shipping-status.css index ff7112406e..021733a3f3 100644 --- a/blocks/commerce-shipping-status/commerce-shipping-status.css +++ b/blocks/commerce-shipping-status/commerce-shipping-status.css @@ -1 +1,9 @@ /* stylelint-disable no-empty-source */ + +.commerce-shipping-status { + margin-bottom: var(--spacing-small); +} + +.commerce-shipping-status .order-shipping-status-card { + margin-bottom: var(--spacing-small); +} diff --git a/blocks/commerce-shipping-status/commerce-shipping-status.js b/blocks/commerce-shipping-status/commerce-shipping-status.js index 50072a0b59..33779c8cea 100644 --- a/blocks/commerce-shipping-status/commerce-shipping-status.js +++ b/blocks/commerce-shipping-status/commerce-shipping-status.js @@ -7,5 +7,15 @@ import { ShippingStatus } from '@dropins/storefront-order/containers/ShippingSta import '../../scripts/initializers/order.js'; export default async function decorate(block) { - await orderRenderer.render(ShippingStatus, {})(block); + await orderRenderer.render(ShippingStatus, { + routeProductDetails: (data) => { + if (data?.orderItem) { + return `/products/${data?.orderItem?.productUrlKey}/${data?.orderItem?.product?.sku}`; + } + if (data?.product) { + return `/products/${data?.product?.urlKey}/${data?.product?.sku}`; + } + return '#'; + }, + })(block); } diff --git a/blocks/header/renderAuthDropdown.js b/blocks/header/renderAuthDropdown.js index 45a5d1cc26..77e25c91a5 100644 --- a/blocks/header/renderAuthDropdown.js +++ b/blocks/header/renderAuthDropdown.js @@ -68,7 +68,7 @@ export function renderAuthDropdown(navTools) { logoutButtonElement.addEventListener('click', async () => { await authApi.revokeCustomerToken(); - checkAndRedirect('/customer/account', '/customer/login'); + checkAndRedirect('/customer', '/customer/login'); }); renderSignIn(authDropinContainer); diff --git a/package-lock.json b/package-lock.json index ecc882eb22..376fd0301e 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-alpha13", + "@dropins/storefront-account": "0.1.0-alpha17", "@dropins/storefront-auth": "0.0.1-alpha25", "@dropins/storefront-cart": "0.9.0", "@dropins/storefront-checkout": "0.1.0-alpha49", - "@dropins/storefront-order": "0.1.0-alpha15", + "@dropins/storefront-order": "0.1.0-alpha18", "@dropins/storefront-order-confirmation": "0.1.0-alpha33", "@dropins/storefront-pdp": "0.4.0", "@dropins/tools": "^0.35.0" @@ -797,9 +797,9 @@ } }, "node_modules/@dropins/storefront-account": { - "version": "0.1.0-alpha13", - "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-0.1.0-alpha13.tgz", - "integrity": "sha512-Pe0tSBGiweMTyEzAubM0Jwjl+SUUrZoAwa+8RhBEjw4YsOJskiznhyUo0SOOq9Fn+0crnEGkwia3Be1fQ+5tHQ==" + "version": "0.1.0-alpha17", + "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-0.1.0-alpha17.tgz", + "integrity": "sha512-iB4thEAq8hj8nkjLikM+mfZAnfp4q57AgbLpnex3jf0QkDfJefv7/ydUamydpDuqvJ6sP0jMwYKPf4/XbbcE8Q==" }, "node_modules/@dropins/storefront-auth": { "version": "0.0.1-alpha25", @@ -815,9 +815,9 @@ "version": "0.1.0-alpha49" }, "node_modules/@dropins/storefront-order": { - "version": "0.1.0-alpha15", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-0.1.0-alpha15.tgz", - "integrity": "sha512-Sz4Lw+ydpwVZgxtQVic3WWpCIT8yc7QgA3ODSIaaLxIY8Ochtrtb1JSuCl6vTq5WyTgaUb7rrmgi1KVkwAAqXQ==" + "version": "0.1.0-alpha18", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-0.1.0-alpha18.tgz", + "integrity": "sha512-UMw+8XcpKe544IzLr4gK4pZ+/lihKcBogr4/p2+CwIfIbjgb4p6S1Ly3kFDR3xNglYRSXEVO1RxJQwyh31ltLg==" }, "node_modules/@dropins/storefront-order-confirmation": { "version": "0.1.0-alpha33" diff --git a/package.json b/package.json index 8cfa0e8ce4..ec253a5761 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-alpha13", + "@dropins/storefront-account": "0.1.0-alpha17", "@dropins/storefront-auth": "0.0.1-alpha25", "@dropins/storefront-cart": "0.9.0", "@dropins/storefront-checkout": "0.1.0-alpha49", - "@dropins/storefront-order": "0.1.0-alpha15", + "@dropins/storefront-order": "0.1.0-alpha18", "@dropins/storefront-order-confirmation": "0.1.0-alpha33", "@dropins/storefront-pdp": "0.4.0", "@dropins/tools": "^0.35.0" diff --git a/scripts/__dropins__/storefront-account/api.js b/scripts/__dropins__/storefront-account/api.js index 66220c63e2..80d1dacbc0 100644 --- a/scripts/__dropins__/storefront-account/api.js +++ b/scripts/__dropins__/storefront-account/api.js @@ -1,9 +1 @@ -import{Initializer as c}from"@dropins/tools/lib.js";import{f as n,h as d,a as u}from"./chunks/removeCustomerAddress.js";import{e as T,d as x,g as y,j as Q,i as k,k as w,l as z,r as O,s as R,b,c as v,u as M}from"./chunks/removeCustomerAddress.js";import{g as U}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const s=new c({init:async t=>{const a={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};s.config.setConfig({...a,...t})},listeners:()=>[]}),G=s.config,f=t=>{var a,r,e,i,o,m;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((i=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:i.firstname)||"",lastname:((m=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:m.lastname)||""}},h=` - query GET_CUSTOMER { - customer { - firstname - lastname - email - } - } -`,A=async()=>await n(h,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?d(t.errors):f(t)}).catch(u);export{G as config,T as createCustomerAddress,n as fetchGraphQl,x as getAttributesForm,y as getConfig,Q as getCountries,A as getCustomer,k as getCustomerAddress,U as getOrderHistoryList,w as getRegions,s as initialize,z as removeCustomerAddress,O as removeFetchGraphQlHeader,R as setEndpoint,b as setFetchGraphQlHeader,v as setFetchGraphQlHeaders,M as updateCustomerAddress}; +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}; diff --git a/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts new file mode 100644 index 0000000000..bd2d4a00d0 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts @@ -0,0 +1,2 @@ +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/getCustomer/graphql/getCustomer.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getCustomer/graphql/getCustomer.graphql.d.ts index ba5cc6e262..234f26dab3 100644 --- a/scripts/__dropins__/storefront-account/api/getCustomer/graphql/getCustomer.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/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: string; //# sourceMappingURL=getCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getStoreConfig/getStoreConfig.d.ts b/scripts/__dropins__/storefront-account/api/getStoreConfig/getStoreConfig.d.ts new file mode 100644 index 0000000000..4990b0c91d --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/getStoreConfig/getStoreConfig.d.ts @@ -0,0 +1,4 @@ +import { StoreConfigModel } from '../../data/models'; + +export declare const getStoreConfig: () => Promise; +//# sourceMappingURL=getStoreConfig.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 new file mode 100644 index 0000000000..6af98bcb32 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts @@ -0,0 +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"; +//# sourceMappingURL=getStoreConfig.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getStoreConfig/index.d.ts b/scripts/__dropins__/storefront-account/api/getStoreConfig/index.d.ts new file mode 100644 index 0000000000..572f234893 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/getStoreConfig/index.d.ts @@ -0,0 +1,2 @@ +export * from './getStoreConfig'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/index.d.ts b/scripts/__dropins__/storefront-account/api/index.d.ts index 2583608846..1ccaa1b395 100644 --- a/scripts/__dropins__/storefront-account/api/index.d.ts +++ b/scripts/__dropins__/storefront-account/api/index.d.ts @@ -9,4 +9,8 @@ export * from './updateCustomerAddress'; export * from './getCustomer'; export * from './removeCustomerAddress'; export * from './getOrderHistoryList'; +export * from './updateCustomerPassword'; +export * from './getStoreConfig'; +export * from './updateCustomerEmail'; +export * from './updateCustomer'; //# sourceMappingURL=index.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 new file mode 100644 index 0000000000..5948b580ef --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomer/graphql/updateCustomer.graphql.d.ts @@ -0,0 +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"; +//# sourceMappingURL=updateCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomer/index.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomer/index.d.ts new file mode 100644 index 0000000000..97ce7df967 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomer/index.d.ts @@ -0,0 +1,2 @@ +export * from './updateCustomer'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomer/updateCustomer.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomer/updateCustomer.d.ts new file mode 100644 index 0000000000..e15cf216af --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomer/updateCustomer.d.ts @@ -0,0 +1,2 @@ +export declare const updateCustomer: (form: Record) => Promise; +//# sourceMappingURL=updateCustomer.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 new file mode 100644 index 0000000000..9173e7848c --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts @@ -0,0 +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"; +//# sourceMappingURL=updateCustomerEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerEmail/index.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/index.d.ts new file mode 100644 index 0000000000..a82a653b98 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/index.d.ts @@ -0,0 +1,2 @@ +export * from './updateCustomerEmail'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerEmail/updateCustomerEmail.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/updateCustomerEmail.d.ts new file mode 100644 index 0000000000..3f20a0d45d --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerEmail/updateCustomerEmail.d.ts @@ -0,0 +1,5 @@ +export declare const updateCustomerEmail: ({ email, password, }: { + email: string; + password: string; +}) => Promise; +//# sourceMappingURL=updateCustomerEmail.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 new file mode 100644 index 0000000000..ef98a002c7 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts @@ -0,0 +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"; +//# sourceMappingURL=updateCustomerPassword.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerPassword/index.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/index.d.ts new file mode 100644 index 0000000000..a526c14f61 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/index.d.ts @@ -0,0 +1,2 @@ +export * from './updateCustomerPassword'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/updateCustomerPassword/updateCustomerPassword.d.ts b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/updateCustomerPassword.d.ts new file mode 100644 index 0000000000..84bbb83636 --- /dev/null +++ b/scripts/__dropins__/storefront-account/api/updateCustomerPassword/updateCustomerPassword.d.ts @@ -0,0 +1,4 @@ +import { ChangeCustomerPasswordProps } from '../../types'; + +export declare const updateCustomerPassword: ({ currentPassword, newPassword, }: ChangeCustomerPasswordProps) => Promise; +//# sourceMappingURL=updateCustomerPassword.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/chunks/AddressFormWrapper.js b/scripts/__dropins__/storefront-account/chunks/AddressFormWrapper.js deleted file mode 100644 index 10fb152a90..0000000000 --- a/scripts/__dropins__/storefront-account/chunks/AddressFormWrapper.js +++ /dev/null @@ -1 +0,0 @@ -import{jsx as o,Fragment as oe,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{classes as J,Slot as Ee}from"@dropins/tools/lib.js";import{Field as ie,Picker as qe,Input as Pe,InputDate as We,Checkbox as we,TextArea as je,Card as Le,Skeleton as Se,SkeletonRow as W,Button as de,Tag as fe,Icon as Re,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as De}from"@dropins/tools/components.js";import{useRef as Ye,useState as N,useEffect as Q,useCallback as V,useMemo as Qe}from"@dropins/tools/preact-hooks.js";import{m as et,n as xe,u as Ce,d as He,i as tt,o as rt,l as st,j as nt,k as at,e as ot}from"./removeCustomerAddress.js";import{useText as re}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as _e,useCallback as se,forwardRef as dt,useImperativeHandle as lt,useMemo as Me}from"@dropins/tools/preact-compat.js";import{Fragment as Ne}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const me=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:t,saveCheckBoxValue:a,forwardFormRef:d,slots:l,addressesFormTitle:i,className:c,addressFormId:h,inputsDefaultValueSet:m,billingCheckBoxValue:C,shippingCheckBoxValue:g,showBillingCheckBox:Z,showShippingCheckBox:r,isOpen:L,onSubmit:u,onCloseBtnClick:$,onSuccess:O,onError:E,onChange:F})=>o("div",{className:J(["account-address-form"]),children:o(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:l,addressesFormTitle:i,className:c,addressFormId:h,inputsDefaultValueSet:m,shippingCheckBoxValue:g,billingCheckBoxValue:C,showShippingCheckBox:r,showBillingCheckBox:Z,isOpen:L,onSubmit:u,onCloseBtnClick:$,onSuccess:O,onError:E,onChange:F,forwardFormRef:d,showSaveCheckBox:t,saveCheckBoxValue:a})}),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)),Lt=(e,s,n)=>{const t=new Date(e).getTime()/1e3;return isNaN(t)||t<0?!1:t>=s&&t<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],At=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 t=e.length;return t>=s&&t<=n},ye=(e,s,n,t)=>{var I,B;const{requiredFieldError:a,lengthTextError:d,numericError:l,alphaNumWithSpacesError:i,alphaNumericError:c,alphaError:h,emailError:m,dateError:C,urlError:g,dateLengthError:Z}=n,r=s==null?void 0:s.customUpperCode,L={[r]:""};if(t[r]&&delete t[r],s!=null&&s.required&&!e)return{[r]:a};if(!(s!=null&&s.required)&&!e||!((I=s==null?void 0:s.validateRules)!=null&&I.length))return L;const u=it(s==null?void 0:s.validateRules),$=u.MIN_TEXT_LENGTH??1,O=u.MAX_TEXT_LENGTH??255,E=u.DATE_RANGE_MIN,F=u.DATE_RANGE_MAX;if(!gt(e,+$,+O)&&!(E||F))return{[r]:d.replace("{min}",$).replace("{max}",O)};if(!Lt(e,+E,+F)&&(E||F))return{[r]:Z.replace("{min}",Te(E)).replace("{max}",Te(F))};const R={numeric:{validate:ct,error:l},"alphanum-with-spaces":{validate:ut,error:i},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:h},email:{validate:mt,error:m},date:{validate:ht,error:C},url:{validate:At,error:g}}[u.INPUT_VALIDATION];return R&&!R.validate(e)&&!((B=t[r])!=null&&B.length)?{[r]:R.error}:L},Ve=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:""},Mt=e=>{const s={},n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t],d=t.match(/^(.*)Multiline_(\d+)$/);if(d){const l=d[1],i=parseInt(d[2],10);n[l]||(n[l]=[]),n[l].push({index:i,value:a})}else Object.keys(e).filter(i=>i.startsWith(`${t}Multiline_`)).length>0?n[t]=[{index:1,value:a}]:s[t]=a}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const a=n[t];a.sort((d,l)=>d.index-l.index),s[t]=a.map(d=>d.value)}return s},bt=e=>{const s={},n=[];for(const t in e){const a=yt.includes(e[t])?Ve(e[t]):e[t];Object.prototype.hasOwnProperty.call(e,t)&&(Object.prototype.hasOwnProperty.call(Ct,t)?s[t]=a:n.push({code:xe(t),value:a}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=et(e,"camelCase",{firstname:"firstName",lastname:"lastName"}),t=bt(Mt(n));if(!s)return t;const[a,d]=t.region?t.region.split(","):[];return{...t,region:{regionCode:a,...d&&{regionId:+d}}}},he=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((t,a)=>(a.name&&(t[a.name]=a.type==="checkbox"?a.checked:a.value),t),{})},Ze=(e,s)=>Object.keys(e).every(t=>t in s&&s[t]!==""),ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:t,defaultValue:a})=>(t&&n&&(s.initialData[n]=a||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:t,formName:a,isWaitingForResponse:d})=>{const l=re({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"}),i=Ye(null),[c,h]=N({}),[m,C]=N({}),[g,Z]=N({}),[r,L]=N(!0),[u,$]=N(!1),[O,E]=N(!1),[F,S]=N(!0);Q(()=>{const p=()=>{if(i.current){const v=window.getComputedStyle(i.current).getPropertyValue("grid-template-rows").split(" ").length,w=i.current.querySelector(".account-address-form--saveAddressBook");w&&(w.style.gridRow=String(v-1))}};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[e==null?void 0:e.length]);const R=V((p=!1)=>{let A=!0;const v={...m};let w=null;for(const[x,T]of Object.entries(c)){const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(x)),f=ye(T.toString(),U,l,v);f[x]&&(Object.assign(v,f),A=!1),w||(w=Object.keys(v).find(M=>v[M])||null)}if(p||C(v),w&&i.current&&!p){const x=i.current.elements.namedItem(w);x==null||x.focus()}return A},[m,e,c,l]),I=V((p,A,v,w)=>{const x={...he(i),[A]:p,...A.includes("countryCode")?{region:""}:{}},T={data:ae(x,!0),isDataValid:Ze(v,x)};R(!0),["selectedShippingAddress","selectedBillingAddress"].includes(a)&&sessionStorage.setItem(`${a}_addressData`,JSON.stringify(T)),n==null||n(T,{},w)},[R,a,n]);Q(()=>{if(e!=null&&e.length){const{initialData:p,errorList:A}=vt(e);h(v=>({...p,...v})),C(A),Z(A)}},[JSON.stringify(e)]),Q(()=>{if(O)return;const p=he(i),A=sessionStorage.getItem(`${a}_addressData`);if($e(c)&&$e(g)){let v={};const w=Ze(g,c);A?v=JSON.parse(A).data:v=ae(p,!0)??{},n==null||n({data:v,isDataValid:w},{},null),E(!0)}},[c,g]),Q(()=>{var x;if(!F)return;const p=he(i),A=!!(p!=null&&p.countryCode),v=!!((x=p==null?void 0:p.region)!=null&&x.length);p&&A&&!v&&ze(n)&&!d&&I(p==null?void 0:p.region,"region",g,null)},[F,r,e,i,n,I,g,u,d]);const B=V(p=>{const{name:A,value:v,type:w,checked:x}=p==null?void 0:p.target,T=w==="checkbox"?x:v;h(M=>{const j={...M,[A]:T};return A==="countryCode"&&(j.region="",L(!0),$(!1)),j}),t==null||t({[A]:T}),E(!0);const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(A));let f={...m};if(U){const M=ye(T.toString(),U,l,f);M&&Object.assign(f,M),C(f)}I(T,A,g,p)},[t,e,m,l,I,g,r]),y=V(p=>{const{name:A}=p==null?void 0:p.target,v=e==null?void 0:e.find(w=>w.customUpperCode===A);A==="region"&&(v!=null&&v.options.length)&&S(!1),S(A==="countryCode")},[]),q=V(p=>{const{name:A,value:v,type:w,checked:x}=p==null?void 0:p.target,T=w==="checkbox"?x:v,U=e==null?void 0:e.find(f=>f.customUpperCode===A);if(U){const f={...m},M=ye(T.toString(),U,l,f);M&&Object.assign(f,M),C(f)}},[m,e,l]),z=V(p=>{p.preventDefault();const A=R();s==null||s(p,A)},[R,s]);return{formData:c,errors:m,formRef:i,handleInputChange:B,onFocus:y,handleBlur:q,handleSubmit:z,handleValidationSubmit:R}};var te=(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))(te||{});const _t=_e(({loading:e,values:s,fields:n=[],errors:t,className:a="",onChange:d,onBlur:l,onFocus:i})=>{const c=`${a}__field`,h=se((r,L,u)=>{var O;const $=((O=r.options.find(E=>E.isDefault))==null?void 0:O.value)??L??r.defaultValue;return o(ie,{error:u,className:J([c,`${c}--${r.id}`,[`${c}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${a}--${r.id}`,disabled:e||r.disabled,children:o(qe,{required:r.required,name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,"aria-label":r.label,options:r.options,onBlur:l,onFocus:i,handleSelect:d,defaultValue:$,value:$})},r.id)},[a,e,c,l,d,i]),m=se((r,L,u)=>o(ie,{error:u,className:J([c,`${c}--${r.id}`,[`${c}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${a}--${r.id}`,disabled:e,children:o(Pe,{type:"text",name:r.customUpperCode,value:L??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:l,onFocus:i,onChange:d})},r.id),[a,e,c,l,d,i]),C=se((r,L,u)=>o(ie,{error:u,className:J([c,`${c}--${r.id}`,[`${c}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${a}--${r.id}`,disabled:e||r.disabled,children:o(We,{type:"text",name:r.customUpperCode,value:L||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:l,onChange:d,disabled:e||r.disabled})},r.id),[a,e,c,l,d]),g=se((r,L,u)=>o(ie,{error:u,className:J([c,`${c}--${r.id}`,[`${c}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${a}--${r.id}`,disabled:e,children:o(we,{name:r.customUpperCode,checked:L||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:l,onChange:d})},r.id),[a,e,c,l,d]),Z=se((r,L,u)=>o(ie,{error:u,className:J([c,`${c}--${r.id}`,[`${c}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${a}--${r.id}`,disabled:e,children:o(je,{type:"text",name:r.customUpperCode,value:L??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:l,onChange:d})},r.id),[a,e,c,l,d]);return n.length?o(oe,{children:n.map(r=>{const L=t==null?void 0:t[r.customUpperCode],u=s==null?void 0:s[r.customUpperCode];switch(r.fieldType){case te.TEXT:return r.options.length?h(r,u,L):m(r,u,L);case te.MULTILINE:return m(r,u,L);case te.SELECT:return h(r,u,L);case te.DATE:return C(r,u,L);case te.BOOLEAN:return g(r,u,L);case te.TEXTAREA:return Z(r,u,L);default:return null}})}):null}),Be=({testId:e,withCard:s=!0})=>{const n=k(Se,{"data-testid":e||"skeletonLoader",children:[o(W,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:o(Le,{variant:"secondary",className:J(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>k(Se,{"data-testid":"addressFormLoader",children:[o(W,{variant:"heading",size:"medium"}),o(W,{variant:"empty",size:"medium"}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large",fullWidth:!0}),o(W,{size:"large",fullWidth:!0,lines:3}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large"}),o(W,{size:"large",fullWidth:!0})]}),Tt=_e(dt(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:t,name:a,loading:d,children:l,className:i="defaultForm",fieldsConfig:c,onSubmit:h,onChange:m,forwardFormRef:C,regionOptions:g,showSaveCheckBox:Z,handleSaveCheckBoxAddress:r,saveCheckBoxAddress:L})=>{const u=re({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{formData:$,errors:O,formRef:E,handleInputChange:F,handleBlur:S,handleSubmit:R,handleValidationSubmit:I,onFocus:B}=Et({fieldsConfig:c,onSubmit:h,onChange:m,setInputChange:s,regionOptions:g,formName:a,isWaitingForResponse:e});return lt(C,()=>{const y=he(E);return{handleValidationSubmit:I,formData:ae(y,!0)}}),n||!(c!=null&&c.length)?o(Nt,{}):k("form",{className:J(["account-form",i]),onSubmit:R,name:a,ref:E,children:[o(_t,{className:i,loading:d,fields:c,onChange:F,onBlur:S,errors:O,values:$,onFocus:B}),t!=null&&t.AddressFormInputs?o(Ee,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:F}}}):null,Z?o("div",{className:"account-address-form--saveAddressBook",children:o(we,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:u.saveAddressBook,checked:L,onChange:y=>{F(y),r==null||r(y)}})}):null,l]})})),be=({slots:e,selectable:s,selectShipping:n,selectBilling:t,variant:a="secondary",minifiedView:d,keysSortOrder:l,addressData:i,loading:c,setAddressId:h,handleRenderModal:m,handleRenderForm:C})=>{const g=d?"minifiedView":"fullSizeView",Z=re({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`}),r=Z.cardLabelBilling.toLocaleUpperCase(),L=Z.cardLabelShipping.toLocaleUpperCase(),u=Z.defaultLabelText.toLocaleUpperCase(),$=Me(()=>{const y={shippingLabel:L,billingLabel:r,hideShipping:!1,hideBilling:!1};return s?n&&!t?{shippingLabel:u,billingLabel:u,hideShipping:!1,hideBilling:!0}:t&&!n?{shippingLabel:u,billingLabel:u,hideShipping:!0,hideBilling:!1}:y:y},[r,u,L,t,n,s]),O=se(()=>{h==null||h(i==null?void 0:i.id),m==null||m()},[m,i==null?void 0:i.id,h]),E=se(()=>{h==null||h(i==null?void 0:i.id),C==null||C()},[C,i==null?void 0:i.id,h]),F=Me(()=>{if(!l)return[];const{region:y,...q}=i,z={...q,...y};return l.filter(({name:p})=>z[p]).map(p=>({name:p.name,orderNumber:p.orderNumber,value:z[p.name],label:p.label}))},[i,l]),{shippingLabel:S,billingLabel:R,hideShipping:I,hideBilling:B}=$;return o(Le,{variant:a,className:"account-address-card","data-testid":"addressCard",children:c?o(Be,{}):k(oe,{children:[k("div",{className:"account-address-card__action",children:[m?o(de,{type:"button",variant:"tertiary",onClick:O,"data-testid":"removeButton",children:Z.actionRemove}):null,C?o(de,{type:"button",variant:"tertiary",onClick:E,className:"account-address-card__action--editbutton","data-testid":"editButton",children:Z.actionEdit}):null]}),o("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?o(Ee,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:F}}):o(oe,{children:F.map((y,q)=>{const z=y.label?`${y.label}: ${y==null?void 0:y.value}`:y==null?void 0:y.value;return o("p",{"data-testid":`${y.name}_${q}`,children:z},q)})})}),(i!=null&&i.defaultShipping||i!=null&&i.defaultBilling)&&!s?k("div",{className:"account-address-card__labels",children:[i!=null&&i.defaultShipping?o(fe,{label:L}):null,i!=null&&i.defaultBilling?o(fe,{label:r}):null]}):null,s?k("div",{className:"account-address-card__labels",children:[!I&&(i!=null&&i.defaultShipping)?o(fe,{label:S}):null,!B&&(i!=null&&i.defaultBilling)?o(fe,{label:R}):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"})),It=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:t,routeAddressesPage:a})=>{const d=t?"minifiedView":"fullSizeView",l=re({viewAllAddressesButton:`Account.${d}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${d}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${d}.Addresses.differentAddressButton`}),i=t&&!n?l.viewAllAddressesButton:l.addNewAddressButton,c=e?l.differentAddressButton:i;return k("button",{type:"button",className:J(["account-actions-address",["account-actions-address--viewall",t],["account-actions-address--address",!t],s]),"data-testid":"showRouteFullAddress",onClick:a,children:[o("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:c}),o(Re,{source:t&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:t,submitLoading:a,onRemoveAddress:d,closeModal:l})=>{const i=e?"minifiedView":"fullSizeView",c=re({title:`Account.${i}.Addresses.removeAddressModal.title`,description:`Account.${i}.Addresses.removeAddressModal.description`,actionCancel:`Account.${i}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${i}.Addresses.removeAddressModal.actionConfirm`});return t?k(Ge,{title:o("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:l,children:[a?o("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:o(Ke,{stroke:"4",size:"large"})}):null,o("p",{children:c.description}),o(be,{minifiedView:e,addressData:n,keysSortOrder:s}),k("div",{className:"account-address-modal__buttons",children:[o(de,{type:"button",onClick:l,variant:"secondary",disabled:a,children:c.actionCancel}),o(de,{disabled:a,onClick:d,children:c.actionConfirm})]})]}):null},wt=({typeList:e,isEmpty:s,minifiedView:n,className:t})=>{const a=n?"minifiedView":"fullSizeView",d=re({addressesMessage:`Account.${a}.EmptyList.Addresses.message`,ordersListMessage:`Account.${a}.EmptyList.OrdersList.message`}),l=Me(()=>{switch(e){case"address":return{icon:Ft,text:o("p",{children:d.addressesMessage})};case"orders":return{icon:It,text:o("p",{children:d.ordersListMessage})};default:return{icon:"",text:""}}},[e,d]);return!s||!e||!l.text?null:o(Je,{className:J(["account-empty-list",n?"account-empty-list--minified":"",t]),message:l.text,icon:o(Re,{source:l.icon}),"data-testid":"emptyList"})},St=async(e,s)=>{if(s.length===1){const l=s[0],c=Object.values(l.region).every(m=>!!m)?{}:{region:{...l.region,regionId:0}};return!!await Ce({addressId:Number(l==null?void 0:l.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(l=>l.id!==e&&(l.defaultBilling||l.defaultShipping)||l.id!==e),t=s[s.length-1],a=n[0]||((t==null?void 0:t.id)!==e?t:null);return!a||!a.id?!1:!!await Ce({addressId:+a.id,defaultShipping:!0,defaultBilling:!0})},Rt=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing"],Ue=(e,s,n)=>{if(s&&n||!s&&!n)return e;const t=e.slice();return s?t.sort((a,d)=>Number(d.defaultShipping)-Number(a.defaultShipping)):n?t.sort((a,d)=>Number(d.defaultBilling)-Number(a.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),xt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:t,minifiedView:a,routeAddressesPage:d,onSuccess:l})=>{const[i,c]=N(""),[h,m]=N(!1),[C,g]=N(!1),[Z,r]=N(!1),[L,u]=N(!1),[$,O]=N(!1),[E,F]=N(""),[S,R]=N([]),[I,B]=N([]),y=V(async()=>{r(!0),Promise.all([He("shortRequest"),tt()]).then(f=>{const[M,j]=f;if(M){const X=M.map(({name:D,orderNumber:ne,label:ee})=>({name:rt(D),orderNumber:ne,label:Rt.includes(D)?null:ee}));B(X)}if(j)if(a){const X=j.filter(D=>!!D.defaultShipping||!!D.defaultBilling);R(X)}else R(j)}).finally(()=>{r(!1)})},[a]);Q(()=>{y()},[y]),Q(()=>{var f;if(S.length)if(n===0)O(!0),c("0");else{const M=S.find(X=>+X.id===n)||Ue(S,e,s)[0],j={data:ae(M),isDataValid:!ve(M)};c(n.toString()||((f=M==null?void 0:M.id)==null?void 0:f.toString())),t==null||t(j)}},[S,n,t,s,e]);const q=V(f=>{F(f),O(!1)},[]),z=V((f,M)=>{const j=(f==null?void 0:f.target).value;c(j);const X={data:ae(M),isDataValid:!ve(ae(M))};t==null||t(X),j!=="0"&&O(!1)},[t]),p=V(()=>{g(!0)},[]),A=V(()=>{F(""),g(!1),m(!1)},[]),v=V(()=>{m(!0)},[]),w=V(async()=>{u(!0),await St(E,S),st(+E).then(()=>{y(),A()}).finally(()=>{u(!1)})},[S,E,A,y]),x=V(()=>{O(!1)},[]),T=V(()=>{ze(d)&&a&&!$?window.location.href=d():(O(!0),F(""))},[$,d,a]),U=V(async()=>{await y(),await(l==null?void 0:l())},[y,l]);return{keysSortOrder:I,submitLoading:L,isModalRendered:h,isFormRendered:C,loading:Z,addNewAddress:$,addressesList:S,addressId:E,handleRenderForm:p,handleRenderModal:v,removeAddress:w,onCloseBtnClick:A,setEditingAddressId:q,closeNewAddressForm:x,redirectToAddressesRoute:T,handleOnSuccess:U,handleSelectAddressOption:z,selectedAddressOption:i}},t1=_e(({hideActionFormButtons:e=!1,formName:s,slots:n,title:t="",addressFormTitle:a="",defaultSelectAddressId:d="",showFormLoader:l=!1,onAddressData:i,forwardFormRef:c,className:h,showSaveCheckBox:m=!1,saveCheckBoxValue:C=!1,selectShipping:g=!1,selectBilling:Z=!1,selectable:r=!1,withHeader:L=!0,minifiedView:u=!1,withActionsInMinifiedView:$=!1,withActionsInFullSizeView:O=!0,inputsDefaultValueSet:E,showShippingCheckBox:F=!0,showBillingCheckBox:S=!0,shippingCheckBoxValue:R=!0,billingCheckBoxValue:I=!0,routeAddressesPage:B,onSuccess:y,onError:q})=>{var K;const z=u?"minifiedView":"fullSizeView",p=re({containerTitle:`Account.${z}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${z}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${z}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${z}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${z}.Addresses.newAddressFormTitle`}),{keysSortOrder:A,submitLoading:v,isModalRendered:w,isFormRendered:x,loading:T,addNewAddress:U,addressesList:f,addressId:M,handleRenderForm:j,handleRenderModal:X,removeAddress:D,onCloseBtnClick:ne,handleOnSuccess:ee,setEditingAddressId:Ae,closeNewAddressForm:le,redirectToAddressesRoute:ce,handleSelectAddressOption:ue,selectedAddressOption:pe}=xt({defaultSelectAddressId:d,minifiedView:u,routeAddressesPage:B,onSuccess:y,onAddressData:i,selectShipping:g,selectBilling:Z}),H=s??(g&&Z?"selectedAddress":g?"selectedShippingAddress":Z?"selectedBillingAddress":"default"),P=r?k("div",{className:"account-addresses-wrapper--select-view",children:[(K=Ue(f,g,Z))==null?void 0:K.map((b,Y)=>k(Ne,{children:[o("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:H,id:`${H}_${b.id}`,value:b.id,checked:pe===(b==null?void 0:b.id.toString()),onChange:ge=>ue(ge,b)}),o("label",{htmlFor:`${H}_${b.id}`,className:"account-addresses-wrapper__label",children:o(be,{slots:n,selectable:r,selectShipping:g,selectBilling:Z,minifiedView:u,addressData:b,keysSortOrder:A,loading:T})})]},b.id)),o("input",{"data-testid":"radio-0",type:"radio",name:H,id:`${H}_addressActions`,value:"0",checked:pe==="0",onChange:b=>ue(b,{})}),o("label",{htmlFor:`${H}_addressActions`,className:"account-addresses-wrapper__label",children:U?o("div",{className:J(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",U]]),children:o(me,{hideActionFormButtons:e,formName:H,showFormLoader:l,isOpen:U,forwardFormRef:c,showSaveCheckBox:m,saveCheckBoxValue:C,shippingCheckBoxValue:R,billingCheckBoxValue:I,addressesFormTitle:a||p.differentAddressFormTitle,inputsDefaultValueSet:E,showShippingCheckBox:F,showBillingCheckBox:S,onCloseBtnClick:le,onSuccess:ee,onError:q,onChange:i})}):f!=null&&f.length?o(Fe,{selectable:r,minifiedView:u,addNewAddress:U,routeAddressesPage:ce}):null})]}):k(oe,{children:[f.map(b=>o(Ne,{children:M===b.id&&x?o(Le,{variant:"secondary",style:{marginBottom:20},children:o(me,{isOpen:M===b.id&&x,addressFormId:M,inputsDefaultValueSet:b,addressesFormTitle:p.editAddressFormTitle,showShippingCheckBox:F,showBillingCheckBox:S,shippingCheckBoxValue:R,billingCheckBoxValue:I,onCloseBtnClick:ne,onSuccess:ee,onError:q})}):o(be,{slots:n,minifiedView:u,addressData:b,keysSortOrder:A,loading:T,setAddressId:Ae,handleRenderModal:u&&$||!u&&O?X:void 0,handleRenderForm:u&&$||!u&&O?j:void 0},b.id)},b.id)),o("div",{className:"account-addresses__footer",children:U?o(Le,{variant:"secondary",children:o(me,{isOpen:U,addressesFormTitle:p.newAddressFormTitle,inputsDefaultValueSet:E,showShippingCheckBox:!!(f!=null&&f.length),showBillingCheckBox:!!(f!=null&&f.length),shippingCheckBoxValue:R,billingCheckBoxValue:I,onCloseBtnClick:le,onSuccess:ee,onError:q})}):o(Fe,{minifiedView:u,addNewAddress:U,routeAddressesPage:ce})})]});return k("div",{children:[o("div",{children:L?o(Xe,{title:t||p.containerTitle,divider:!u,className:u?"account-addresses-header":""}):null}),k("div",{className:J(["account-addresses-wrapper",h]),"data-testid":"addressesIdWrapper",children:[o(Ot,{minifiedView:u,addressData:f==null?void 0:f.find(b=>b.id===M),keysSortOrder:A,submitLoading:v,open:w,closeModal:ne,onRemoveAddress:D}),T?o(Be,{testId:"addressSkeletonLoader",withCard:!1}):r?o(me,{hideActionFormButtons:e,formName:H,isOpen:!(f!=null&&f.length),forwardFormRef:c,showSaveCheckBox:m,saveCheckBoxValue:C,shippingCheckBoxValue:R,billingCheckBoxValue:I,inputsDefaultValueSet:E,showShippingCheckBox:F,showBillingCheckBox:S,onCloseBtnClick:le,onSuccess:ee,onError:q,onChange:i}):o(wt,{isEmpty:!(f!=null&&f.length),typeList:"address",minifiedView:u}),P]})]})}),ke={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:te.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Ht={...ke,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Vt={...ke,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},zt=(e,s)=>s==null?void 0:s.map(n=>{const t={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName},a=JSON.parse(JSON.stringify(n));if(Object.hasOwn(t,n.customUpperCode)){const d=t[n.customUpperCode];n.customUpperCode==="region"&&typeof d=="object"?a.defaultValue=d.regionCode&&d.regionId?`${d.regionCode},${d.regionId}`:d.region??d.regionCode:a.defaultValue=d}return a}),Ie=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(t=>{s.has(t.name)||s.set(t.name,"false"),t.checked&&s.set(t.name,"true")}),s&&typeof s.entries=="function"){const t=s.entries();if(t&&typeof t[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(t)))||{}}return{}},Bt=({fields:e,addressId:s,countryOptions:n,disableField:t,regionOptions:a,isRequiredRegion:d,isRequiredPostCode:l})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:t}:c.customUpperCode==="postcode"?{...c,required:l}:c.customUpperCode==="region"?{...c,options:a,required:d,disabled:t}: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"],t={},a=[];return Object.keys(e).forEach(d=>{n.includes(d)?t[d]=e[d]:a.push({attribute_code:xe(d),value:e[d]})}),a.length>0&&(t.custom_attributesV2=a),t},Oe=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],t=[],a={};for(const r in e){const L=e[r];n.includes(L)&&(a[r]=Ve(L)),s.includes(r)&&t.push(L)}const{street:d,streetMultiline_2:l,streetMultiline_1:i,region:c,...h}=e,[m,C]=c?c.split(","):[void 0,void 0],g=C&&m?{regionId:+C,regionCode:m}:{region:m};return Ut({...h,...a,region:{...g},street:t})},kt=(e,s)=>{const n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];if(t==="region"&&a.regionId){const d=s.find(l=>(l==null?void 0:l.id)===a.regionId);d?n[t]={...a,text:d.text}:n[t]=a}else Array.isArray(a)?(n[t]=a[0]||"",a.slice(1).forEach((d,l)=>{n[`${t}Multiline_${l+2}`]=d})):n[t]=a}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:t,billingCheckBoxValue:a,shippingCheckBoxValue:d,showShippingCheckBox:l,showBillingCheckBox:i,inputsDefaultValueSet:c,onCloseBtnClick:h,onSuccess:m,onError:C,formName:g})=>{const[Z,r]=N({text:"",type:"success"}),[L,u]=N(e??!1),[$,O]=N(t||""),[E,F]=N([]),[S,R]=N([]),[I,B]=N([]),[y,q]=N([]),[z,p]=N([]),[A,v]=N(!1),[w,x]=N(!1),[T,U]=N(()=>{var H,P;const _=sessionStorage.getItem(`${g}_addressData`);return _?{countryCode:(P=(H=JSON.parse(_))==null?void 0:H.data)==null?void 0:P.countryCode}:c}),[f,M]=N(!1),[j,X]=N(!1),[D,ne]=N(()=>{var P,K;const _=sessionStorage.getItem(`${g}_addressData`);return _?(K=(P=JSON.parse(_))==null?void 0:P.data)==null?void 0:K.saveAddressBook:n}),ee=V(_=>{ne(_.target.checked)},[]);Q(()=>{He($?"customer_address_edit":"customer_register_address").then(_=>{F(_)})},[$]),Q(()=>{M(!0),nt().then(({availableCountries:_,countriesWithRequiredRegion:H,optionalZipCountries:P})=>{R(_),q(H),p(P),M(!1)})},[]),Q(()=>{if(T!=null&&T.countryCode){M(!0),X(!0);const _=T==null?void 0:T.countryCode;at(_).then(H=>{B(H);const P=y.find(b=>b===_),K=z.find(b=>b===_);v(!!P),x(!K),M(!1),X(!1)})}},[T==null?void 0:T.countryCode,y,z]);const Ae=V(()=>{r({text:"",type:"success"}),h==null||h()},[h]),le=V(async(_,H)=>{if(!H)return null;u(!0);const P=Ie(_.target),K=Oe(P);await Ce(K).then(()=>{var b;m==null||m(),h==null||h(),(b=_==null?void 0:_.target)==null||b.reset()}).catch(b=>{r(Y=>({...Y,text:b.message,type:"error"})),C==null||C(b)}).finally(()=>{O(""),u(!1)})},[h,C,m]),ce=V(async(_,H)=>{if(!H)return;u(!0);const{saveAddressBook:P,...K}=Ie(_.target),b=Oe(K);await ot(b).then(()=>{var Y;m==null||m(),h==null||h(),(Y=_==null?void 0:_.target)==null||Y.reset()}).catch(Y=>{r(ge=>({...ge,text:Y.message,type:"error"})),C==null||C(Y)}).finally(()=>{O(""),u(!1)})},[h,C,m]),ue=Qe(()=>{if(!E.length)return[];const _={...Ht,defaultValue:d,isHidden:s&&!D?!0:!l},H={...Vt,defaultValue:a,isHidden:s&&!D?!0:!i},P=[...E,_,H],K=sessionStorage.getItem(`${g}_addressData`),b=K?kt(JSON.parse(K).data,I):{},Y=zt(qt(b,c),P);return Bt({fields:Y,addressId:$,countryOptions:S,disableField:f,regionOptions:I,isRequiredRegion:A,isRequiredPostCode:w})},[E,d,s,D,l,a,i,g,I,c,$,S,f,A,w]),pe=V(_=>{U(H=>({...H,..._}))},[]);return{isWaitingForResponse:j,regionOptions:I,saveCheckBoxAddress:D,inLineAlert:Z,addressId:$,submitLoading:L,normalizeFieldsConfig:ue,handleSaveCheckBoxAddress:ee,handleUpdateAddress:le,handleCreateAddress:ce,handleOnCloseForm:Ae,handleInputChange:pe}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:t=!1,saveCheckBoxValue:a=!1,forwardFormRef:d,slots:l,addressesFormTitle:i,className:c,addressFormId:h,inputsDefaultValueSet:m,showShippingCheckBox:C=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:Z=!0,billingCheckBoxValue:r=!0,isOpen:L,onSubmit:u,onCloseBtnClick:$,onSuccess:O,onError:E,onChange:F})=>{const S=re({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:R,inLineAlert:I,addressId:B,submitLoading:y,normalizeFieldsConfig:q,handleUpdateAddress:z,handleCreateAddress:p,handleOnCloseForm:A,handleSaveCheckBoxAddress:v,saveCheckBoxAddress:w,handleInputChange:x,regionOptions:T}=Pt({showFormLoader:n,addressFormId:h,inputsDefaultValueSet:m,shippingCheckBoxValue:Z,billingCheckBoxValue:r,showShippingCheckBox:C,showBillingCheckBox:g,saveCheckBoxValue:a,showSaveCheckBox:t,onSuccess:O,onError:E,onCloseBtnClick:$,formName:s});return L?k("div",{className:J(["account-address-form-wrapper",c]),children:[i?o("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:i}):null,I.text?o(De,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:I.type,variant:"secondary",heading:I.text,icon:I.icon}):null,k(Tt,{regionOptions:T,forwardFormRef:d,slots:l,className:"account-address-form",name:s||"addressesForm",fieldsConfig:q,onSubmit:u||(B?z:p),setInputChange:x,loading:y,showFormLoader:n,showSaveCheckBox:t,handleSaveCheckBoxAddress:v,saveCheckBoxAddress:w,onChange:F,isWaitingForResponse:R,children:[B?o("input",{type:"hidden",name:"addressId",value:B,"data-testid":"hidden_test_id"}):null,e?null:o("div",{className:J(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",t]]),children:l!=null&&l.AddressFormActions?o(Ee,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:l.AddressFormActions,context:{handleUpdateAddress:z,handleCreateAddress:p,addressId:B}}):o(oe,{children:t?null:k(oe,{children:[o(de,{type:"button",onClick:A,variant:"secondary",disabled:y,children:S.secondaryButton}),o(de,{disabled:y,children:S.primaryButton})]})})})]})]}):null};export{me as A,Be as C,wt as E,$t as S,t1 as a,ze as c}; diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js new file mode 100644 index 0000000000..34989f980b --- /dev/null +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -0,0 +1 @@ +import{jsx as a,Fragment as Q,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{classes as J,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 W,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as De}from"@dropins/tools/components.js";import{useRef as Ye,useState as Z,useEffect as ee,useCallback as V,useMemo as Qe}from"@dropins/tools/preact-hooks.js";import{k as et,o as Re,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 se}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 _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:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,billingCheckBoxValue:C,shippingCheckBoxValue:y,showBillingCheckBox:F,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N})=>a("div",{className:J(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,shippingCheckBoxValue:y,billingCheckBoxValue:C,showShippingCheckBox:L,showBillingCheckBox:F,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N,forwardFormRef:l,showSaveCheckBox:r,saveCheckBoxValue:d})}),ct=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),it=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 O,z;const{requiredFieldError:d,lengthTextError:l,numericError:c,alphaNumWithSpacesError:o,alphaNumericError:i,alphaError:u,emailError:f,dateError:C,urlError:y,dateLengthError:F}=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||!((O=s==null?void 0:s.validateRules)!=null&&O.length))return x;const t=ct(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,m=t.MAX_TEXT_LENGTH??255,_=t.DATE_RANGE_MIN,N=t.DATE_RANGE_MAX;if(!gt(e,+A,+m)&&!(_||N))return{[L]:l.replace("{min}",A).replace("{max}",m)};if(!At(e,+_,+N)&&(_||N))return{[L]:F.replace("{min}",Te(_)).replace("{max}",Te(N))};const S={numeric:{validate:it,error:c},"alphanum-with-spaces":{validate:ut,error:o},alphanumeric:{validate:pt,error:i},alpha:{validate:ft,error:u},email:{validate:mt,error:f},date:{validate:ht,error:C},url:{validate:Lt,error:y}}[t.INPUT_VALIDATION];return S&&!S.validate(e)&&!((z=r[L])!=null&&z.length)?{[L]:S.error}:x},Ve=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 c=l[1],o=parseInt(l[2],10);n[c]||(n[c]=[]),n[c].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,c)=>l.index-c.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])?Ve(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 c=se({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),[i,u]=Z({}),[f,C]=Z({}),[y,F]=Z({}),[L,x]=Z(!0),[t,A]=Z(!1),[m,_]=Z(!1),[N,I]=Z(!0);ee(()=>{const p=()=>{if(o.current){const E=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,w=o.current.querySelector(".account-address-form--saveAddressBook");w&&(w.style.gridRow=String(E-1))}};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[e==null?void 0:e.length]);const S=V((p=!1)=>{let g=!0;const E={...f};let w=null;for(const[R,$]of Object.entries(i)){const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(R)),h=ye($.toString(),U,c,E);h[R]&&(Object.assign(E,h),g=!1),w||(w=Object.keys(E).find(M=>E[M])||null)}if(p||C(E),w&&o.current&&!p){const R=o.current.elements.namedItem(w);R==null||R.focus()}return g},[f,e,i,c]),O=V((p,g,E,w)=>{const R={...me(o),[g]:p,...g.includes("countryCode")?{region:""}:{}},$={data:ae(R,!0),isDataValid:Ze(E,R)};S(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify($)),n==null||n($,{},w)},[S,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:p,errorList:g}=vt(e);u(E=>({...p,...E})),C(g),F(g)}},[JSON.stringify(e)]),ee(()=>{if(m)return;const p=me(o),g=sessionStorage.getItem(`${d}_addressData`);if($e(i)&&$e(y)){let E={};const w=Ze(y,i);g?E=JSON.parse(g).data:E=ae(p,!0)??{},n==null||n({data:E,isDataValid:w},{},null),_(!0)}},[i,y]),ee(()=>{var R;if(!N)return;const p=me(o),g=!!(p!=null&&p.countryCode),E=!!((R=p==null?void 0:p.region)!=null&&R.length);p&&g&&!E&&Be(n)&&!l&&O(p==null?void 0:p.region,"region",y,null)},[N,L,e,o,n,O,y,t,l]);const z=V(p=>{const{name:g,value:E,type:w,checked:R}=p==null?void 0:p.target,$=w==="checkbox"?R:E;u(M=>{const j={...M,[g]:$};return g==="countryCode"&&(j.region="",x(!0),A(!1)),j}),r==null||r({[g]:$}),_(!0);const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(g));let h={...f};if(U){const M=ye($.toString(),U,c,h);M&&Object.assign(h,M),C(h)}O($,g,y,p)},[r,e,f,c,O,y,L]),b=V(p=>{const{name:g}=p==null?void 0:p.target,E=e==null?void 0:e.find(w=>w.customUpperCode===g);g==="region"&&(E!=null&&E.options.length)&&I(!1),I(g==="countryCode")},[]),q=V(p=>{const{name:g,value:E,type:w,checked:R}=p==null?void 0:p.target,$=w==="checkbox"?R:E,U=e==null?void 0:e.find(h=>h.customUpperCode===g);if(U){const h={...f},M=ye($.toString(),U,c,h);M&&Object.assign(h,M),C(h)}},[f,e,c]),B=V(p=>{p.preventDefault();const g=S();s==null||s(p,g)},[S,s]);return{formData:i,errors:f,formRef:o,handleInputChange:z,onFocus:b,handleBlur:q,handleSubmit:B,handleValidationSubmit:S}};var re=(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))(re||{});const _t=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:l,onBlur:c,onFocus:o,slots:i})=>{const u=`${d}__field`,f=(t,A)=>{if(!(i!=null&&i[`AddressFormInput_${t.code}`]))return;const m={inputName:t.customUpperCode,handleOnChange:l,handleOnBlur:c,handleOnFocus:o,errorMessage:A,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:i[`AddressFormInput_${t.code}`],context:m})},C=(t,A,m)=>{var N;const _=((N=t.options.find(I=>I.isDefault))==null?void 0:N.value)??A??t.defaultValue;return a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:c,onFocus:o,handleSelect:l,defaultValue:_,value:_})},t.id)})},y=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onFocus:o,onChange:l})},t.id)}),F=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:c,onChange:l,disabled:e||t.disabled})},t.id)}),L=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:c,onChange:l})},t.id)}),x=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:l})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],m=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case re.TEXT:return t.options.length?C(t,m,A):y(t,m,A);case re.MULTILINE:return y(t,m,A);case re.SELECT:return C(t,m,A);case re.DATE:return F(t,m,A);case re.BOOLEAN:return L(t,m,A);case re.TEXTAREA:return x(t,m,A);default:return null}})}):null}),ze=({testId:e,withCard:s=!0})=>{const n=k(we,{"data-testid":e||"skeletonLoader",children:[a(W,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:J(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>k(we,{"data-testid":"addressFormLoader",children:[a(W,{variant:"heading",size:"medium"}),a(W,{variant:"empty",size:"medium"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large",fullWidth:!0}),a(W,{size:"large",fullWidth:!0,lines:3}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:l,children:c,className:o="defaultForm",fieldsConfig:i,onSubmit:u,onChange:f,forwardFormRef:C,regionOptions:y,showSaveCheckBox:F,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=se({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{formData:A,errors:m,formRef:_,handleInputChange:N,handleBlur:I,handleSubmit:S,handleValidationSubmit:O,onFocus:z}=Et({fieldsConfig:i,onSubmit:u,onChange:f,setInputChange:s,regionOptions:y,formName:d,isWaitingForResponse:e});return lt(C,()=>{const b=me(_);return{handleValidationSubmit:O,formData:ae(b,!0)}}),n||!(i!=null&&i.length)?a(Nt,{}):k("form",{className:J(["account-form",o]),onSubmit:S,name:d,ref:_,children:[a(_t,{className:o,loading:l,fields:i,onChange:N,onBlur:I,errors:m,values:A,onFocus:z,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:N}}}):null,F?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:b=>{N(b),L==null||L(b)}})}):null,c]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:l,keysSortOrder:c,addressData:o,loading:i,setAddressId:u,handleRenderModal:f,handleRenderForm:C})=>{const y=l?"minifiedView":"fullSizeView",F=se({actionRemove:`Account.${y}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${y}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${y}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${y}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${y}.Addresses.addressCard.defaultLabelText`}),L=F.cardLabelBilling.toLocaleUpperCase(),x=F.cardLabelShipping.toLocaleUpperCase(),t=F.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const b={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}:b:b},[L,t,x,r,n,s]),m=_e(()=>{u==null||u(o==null?void 0:o.id),f==null||f()},[f,o==null?void 0:o.id,u]),_=_e(()=>{u==null||u(o==null?void 0:o.id),C==null||C()},[C,o==null?void 0:o.id,u]),N=be(()=>{if(!c)return[];const{region:b,...q}=o,B={...q,...b};return c.filter(({name:p})=>B[p]).map(p=>({name:p.name,orderNumber:p.orderNumber,value:B[p.name],label:p.label}))},[o,c]),{shippingLabel:I,billingLabel:S,hideShipping:O,hideBilling:z}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:i?a(ze,{}):k(Q,{children:[k("div",{className:"account-address-card__action",children:[f?a(de,{type:"button",variant:"tertiary",onClick:m,"data-testid":"removeButton",children:F.actionRemove}):null,C?a(de,{type:"button",variant:"tertiary",onClick:_,className:"account-address-card__action--editbutton","data-testid":"editButton",children:F.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:N}}):a(Q,{children:N.map((b,q)=>{const B=b.label?`${b.label}: ${b==null?void 0:b.value}`:b==null?void 0:b.value;return a("p",{"data-testid":`${b.name}_${q}`,children:B},q)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?k("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?k("div",{className:"account-address-card__labels",children:[!O&&(o!=null&&o.defaultShipping)?a(pe,{label:I}):null,!z&&(o!=null&&o.defaultBilling)?a(pe,{label:S}):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"})),It=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 l=r?"minifiedView":"fullSizeView",c=se({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",i=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?c.viewAllAddressesButton:c.addNewAddressButton,f=e?c.differentAddressButton:u;return k(o,{...i,className:J(["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:f}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:l,closeModal:c})=>{const o=e?"minifiedView":"fullSizeView",i=se({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?k(Ge,{title:a("h3",{children:i.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:c,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:i.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),k("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:c,variant:"secondary",disabled:d,children:i.actionCancel}),a(de,{disabled:d,onClick:l,children:i.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",l=se({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),c=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||!c.text?null:a(Je,{className:J(["account-empty-list",n?"account-empty-list--minified":"",r]),message:c.text,icon:a(Se,{source:c.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const c=s[0],i=Object.values(c.region).every(f=>!!f)?{}:{region:{...c.region,regionId:0}};return!!await Ce({addressId:Number(c==null?void 0:c.id),defaultShipping:!1,defaultBilling:!1,...i})}const n=s.filter(c=>c.id!==e&&(c.defaultBilling||c.defaultShipping)||c.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:c})=>{const[o,i]=Z(""),[u,f]=Z(!1),[C,y]=Z(!1),[F,L]=Z(!1),[x,t]=Z(!1),[A,m]=Z(!1),[_,N]=Z(""),[I,S]=Z([]),[O,z]=Z([]),b=V(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(h=>{const[M,j]=h;if(M){const X=M.map(({name:D,orderNumber:ne,label:te})=>({name:rt(D),orderNumber:ne,label:St.includes(D)?null:te}));z(X)}if(j)if(d){const X=j.filter(D=>!!D.defaultShipping||!!D.defaultBilling);S(X)}else S(j)}).finally(()=>{L(!1)})},[d]);ee(()=>{b()},[b]),ee(()=>{var h;if(I.length)if(n===0)m(!0),i("0");else{const M=I.find(X=>+X.id===n)||Ue(I,e,s)[0],j={data:ae(M),isDataValid:!ve(M)};i(n.toString()||((h=M==null?void 0:M.id)==null?void 0:h.toString())),r==null||r(j)}},[I,n,r,s,e]);const q=V(h=>{N(h),m(!1)},[]),B=V((h,M)=>{const j=(h==null?void 0:h.target).value;i(j);const X={data:ae(M),isDataValid:!ve(ae(M))};r==null||r(X),j!=="0"&&m(!1)},[r]),p=V(()=>{y(!0)},[]),g=V(()=>{N(""),y(!1),f(!1)},[]),E=V(()=>{f(!0)},[]),w=V(async()=>{t(!0),await wt(_,I),st(+_).then(()=>{b(),g()}).finally(()=>{t(!1)})},[I,_,g,b]),R=V(()=>{m(!1)},[]),$=V(()=>{Be(l)&&d&&!A?window.location.href=l():(m(!0),N(""))},[A,l,d]),U=V(async()=>{await b(),await(c==null?void 0:c())},[b,c]);return{keysSortOrder:O,submitLoading:x,isModalRendered:u,isFormRendered:C,loading:F,addNewAddress:A,addressesList:I,addressId:_,handleRenderForm:p,handleRenderModal:E,removeAddress:w,onCloseBtnClick:g,setEditingAddressId:q,closeNewAddressForm:R,redirectToAddressesRoute:$,handleOnSuccess:U,handleSelectAddressOption:B,selectedAddressOption:o}},r1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:l="",showFormLoader:c=!1,onAddressData:o,forwardFormRef:i,className:u,showSaveCheckBox:f=!1,saveCheckBoxValue:C=!1,selectShipping:y=!1,selectBilling:F=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:m=!0,inputsDefaultValueSet:_,showShippingCheckBox:N=!0,showBillingCheckBox:I=!0,shippingCheckBoxValue:S=!0,billingCheckBoxValue:O=!0,routeAddressesPage:z,onSuccess:b,onError:q})=>{var K;const B=t?"minifiedView":"fullSizeView",p=se({containerTitle:`Account.${B}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${B}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${B}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${B}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${B}.Addresses.newAddressFormTitle`}),{keysSortOrder:g,submitLoading:E,isModalRendered:w,isFormRendered:R,loading:$,addNewAddress:U,addressesList:h,addressId:M,handleRenderForm:j,handleRenderModal:X,removeAddress:D,onCloseBtnClick:ne,handleOnSuccess:te,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ce,handleSelectAddressOption:ie,selectedAddressOption:ue}=Rt({defaultSelectAddressId:l,minifiedView:t,routeAddressesPage:z,onSuccess:b,onAddressData:o,selectShipping:y,selectBilling:F}),H=s??(y&&F?"selectedAddress":y?"selectedShippingAddress":F?"selectedBillingAddress":"default"),P=L?k("div",{className:"account-addresses-wrapper--select-view",children:[(K=Ue(h,y,F))==null?void 0:K.map((v,Y)=>k(Ne,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:H,id:`${H}_${v.id}`,value:v.id,checked:ue===(v==null?void 0:v.id.toString()),onChange:ge=>ie(ge,v)}),a("label",{htmlFor:`${H}_${v.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:y,selectBilling:F,minifiedView:t,addressData:v,keysSortOrder:g,loading:$})})]},v.id)),a("input",{"data-testid":"radio-0",type:"radio",name:H,id:`${H}_addressActions`,value:"0",checked:ue==="0",onChange:v=>ie(v,{})}),a("label",{htmlFor:`${H}_addressActions`,className:"account-addresses-wrapper__label",children:U?a("div",{className:J(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",U]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:H,showFormLoader:c,isOpen:U,forwardFormRef:i,showSaveCheckBox:f,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:O,addressesFormTitle:d||p.differentAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:N,showBillingCheckBox:I,onCloseBtnClick:oe,onSuccess:te,onError:q,onChange:o})}):h!=null&&h.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:U,routeAddressesPage:ce}):null})]}):k(Q,{children:[h.map(v=>a(Ne,{children:M===v.id&&R?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:M===v.id&&R,addressFormId:M,inputsDefaultValueSet:v,addressesFormTitle:p.editAddressFormTitle,showShippingCheckBox:N,showBillingCheckBox:I,shippingCheckBoxValue:S,billingCheckBoxValue:O,onCloseBtnClick:ne,onSuccess:te,onError:q})}):a(Me,{slots:n,minifiedView:t,addressData:v,keysSortOrder:g,loading:$,setAddressId:Le,handleRenderModal:t&&A||!t&&m?X:void 0,handleRenderForm:t&&A||!t&&m?j:void 0},v.id)},v.id)),a("div",{className:"account-addresses__footer",children:U?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:U,addressesFormTitle:p.newAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:!!(h!=null&&h.length),showBillingCheckBox:!!(h!=null&&h.length),shippingCheckBoxValue:S,billingCheckBoxValue:O,onCloseBtnClick:oe,onSuccess:te,onError:q})}):a(Fe,{minifiedView:t,addNewAddress:U,routeAddressesPage:ce})})]});return k("div",{children:[a("div",{children:x?a(Xe,{title:r||p.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),k("div",{className:J(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(Ot,{minifiedView:t,addressData:h==null?void 0:h.find(v=>v.id===M),keysSortOrder:g,submitLoading:E,open:w,closeModal:ne,onRemoveAddress:D}),$?a(ze,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:H,isOpen:!(h!=null&&h.length),forwardFormRef:i,showSaveCheckBox:f,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:O,inputsDefaultValueSet:_,showShippingCheckBox:N,showBillingCheckBox:I,onCloseBtnClick:oe,onSuccess:te,onError:q,onChange:o}):a(xt,{isEmpty:!(h!=null&&h.length),typeList:"address",minifiedView:t}),P]})]})}),ke={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:re.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Ht={...ke,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Vt={...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:c})=>e.filter(i=>!(s&&(i.customUpperCode==="defaultShipping"||i.customUpperCode==="defaultBilling")&&i.defaultValue)).map(i=>i.customUpperCode==="countryCode"?{...i,options:n,disabled:r}:i.customUpperCode==="postcode"?{...i,required:c}:i.customUpperCode==="region"?{...i,options:d,required:l,disabled:r}:i),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]=Ve(x)),s.includes(L)&&r.push(x)}const{street:l,streetMultiline_2:c,streetMultiline_1:o,region:i,...u}=e,[f,C]=i?i.split(","):[void 0,void 0],y=C&&f?{regionId:+C,regionCode:f}:{region:f};return Ut({...u,...d,region:{...y},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(c=>(c==null?void 0:c.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,c)=>{n[`${r}Multiline_${c+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:c,showBillingCheckBox:o,inputsDefaultValueSet:i,onCloseBtnClick:u,onSuccess:f,onError:C,formName:y})=>{const[F,L]=Z({text:"",type:"success"}),[x,t]=Z(e??!1),[A,m]=Z(r||""),[_,N]=Z([]),[I,S]=Z([]),[O,z]=Z([]),[b,q]=Z([]),[B,p]=Z([]),[g,E]=Z(!1),[w,R]=Z(!1),[$,U]=Z(()=>{var H,P;const T=sessionStorage.getItem(`${y}_addressData`);return T?{countryCode:(P=(H=JSON.parse(T))==null?void 0:H.data)==null?void 0:P.countryCode}:i}),[h,M]=Z(!1),[j,X]=Z(!1),[D,ne]=Z(()=>{var P,K;const T=sessionStorage.getItem(`${y}_addressData`);return T?(K=(P=JSON.parse(T))==null?void 0:P.data)==null?void 0:K.saveAddressBook:n}),te=V(T=>{ne(T.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(T=>{N(T)})},[A]),ee(()=>{M(!0),nt().then(({availableCountries:T,countriesWithRequiredRegion:H,optionalZipCountries:P})=>{S(T),q(H),p(P),M(!1)})},[]),ee(()=>{if($!=null&&$.countryCode){M(!0),X(!0);const T=$==null?void 0:$.countryCode;at(T).then(H=>{z(H);const P=b.find(v=>v===T),K=B.find(v=>v===T);E(!!P),R(!K),M(!1),X(!1)})}},[$==null?void 0:$.countryCode,b,B]);const Le=V(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=V(async(T,H)=>{if(!H)return null;t(!0);const P=Ie(T.target),K=Oe(P);await Ce(K).then(()=>{var v;f==null||f(),u==null||u(),(v=T==null?void 0:T.target)==null||v.reset()}).catch(v=>{L(Y=>({...Y,text:v.message,type:"error"})),C==null||C(v)}).finally(()=>{m(""),t(!1)})},[u,C,f]),ce=V(async(T,H)=>{if(!H)return;t(!0);const{saveAddressBook:P,...K}=Ie(T.target),v=Oe(K);await dt(v).then(()=>{var Y;f==null||f(),u==null||u(),(Y=T==null?void 0:T.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),C==null||C(Y)}).finally(()=>{m(""),t(!1)})},[u,C,f]),ie=Qe(()=>{if(!_.length)return[];const T={...Ht,defaultValue:l,isHidden:s&&!D?!0:!c},H={...Vt,defaultValue:d,isHidden:s&&!D?!0:!o},P=[..._,T,H],K=sessionStorage.getItem(`${y}_addressData`),v=K?kt(JSON.parse(K).data,O):{},Y=Bt(qt(v,i),P);return zt({fields:Y,addressId:A,countryOptions:I,disableField:h,regionOptions:O,isRequiredRegion:g,isRequiredPostCode:w})},[_,l,s,D,c,d,o,y,O,i,A,I,h,g,w]),ue=V(T=>{U(H=>({...H,...T}))},[]);return{isWaitingForResponse:j,regionOptions:O,saveCheckBoxAddress:D,inLineAlert:F,addressId:A,submitLoading:x,normalizeFieldsConfig:ie,handleSaveCheckBoxAddress:te,handleUpdateAddress:oe,handleCreateAddress:ce,handleOnCloseForm:Le,handleInputChange:ue}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,showShippingCheckBox:C=!0,showBillingCheckBox:y=!0,shippingCheckBoxValue:F=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N})=>{const I=se({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:S,inLineAlert:O,addressId:z,submitLoading:b,normalizeFieldsConfig:q,handleUpdateAddress:B,handleCreateAddress:p,handleOnCloseForm:g,handleSaveCheckBoxAddress:E,saveCheckBoxAddress:w,handleInputChange:R,regionOptions:$}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:f,shippingCheckBoxValue:F,billingCheckBoxValue:L,showShippingCheckBox:C,showBillingCheckBox:y,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:m,onError:_,onCloseBtnClick:A,formName:s});return x?k("div",{className:J(["account-address-form-wrapper",i]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,O.text?a(De,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,k(Tt,{regionOptions:$,forwardFormRef:l,slots:c,className:"account-address-form",name:s||"addressesForm",fieldsConfig:q,onSubmit:t||(z?B:p),setInputChange:R,loading:b,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:E,saveCheckBoxAddress:w,onChange:N,isWaitingForResponse:S,children:[z?a("input",{type:"hidden",name:"addressId",value:z,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:J(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:c!=null&&c.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:c.AddressFormActions,context:{handleUpdateAddress:B,handleCreateAddress:p,addressId:z}}):a(Q,{children:r?null:k(Q,{children:[a(de,{type:"button",onClick:g,variant:"secondary",disabled:b,children:I.secondaryButton}),a(de,{disabled:b,children:I.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}; diff --git a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js index 4466c4266c..84ca43ae12 100644 --- a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js +++ b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js @@ -1,4 +1,4 @@ -import{t as l,m as i,f as m,h as _,a as p}from"./removeCustomerAddress.js";const f=(t,r="en-US",s={})=>{const e={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},a=new Date(t);return isNaN(a.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,e).format(a)},g=t=>{var d,c;if(!((c=(d=t.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:r,page_info:s,total_count:n,date_of_first_order:e}=t.data.customer.orders;return{items:r.map(o=>{const u={...o,order_date:f(o.order_date),shipping_address:l(o.shipping_address),billing_address:l(o.billing_address)};return i(u,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(n,"camelCase",{}),dateOfFirstOrder:i(e,"camelCase",{})}},y=` +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 @@ -15,7 +15,7 @@ fragment AddressesList on OrderAddress { suffix telephone vat_id -}`,h=` +}`,O=` fragment OrderSummary on OrderTotal { __typename grand_total { @@ -49,9 +49,18 @@ fragment OrderSummary on OrderTotal { } label } -}`,O=` +}`,S=` query GET_CUSTOMER_ORDERS_LIST($currentPage: Int, $pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) { customer { + returns { + items { + uid + number + order { + id + } + } + } orders(currentPage: $currentPage, pageSize: $pageSize, filter: $filter, sort: $sort) { page_info { page_size @@ -96,7 +105,9 @@ fragment OrderSummary on OrderTotal { quantity_shipped quantity_invoiced product { - small_image { + sku + url_key + small_image { url } } @@ -108,6 +119,6 @@ fragment OrderSummary on OrderTotal { } } } -${y} ${h} -`,S={sort_direction:"DESC",sort_field:"CREATED_AT"},T=async(t,r,s)=>{const n=r.includes("viewAll")?{}:{order_date:JSON.parse(r)};return await m(O,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:s,filter:n,sort:S}}).then(e=>{var a;return(a=e.errors)!=null&&a.length?_(e.errors):g(e)}).catch(p)};export{T as g}; +${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}; diff --git a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js index 948561af33..9a1dcf7657 100644 --- a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js +++ b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js @@ -1,4 +1,4 @@ -import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),A=` +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=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -30,7 +30,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,p=` +`,R=` query GET_ATTRIBUTES_FORM_SHORT { attributesForm(formCode: "customer_register_address") { items { @@ -44,13 +44,13 @@ 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)},b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),R=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:R;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},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==="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},O=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",{})},$=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(O).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},d=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}},G=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"?A:p,{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),I=` +`,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=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { createCustomerAddress(input:$input) { firstname } } -`,L=async t=>await s(I,{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),M=` +`,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=` query GET_CUSTOMER_ADDRESS { customer { addresses { @@ -80,7 +80,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr } } } -`,P=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),N=` +`,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=` query GET_COUNTRIES_QUERY { countries { two_letter_abbreviation @@ -91,7 +91,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr optional_zip_countries } } -`,z=async()=>await s(N,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):d(t)}).catch(f),U=` +`,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=` query GET_REGIONS($countryCode: String!) { country(id: $countryCode) { id @@ -102,7 +102,7 @@ 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):G(e)}).catch(f),w=` +`,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) { @@ -113,4 +113,4 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) { 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{f as a,B as b,j as c,H as d,L as e,s as f,k as g,h,P as i,z as j,Z as k,W as l,a as m,R as n,b as o,Q as r,x as s,O as t,K as u}; +`,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}; diff --git a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js new file mode 100644 index 0000000000..bf2d67bd23 --- /dev/null +++ b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js @@ -0,0 +1,57 @@ +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 { + date_of_birth + dob + email + firstname + gender + lastname + middlename + prefix + suffix + created_at + } +`,D=` + query GET_CUSTOMER { + customer { + ...BasicCustomerInfo + custom_attributes { + ... on AttributeValue { + 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) { + 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) { + customer { + 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=` + mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) { + updateCustomerV2(input:$input) { + customer { + 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}; diff --git a/scripts/__dropins__/storefront-account/components/ChangePassword/ChangePassword.d.ts b/scripts/__dropins__/storefront-account/components/ChangePassword/ChangePassword.d.ts new file mode 100644 index 0000000000..9ef25dd3a0 --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/ChangePassword/ChangePassword.d.ts @@ -0,0 +1,5 @@ +import { FunctionComponent } from 'preact'; +import { ChangePasswordProps } from '../../types'; + +export declare const ChangePassword: FunctionComponent; +//# sourceMappingURL=ChangePassword.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/ChangePassword/index.d.ts b/scripts/__dropins__/storefront-account/components/ChangePassword/index.d.ts new file mode 100644 index 0000000000..3a99538223 --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/ChangePassword/index.d.ts @@ -0,0 +1,3 @@ +export * from './ChangePassword'; +export { ChangePassword as default } from './ChangePassword'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/CustomerInformationCard/CustomerInformationCard.d.ts b/scripts/__dropins__/storefront-account/components/CustomerInformationCard/CustomerInformationCard.d.ts new file mode 100644 index 0000000000..cebb17db7f --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/CustomerInformationCard/CustomerInformationCard.d.ts @@ -0,0 +1,5 @@ +import { FunctionComponent } from 'preact'; +import { CustomerInformationCardProps } from '../../types'; + +export declare const CustomerInformationCard: FunctionComponent; +//# sourceMappingURL=CustomerInformationCard.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/CustomerInformationCard/index.d.ts b/scripts/__dropins__/storefront-account/components/CustomerInformationCard/index.d.ts new file mode 100644 index 0000000000..76e5ae48fa --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/CustomerInformationCard/index.d.ts @@ -0,0 +1,3 @@ +export * from './CustomerInformationCard'; +export { CustomerInformationCard as default } from './CustomerInformationCard'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/EditCustomerInformation/EditCustomerInformation.d.ts b/scripts/__dropins__/storefront-account/components/EditCustomerInformation/EditCustomerInformation.d.ts new file mode 100644 index 0000000000..b3bff802cf --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/EditCustomerInformation/EditCustomerInformation.d.ts @@ -0,0 +1,5 @@ +import { FunctionComponent } from 'preact'; +import { EditCustomerInformationProps } from '../../types'; + +export declare const EditCustomerInformation: FunctionComponent; +//# sourceMappingURL=EditCustomerInformation.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/EditCustomerInformation/index.d.ts b/scripts/__dropins__/storefront-account/components/EditCustomerInformation/index.d.ts new file mode 100644 index 0000000000..083691b625 --- /dev/null +++ b/scripts/__dropins__/storefront-account/components/EditCustomerInformation/index.d.ts @@ -0,0 +1,3 @@ +export * from './EditCustomerInformation'; +export { EditCustomerInformation as default } from './EditCustomerInformation'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/components/index.d.ts b/scripts/__dropins__/storefront-account/components/index.d.ts index 12ff095980..20afdd32d1 100644 --- a/scripts/__dropins__/storefront-account/components/index.d.ts +++ b/scripts/__dropins__/storefront-account/components/index.d.ts @@ -10,4 +10,7 @@ export * from './OrdersListCard'; export * from './AccountLoaders'; export * from './AddressesWrapper'; export * from './AddressFormWrapper'; +export * from './ChangePassword'; +export * from './EditCustomerInformation'; +export * from './CustomerInformationCard'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/containers/AddressForm.js b/scripts/__dropins__/storefront-account/containers/AddressForm.js index 1fb6dc9c23..154dd81c21 100644 --- a/scripts/__dropins__/storefront-account/containers/AddressForm.js +++ b/scripts/__dropins__/storefront-account/containers/AddressForm.js @@ -1 +1 @@ -import{A as l,A as u}from"../chunks/AddressFormWrapper.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}; +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 008a9e1b11..79553d3545 100644 --- a/scripts/__dropins__/storefront-account/containers/Addresses.js +++ b/scripts/__dropins__/storefront-account/containers/Addresses.js @@ -1 +1 @@ -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/AddressFormWrapper.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}; +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.d.ts b/scripts/__dropins__/storefront-account/containers/CustomerInformation.d.ts new file mode 100644 index 0000000000..c54d8f7a56 --- /dev/null +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.d.ts @@ -0,0 +1,3 @@ +export * from './CustomerInformation/index' +import _default from './CustomerInformation/index' +export default _default diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js new file mode 100644 index 0000000000..6e7d20a894 --- /dev/null +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js @@ -0,0 +1 @@ +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}; diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation/CustomerInformation.d.ts b/scripts/__dropins__/storefront-account/containers/CustomerInformation/CustomerInformation.d.ts new file mode 100644 index 0000000000..28c0939c9f --- /dev/null +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation/CustomerInformation.d.ts @@ -0,0 +1,5 @@ +import { CustomerInformationProps } from '../../types'; +import { Container } from '@dropins/tools/types/elsie/src/lib'; + +export declare const CustomerInformation: Container; +//# sourceMappingURL=CustomerInformation.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation/index.d.ts b/scripts/__dropins__/storefront-account/containers/CustomerInformation/index.d.ts new file mode 100644 index 0000000000..2909b12625 --- /dev/null +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation/index.d.ts @@ -0,0 +1,3 @@ +export * from './CustomerInformation'; +export { CustomerInformation as default } from './CustomerInformation'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/containers/OrdersList.js b/scripts/__dropins__/storefront-account/containers/OrdersList.js index 715604dc9f..ed1e3f119d 100644 --- a/scripts/__dropins__/storefront-account/containers/OrdersList.js +++ b/scripts/__dropins__/storefront-account/containers/OrdersList.js @@ -1 +1 @@ -import{jsx as s,jsxs as f,Fragment as C}from"@dropins/tools/preact-jsx-runtime.js";import{classes as N,Slot as H}from"@dropins/tools/lib.js";import{S as m,c as B,E as K,C as V}from"../chunks/AddressFormWrapper.js";import"@dropins/tools/preact-compat.js";import{Card as F,Icon as z,ContentGrid as q,Image as Y,Header as J,Picker as R,Pagination as W}from"@dropins/tools/components.js";import{useText as x}from"@dropins/tools/i18n.js";import{useState as O,useEffect as I,useMemo as j,useCallback as P}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as G}from"../chunks/getOrderHistoryList.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const E={size:"32",stroke:"2"},T=({minifiedView:c,orderNumber:r,orderToken:t,routeOrdersList:e,routeOrderDetails:n})=>{const i=c?"minifiedView":"fullSizeView",l=x({viewAllOrdersButton:`Account.${i}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${i}.OrdersList.ariaLabelLink`});return e?s("a",{className:N(["account-orders-list-action",["account-orders-list-action--minifiedView",c]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(F,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:f("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:l.viewAllOrdersButton}),s(z,{source:m,...E})]})})}):s("a",{"aria-label":`${l.ariaLabelLink} ${r??t}`,href:B(n)?n(r,t):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(z,{source:m,...E})})},U=()=>{const[c,r]=O(window.innerWidth<768);return I(()=>{const t=()=>{r(window.innerWidth<768)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),c},Q=({minifiedView:c,item:r,withThumbnails:t,children:e,slots:n,routeTracking:i,routeOrderProduct:l,...A})=>{var h,y,_,w,$,b;const L=c?"minifiedView":"fullSizeView",p=x({orderNumber:`Account.${L}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${L}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${L}.OrdersList.OrdersListCard.carrier`,deliveryDateText:`Account.${L}.OrdersList.OrdersListCard.orderDate`}),o=U(),u=B(l);return f(F,{variant:"secondary",...A,className:N(["account-orders-list-card",["account-orders-list-card--full",((h=r==null?void 0:r.items)==null?void 0:h.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(H,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):f(C,{children:[s("div",{children:r==null?void 0:r.status}),f("p",{children:[p.deliveryDateText," ",r==null?void 0:r.orderDate]}),f("p",{children:[p.orderNumber," ",r.number]}),(y=r==null?void 0:r.shipments)==null?void 0:y.map(a=>{var g;return(g=a==null?void 0:a.tracking)==null?void 0:g.map(d=>f("p",{"data-testid":d.number,children:[s("span",{children:`${p.carrier} ${d.carrier.toLocaleUpperCase()} `}),s("a",{href:(i==null?void 0:i(d))??"",className:"account-orders-list-card__content--track_number",children:d.number})]},a.id))}),f("p",{children:["$",(_=r==null?void 0:r.total)==null?void 0:_.grandTotal.value]}),f("p",{"data-testid":"itemsAmount",children:[((w=r==null?void 0:r.items)==null?void 0:w.length)??0," ",p.itemsAmount]}),($=r==null?void 0:r.items)==null?void 0:$.map((a,g)=>{if(g>=0&&g<10)return f("p",{className:"account-orders-list-card__content--product-name",children:[f("span",{className:"account-orders-list-card__content--quantity",children:[(a==null?void 0:a.quantityOrdered)>1?a==null?void 0:a.quantityOrdered:null," "]}),a==null?void 0:a.productName.replaceAll("-"," ")]},`${g}_${a.id}`);if(g===11)return s("p",{children:"..."},"ellipsis")})]})}),t&&((b=r==null?void 0:r.items)!=null&&b.length)?s(q,{maxColumns:o?3:9,emptyGridContent:s(C,{}),className:N(["account-orders-list-card__images",["account-orders-list-card__images-3",o]]),"data-testid":"ordersListCardImages",children:r.items.map((a,g)=>{var v;const d=(v=a==null?void 0:a.product)==null?void 0:v.smallImage.url,D=a==null?void 0:a.productName;return u?s("a",{href:l==null?void 0:l(a),target:"_blank",rel:"noreferrer",children:s(Y,{src:d,width:65,height:65,alt:D})},a.id+g):s(Y,{src:d,width:65,height:65,alt:D},a.id+g)})}):null,s("div",{className:"account-orders-list-card__actions",children:e})]})},X=({ordersInMinifiedView:c,minifiedView:r,pageSize:t,selectedDate:e,selectedPage:n,handleSetFirstOrderDate:i})=>{const[l,A]=O([]),[L,p]=O({totalPages:1,currentPage:1,pageSize:1}),[o,u]=O(!1);return I(()=>{u(!0),G(r?c:t,e,n).then(h=>{!h||!h.items||(p(h.pageInfo),A(h.items),i==null||i(h.dateOfFirstOrder))}).finally(()=>{u(!1)})},[i,r,c,t,e,n]),{loading:o,orderHistoryListItems:l,pageInfo:L}},M=(c,r=1)=>{const t=new Date,e=new Date(t);switch(c){case"sixMonthsAgo":{e.setMonth(e.getMonth()-r);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-r);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${t==null?void 0:t.toISOString().split("T")[0]} 23:59:59`}},Z=c=>{const r=[],t=new Date().getFullYear();for(let e=c;e<=t-1;e++)r.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return r},rr=()=>{const c=x({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[r,t]=O(),[e,n]=O(JSON.stringify(M("sixMonthsAgo",6))),[i,l]=O(1);I(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[i]);const A=j(()=>{const o=[{value:JSON.stringify(M("sixMonthsAgo",6)),text:c.pastSixMonths},{value:JSON.stringify(M("oneYearAgo",1)),text:c.currentYear},{value:"viewAll",text:c.viewAll}];if(r){const h=new Date(r).getFullYear();o==null||o.splice(2,0,...Z(h))}return o},[c,r]),L=P(o=>{t(o)},[]),p=P(o=>{const h=o.target.value;n(h),l(1)},[]);return{selectableDateList:A,selectedDate:e,selectedPage:i,handleSelectDate:p,setSelectedPage:l,handleSetFirstOrderDate:L}},tr=({className:c,withHeader:r=!0,minifiedView:t=!1,withThumbnails:e=!0,withFilter:n=!0,ordersInMinifiedView:i=1,pageSize:l=10,routeOrdersList:A,routeOrderDetails:L,routeTracking:p,routeOrderProduct:o,slots:u})=>{const y=x({containerTitle:`Account.${t?"minifiedView":"fullSizeView"}.OrdersList.containerTitle`}),{selectableDateList:_,selectedDate:w,handleSelectDate:$,selectedPage:b,setSelectedPage:a,handleSetFirstOrderDate:g}=rr(),{pageInfo:d,loading:D,orderHistoryListItems:v}=X({minifiedView:t,pageSize:l,ordersInMinifiedView:i,selectedDate:w,selectedPage:b,handleSetFirstOrderDate:g});return f("div",{children:[r?s(J,{"aria-label":y.containerTitle,role:"region",title:y.containerTitle,divider:!t,className:t?"account-orders-list-header":""}):null,f("div",{className:N(["account-orders-list",c]),children:[!t&&n?s("div",{className:"account-orders-list__date-select",children:s(R,{value:w,name:"orderDatePicker",options:_,handleSelect:$})}):null,D?s(C,{children:Array.from(Array(d==null?void 0:d.pageSize).keys()).map(S=>s(V,{testId:"orderSkeletonLoader",withCard:!1},S))}):s(C,{children:v.length?s(C,{children:v.map((S,k)=>s(Q,{routeTracking:p,routeOrderProduct:o,minifiedView:t,item:S,withThumbnails:e,slots:u,children:u!=null&&u.OrdersListAction?s(H,{"data-testid":`ordersListActionSlot_${k}`,name:"OrdersListAction",slot:u==null?void 0:u.OrdersListAction,context:{orderHistoryListItem:S}}):s(T,{minifiedView:t,orderNumber:S.number,orderToken:S.token,routeOrderDetails:L})},k))}):s(K,{isEmpty:!v.length,typeList:"orders",minifiedView:t})}),!t&&(d==null?void 0:d.totalPages)>1?s(W,{totalPages:d==null?void 0:d.totalPages,currentPage:b,onChange:a}):null,t?s(T,{minifiedView:t,routeOrdersList:A}):null]})]})},pr=({className:c,withHeader:r,minifiedView:t,withThumbnails:e,withFilter:n,ordersInMinifiedView:i,pageSize:l,routeOrdersList:A,routeOrderDetails:L,routeTracking:p,routeOrderProduct:o,slots:u})=>s("div",{className:N(["account-orders-list",c]),"data-testid":"ordersListId",children:s(tr,{className:c,withHeader:r,minifiedView:t,withThumbnails:e,withFilter:n,ordersInMinifiedView:i,pageSize:l,routeOrdersList:A,routeOrderDetails:L,routeTracking:p,routeOrderProduct:o,slots:u})});export{pr as OrdersList,pr as default}; +import{jsx as s,jsxs as u,Fragment as _}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as B}from"@dropins/tools/lib.js";import{S as T,c as F,E as J,C as K}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as q,Icon as Y,ContentGrid as V,Image as D,Header as W,Picker as j,Pagination as G}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";import{useState as v,useEffect as z,useMemo as U,useCallback as E}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Q}from"../chunks/getOrderHistoryList.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const H={size:"32",stroke:"2"},m=({minifiedView:n,orderNumber:r,orderToken:e,routeOrdersList:a,routeOrderDetails:d})=>{const i=n?"minifiedView":"fullSizeView",l=I({viewAllOrdersButton:`Account.${i}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${i}.OrdersList.ariaLabelLink`});return a?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",n]]),"data-testid":"ordersListActionButtonMinifiedView",href:a(),children:s(q,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:l.viewAllOrdersButton}),s(Y,{source:T,...H})]})})}):s("a",{"aria-label":`${l.ariaLabelLink} ${r??e}`,href:F(d)?d(r,e):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(Y,{source:T,...H})})},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:l,routeReturnDetails:p,...A})=>{var S,b,$,y,x,w,k,M;const h=n?"minifiedView":"fullSizeView",o=I({orderNumber:`Account.${h}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${h}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${h}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${h}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${h}.OrdersList.OrdersListCard.orderDate`}),g=X(),c=F(l);return u(q,{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:[s("div",{className:"account-orders-list-card__content",children:d!=null&&d.OrdersListCard?s(B,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:d==null?void 0:d.OrdersListCard,context:{orderHistoryListItem:r}}):u(_,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[o.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[o.orderNumber," ",r.number]}),(b=r==null?void 0:r.shipments)==null?void 0:b.map(t=>{var L;return(L=t==null?void 0:t.tracking)==null?void 0:L.map(O=>u("p",{"data-testid":O.number,children:[s("span",{children:`${o.carrier} ${O.carrier.toLocaleUpperCase()} `}),s("a",{href:(i==null?void 0:i(O))??"",className:"account-orders-list-card__content--track_number",children:O.number})]},t.id))}),r!=null&&r.returns&&(($=r.returns)!=null&&$.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[o.returnsText," "]}),(y=r==null?void 0:r.returns)==null?void 0:y.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(p==null?void 0:p({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:["$",(x=r==null?void 0:r.total)==null?void 0:x.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[((w=r==null?void 0:r.items)==null?void 0:w.length)??0," ",o.itemsAmount]}),(k=r==null?void 0:r.items)==null?void 0:k.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(V,{maxColumns:g?3:9,emptyGridContent:s(_,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",g]]),"data-testid":"ordersListCardImages",children:r.items.map((t,L)=>{var N;const O=(N=t==null?void 0:t.product)==null?void 0:N.smallImage.url,f=t==null?void 0:t.productName;return c?s("a",{href:l==null?void 0:l(t),target:"_blank",rel:"noreferrer",children:s(D,{src:O,width:65,height:65,alt:f})},t.id+L):s(D,{src:O,width:65,height:65,alt:f},t.id+L)})}):null,s("div",{className:"account-orders-list-card__actions",children:a})]})},R=({ordersInMinifiedView:n,minifiedView:r,pageSize:e,selectedDate:a,selectedPage:d,handleSetFirstOrderDate:i})=>{const[l,p]=v([]),[A,h]=v({totalPages:1,currentPage:1,pageSize:1}),[o,g]=v(!1);return z(()=>{g(!0),Q(r?n:e,a,d).then(c=>{!c||!c.items||(h(c.pageInfo),p(c.items),i==null||i(c.dateOfFirstOrder))}).finally(()=>{g(!1)})},[i,r,n,e,a,d]),{loading:o,orderHistoryListItems:l,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`}},rr=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},tr=()=>{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,l]=v(1);z(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[i]);const p=U(()=>{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,...rr(c))}return o},[n,r]),A=E(o=>{e(o)},[]),h=E(o=>{const c=o.target.value;d(c),l(1)},[]);return{selectableDateList:p,selectedDate:a,selectedPage:i,handleSelectDate:h,setSelectedPage:l,handleSetFirstOrderDate:A}},sr=({className:n,withHeader:r=!0,minifiedView:e=!1,withThumbnails:a=!0,withFilter:d=!0,ordersInMinifiedView:i=1,pageSize:l=10,routeOrdersList:p,routeOrderDetails:A,routeReturnDetails:h,routeTracking:o,routeOrderProduct:g,slots:c})=>{const S=e?"minifiedView":"fullSizeView",b=I({containerTitle:`Account.${S}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${S}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:y,handleSelectDate:x,selectedPage:w,setSelectedPage:k,handleSetFirstOrderDate:M}=tr(),{pageInfo:t,loading:L,orderHistoryListItems:O}=R({minifiedView:e,pageSize:l,ordersInMinifiedView:i,selectedDate:y,selectedPage:w,handleSetFirstOrderDate:M});return u("div",{children:[r?s(W,{"aria-label":b.containerTitle,role:"region",title:b.containerTitle,divider:!e,className:e?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",n]),children:[!e&&d?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:b.dateOrderPlaced}),s(j,{value:y,name:"orderDatePicker",options:$,handleSelect:x})]}):null,L?s(_,{children:Array.from(Array(t==null?void 0:t.pageSize).keys()).map(f=>s(K,{testId:"orderSkeletonLoader",withCard:!1},f))}):s(_,{children:O.length?s(_,{children:O.map((f,N)=>s(Z,{routeTracking:o,routeOrderProduct:g,routeReturnDetails:h,minifiedView:e,item:f,withThumbnails:a,slots:c,children:c!=null&&c.OrdersListAction?s(B,{"data-testid":`ordersListActionSlot_${N}`,name:"OrdersListAction",slot:c==null?void 0:c.OrdersListAction,context:{orderHistoryListItem:f}}):s(m,{minifiedView:e,orderNumber:f.number,orderToken:f.token,routeOrderDetails:A})},N))}):s(J,{isEmpty:!O.length,typeList:"orders",minifiedView:e})}),!e&&(t==null?void 0:t.totalPages)>1?s(G,{totalPages:t==null?void 0:t.totalPages,currentPage:w,onChange:k}):null,e?s(m,{minifiedView:e,routeOrdersList:p}):null]})]})},gr=({className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:l,routeOrdersList:p,routeOrderDetails:A,routeReturnDetails:h,routeTracking:o,routeOrderProduct:g,slots:c})=>s("div",{className:C(["account-orders-list",n]),"data-testid":"ordersListId",children:s(sr,{className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:l,routeOrdersList:p,routeOrderDetails:A,routeReturnDetails:h,routeTracking:o,routeOrderProduct:g,slots:c})});export{gr as OrdersList,gr as default}; diff --git a/scripts/__dropins__/storefront-account/containers/index.d.ts b/scripts/__dropins__/storefront-account/containers/index.d.ts index b8ad463597..0855e2fa12 100644 --- a/scripts/__dropins__/storefront-account/containers/index.d.ts +++ b/scripts/__dropins__/storefront-account/containers/index.d.ts @@ -1,4 +1,5 @@ export * from './AddressForm'; export * from './Addresses'; export * from './OrdersList'; +export * from './CustomerInformation'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/data/models/customer.d.ts b/scripts/__dropins__/storefront-account/data/models/customer.d.ts index 5e1f1813dc..31da09a4e5 100644 --- a/scripts/__dropins__/storefront-account/data/models/customer.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/customer.d.ts @@ -1,6 +1,14 @@ export interface CustomerDataModelShort { - firstname: string; - lastname: string; + firstName: string; + lastName: string; + middleName: string; + dateOfBirth: string; + dob: string; + prefix: string; + gender: 1 | 2 | string; + suffix: string; email: string; + createdAt: string; + [key: string]: string | boolean | number; } //# sourceMappingURL=customer.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/data/models/index.d.ts b/scripts/__dropins__/storefront-account/data/models/index.d.ts index 6eb30926e2..a97f699131 100644 --- a/scripts/__dropins__/storefront-account/data/models/index.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/index.d.ts @@ -3,4 +3,5 @@ export * from './attributes-form'; export * from './country'; export * from './region'; export * from './order-history-list'; +export * from './store-config'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file 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 f5ed41e9bf..7bd14b2fc1 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 @@ -1,4 +1,5 @@ import { CustomerAddressesModel } from './customer-address'; +import { ReturnProps } from '../../types'; export type ProductImage = { url: string; @@ -58,6 +59,7 @@ export type OrderDetails = { number: string; orderDate: string; items: OrderItem[]; + returns: ReturnProps[]; shipments: ShipmentsModel[]; paymentMethods: PaymentMethod[]; shippingAddress: CustomerAddressesModel; diff --git a/scripts/__dropins__/storefront-account/data/models/store-config.d.ts b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts new file mode 100644 index 0000000000..2f2ba6e973 --- /dev/null +++ b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts @@ -0,0 +1,5 @@ +export interface StoreConfigModel { + minLength: number; + requiredCharacterClasses: number; +} +//# sourceMappingURL=store-config.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/data/transforms/index.d.ts b/scripts/__dropins__/storefront-account/data/transforms/index.d.ts index 340b0aebdd..b8eab57d73 100644 --- a/scripts/__dropins__/storefront-account/data/transforms/index.d.ts +++ b/scripts/__dropins__/storefront-account/data/transforms/index.d.ts @@ -4,4 +4,5 @@ export * from './transform-customer'; export * from './transform-countries'; export * from './transform-regions'; export * from './transform-order-history-list'; +export * from './transform-store-config'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/data/transforms/transform-store-config.d.ts b/scripts/__dropins__/storefront-account/data/transforms/transform-store-config.d.ts new file mode 100644 index 0000000000..96b684a22b --- /dev/null +++ b/scripts/__dropins__/storefront-account/data/transforms/transform-store-config.d.ts @@ -0,0 +1,5 @@ +import { GetStoreConfigResponse } from '../../types'; +import { StoreConfigModel } from '../models'; + +export declare const transformStoreConfig: (response: GetStoreConfigResponse) => StoreConfigModel; +//# sourceMappingURL=transform-store-config.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/components/useChangePassword.d.ts b/scripts/__dropins__/storefront-account/hooks/components/useChangePassword.d.ts new file mode 100644 index 0000000000..fbec5ff10c --- /dev/null +++ b/scripts/__dropins__/storefront-account/hooks/components/useChangePassword.d.ts @@ -0,0 +1,26 @@ +import { UseChangePasswordProps } from '../../types'; + +export declare const DEFAULT_ERRORS_STATE: { + currentPassword: string; + newPassword: string; + confirmPassword: string; +}; +export declare const useChangePassword: ({ passwordConfigs, handleSetInLineAlert, handleHideChangePassword, }: UseChangePasswordProps) => { + hideChangePassword: () => void; + handleOnBlurPassword: (event: Event) => void; + handleConfirmPasswordChange: (value: string) => void; + handleNewPasswordChange: (value: string) => void; + handleCurrentPasswordChange: (value: string) => void; + mutationChangePassword: (event: Event) => void; + currentPassword: string; + newPassword: string; + confirmPassword: string; + passwordErrors: { + currentPassword: string; + newPassword: string; + confirmPassword: string; + }; + submitLoading: boolean; + isClickSubmit: boolean; +}; +//# sourceMappingURL=useChangePassword.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/components/usePasswordValidationMessage.d.ts b/scripts/__dropins__/storefront-account/hooks/components/usePasswordValidationMessage.d.ts new file mode 100644 index 0000000000..b02c64fcba --- /dev/null +++ b/scripts/__dropins__/storefront-account/hooks/components/usePasswordValidationMessage.d.ts @@ -0,0 +1,16 @@ +import { ValidateLengthConfigProps, statusTypes } from '../../types'; + +interface UsePasswordValidationMessageProps { + passwordConfigs: { + minLength: number; + requiredCharacterClasses: number; + } | null; + isClickSubmit: boolean; + password: string; +} +export declare const usePasswordValidationMessage: ({ passwordConfigs, isClickSubmit, password, }: UsePasswordValidationMessageProps) => { + isValidUniqueSymbols: statusTypes; + defaultLengthMessage: ValidateLengthConfigProps | undefined; +}; +export {}; +//# sourceMappingURL=usePasswordValidationMessage.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useCustomerInformation.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useCustomerInformation.d.ts new file mode 100644 index 0000000000..d774cc129e --- /dev/null +++ b/scripts/__dropins__/storefront-account/hooks/containers/useCustomerInformation.d.ts @@ -0,0 +1,50 @@ +import { UseCustomerInformationProps } from '../../types'; + +export declare const useCustomerInformation: ({ handleSetInLineAlert, }: UseCustomerInformationProps) => { + createdAt: string; + errorPasswordEmpty: boolean; + passwordValue: string; + showPasswordOnEmailChange: boolean; + orderedCustomerData: { + name: string; + orderNumber: number | undefined; + value: any; + label: string | null | undefined; + }[]; + loading: boolean; + normalizeFieldsConfig: { + defaultValue: any; + code?: string | undefined; + name?: string | undefined; + id?: string | undefined; + required?: boolean | undefined; + label?: string | undefined; + options?: { + is_default: boolean; + label: string; + value: string; + }[] | undefined; + entityType?: string | undefined; + className?: string | undefined; + fieldType?: import('../../data/models').FieldEnumList | undefined; + multilineCount?: number | undefined; + isUnique?: boolean | undefined; + orderNumber: number; + isHidden?: boolean | undefined; + customUpperCode: string; + validateRules: Record[]; + }[]; + submitLoading: boolean; + showEditForm: boolean; + showChangePassword: boolean; + handleShowChangePassword: () => void; + handleHideChangePassword: (clearStates?: () => void) => void; + handleShowEditForm: () => void; + handleHideEditForm: (clearStates?: () => void) => void; + handleUpdateCustomerInformation: (event: Event, valid: boolean) => Promise; + handleInputChange: (value: Record) => void; + handleSetPassword: (value: string) => void; + handleOnBlurPassword: (event: Event) => void; + renderAlertMessage: (type: 'success' | 'error', message?: string) => void; +}; +//# sourceMappingURL=useCustomerInformation.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useGetStoreConfigs.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useGetStoreConfigs.d.ts new file mode 100644 index 0000000000..5c38bf76fe --- /dev/null +++ b/scripts/__dropins__/storefront-account/hooks/containers/useGetStoreConfigs.d.ts @@ -0,0 +1,7 @@ +export declare const useGetStoreConfigs: () => { + passwordConfigs: { + minLength: number; + requiredCharacterClasses: number; + } | null; +}; +//# sourceMappingURL=useGetStoreConfigs.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/useInLineAlert.d.ts b/scripts/__dropins__/storefront-account/hooks/useInLineAlert.d.ts new file mode 100644 index 0000000000..de336f092e --- /dev/null +++ b/scripts/__dropins__/storefront-account/hooks/useInLineAlert.d.ts @@ -0,0 +1,7 @@ +import { InLineAlertProps } from '../types'; + +export declare const useInLineAlert: () => { + inLineAlertProps: InLineAlertProps; + handleSetInLineAlert: (notification: InLineAlertProps | undefined) => void; +}; +//# sourceMappingURL=useInLineAlert.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts index 421b75663e..0610e0c648 100644 --- a/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts @@ -1,6 +1,53 @@ declare const _default: { "Account": { "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", @@ -25,10 +72,12 @@ declare const _default: { "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": { @@ -71,10 +120,12 @@ declare const _default: { "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": { diff --git a/scripts/__dropins__/storefront-account/lib/validationChangePassword.d.ts b/scripts/__dropins__/storefront-account/lib/validationChangePassword.d.ts new file mode 100644 index 0000000000..e19b51dd33 --- /dev/null +++ b/scripts/__dropins__/storefront-account/lib/validationChangePassword.d.ts @@ -0,0 +1,17 @@ +interface PasswordValidationParams { + currentPassword: string; + newPassword: string; + confirmPassword: string; + translations: Record; +} +interface PasswordErrors { + currentPassword: string; + newPassword: string; + confirmPassword: string; +} +export declare const validationChangePassword: ({ currentPassword, newPassword, confirmPassword, translations, }: PasswordValidationParams) => { + isValid: boolean; + errors: PasswordErrors; +}; +export {}; +//# sourceMappingURL=validationChangePassword.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/lib/validationUniqueSymbolsPassword.d.ts b/scripts/__dropins__/storefront-account/lib/validationUniqueSymbolsPassword.d.ts new file mode 100644 index 0000000000..4d33927030 --- /dev/null +++ b/scripts/__dropins__/storefront-account/lib/validationUniqueSymbolsPassword.d.ts @@ -0,0 +1,2 @@ +export declare const validationUniqueSymbolsPassword: (password: string, uniqueSymbolsCount: number) => boolean; +//# sourceMappingURL=validationUniqueSymbolsPassword.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 9c5957de93..97a853aeff 100644 --- a/scripts/__dropins__/storefront-account/render.js +++ b/scripts/__dropins__/storefront-account/render.js @@ -1,3 +1,3 @@ -(function(c,t){try{if(typeof document<"u"){const a=document.createElement("style"),d=t.styleId;for(const r in t.attributes)a.setAttribute(r,t.attributes[r]);a.setAttribute("data-dropin",d),a.appendChild(document.createTextNode(c));const e=document.querySelector('style[data-dropin="sdk"]');if(e)e.after(a);else{const r=document.querySelector('link[rel="stylesheet"], style');r?r.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);border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.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{border-radius:var(--shape-border-radius-1);margin-bottom:var(--spacing-small);border-width:var(--shape-border-width-1)}.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__description p{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);color:var(--color-neutral-800);margin:0;padding:0;display:inline;overflow:hidden}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(2){margin:0 0 var(--spacing-small) 0;color:var(--color-neutral-800);font:var(--type-button-2-font);text-align:left;font-weight:500;cursor:default}.account-address-card__description p{margin-bottom:var(--spacing-small)}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(5),.account-address-card .account-address-card__description p:nth-child(7){float:left;width:auto;margin-right:var(--spacing-xsmall)}.account-address-card .account-address-card__description p:nth-child(2),.account-address-card .account-address-card__description p:nth-child(6),.account-address-card .account-address-card__description p:nth-child(8){display:inline;width:50%}.account-address-card .account-address-card__description p:nth-child(2):after,.account-address-card .account-address-card__description p:nth-child(6):after,.account-address-card .account-address-card__description p:nth-child(8):after{content:"\\a";white-space:pre;display:block;height:var(--spacing-small)}.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(n+9){display:block;width:100%;margin-bottom:var(--spacing-small)}.account-address-card .account-address-card__labels{display:flex;gap:0 var(--spacing-xsmall);grid-area:labels}.account-actions-address{cursor:pointer;padding:var(--spacing-xsmall) var(--spacing-medium);border-radius:var(--shape-border-radius-1);border:var(--shape-border-width-1) 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__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);border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.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--secondary{border-width:var(--shape-border-width-1);border-radius:var(--shape-border-radius-1)}.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);border-width:var(--shape-border-width-1);border-radius:var(--shape-border-radius-1)}.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{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);cursor:pointer}.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-bottom:var(--spacing-small);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 .account-addresses__footer .dropin-card--secondary{border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.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}`,{styleId:"account"}); -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as o,useEffect as n}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as m}from"@dropins/tools/event-bus.js";const c={minifiedView:{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",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",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",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",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:c},f={default:u},p=({children:s})=>{const[d,a]=o("en_US");return n(()=>{const e=m.on("locale",t=>{a(t)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:d,langDefinitions:f,children:s})},g=new i(r(p,{}));export{g as render}; +(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);cursor:pointer}.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"}); +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/addresses.types.d.ts b/scripts/__dropins__/storefront-account/types/addresses.types.d.ts index 370b46a0f7..e61393761b 100644 --- a/scripts/__dropins__/storefront-account/types/addresses.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/addresses.types.d.ts @@ -17,7 +17,7 @@ export interface AddressesProps { hideActionFormButtons?: boolean; formName?: string; slots?: { - AddressCard: SlotProps; + [key: string]: SlotProps; }; title?: string; addressFormTitle?: string; @@ -57,7 +57,7 @@ export interface KeysSortOrderProps { } export interface AddressCardProps { slots?: { - AddressCard: SlotProps; + [key: string]: SlotProps; }; selectShipping?: boolean; selectBilling?: boolean; 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 88baa26ea3..c373f4955a 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts @@ -1,9 +1,20 @@ export interface getCustomerShortResponse { data: { customer: { + custom_attributes: { + code: string; + value: string | number | boolean; + }[]; firstname: string; lastname: string; email: string; + date_of_birth: string; + dob: string; + gender: 1 | 2; + middlename: string; + prefix: string; + suffix: string; + created_at: string; }; }; errors?: { diff --git a/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts b/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts index 7420c44254..c8c9a468a3 100644 --- a/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts @@ -12,6 +12,8 @@ export interface OrderItemProps { quantity_ordered?: number; quantity_shipped?: number; quantity_invoiced?: number; + url_key: string; + sku: string; status: string; product_name: string; id: string; @@ -49,6 +51,7 @@ export interface OrderProps { order_date: string; carrier: string; items: OrderItemProps[]; + returns?: ReturnProps[]; total: TotalProps; status: string; id: string; @@ -64,10 +67,21 @@ export interface OrdersProps { items: OrderProps[]; date_of_first_order: string; } +export interface ReturnsProps { + items: ReturnProps[]; +} +export interface ReturnProps { + uid: string; + number: string; + order: { + id: string; + }; +} export interface OrderHistoryListResponse { data: { customer?: { orders: OrdersProps; + returns: ReturnsProps; }; }; errors?: { diff --git a/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts new file mode 100644 index 0000000000..ae72c8c484 --- /dev/null +++ b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts @@ -0,0 +1,13 @@ +export interface StoreConfigProps { + minimum_password_length: number; + required_character_classes_number: string; +} +export interface GetStoreConfigResponse { + data: { + storeConfig: StoreConfigProps; + }; + errors?: { + message: string; + }[]; +} +//# sourceMappingURL=storeConfig.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/api/updateCustomerPassword.types.d.ts b/scripts/__dropins__/storefront-account/types/api/updateCustomerPassword.types.d.ts new file mode 100644 index 0000000000..8ce51b4031 --- /dev/null +++ b/scripts/__dropins__/storefront-account/types/api/updateCustomerPassword.types.d.ts @@ -0,0 +1,15 @@ +export interface ChangeCustomerPasswordProps { + currentPassword: string; + newPassword: string; +} +export interface ChangeCustomerPasswordResponse { + data: { + changeCustomerPassword: { + email: string; + }; + }; + errors?: { + message: string; + }[]; +} +//# sourceMappingURL=updateCustomerPassword.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/customerInformation.types.d.ts b/scripts/__dropins__/storefront-account/types/customerInformation.types.d.ts new file mode 100644 index 0000000000..01598f96ba --- /dev/null +++ b/scripts/__dropins__/storefront-account/types/customerInformation.types.d.ts @@ -0,0 +1,61 @@ +import { SlotProps } from '@dropins/tools/types/elsie/src/lib'; +import { AttributesFormModel } from '../data/models'; +import { InLineAlertProps } from './notification.types'; +import { KeysSortOrderProps } from './addresses.types'; + +type PasswordConfigsProps = { + minLength: number; + requiredCharacterClasses: number; +} | null; +export type CustomerDataProps = KeysSortOrderProps & { + value: string | number | boolean; +}; +export interface CustomerDataContext { + customerData: CustomerDataProps[]; +} +export interface CustomerInformationProps { + className: string; + withHeader: boolean; + slots?: { + CustomerData?: SlotProps; + }; +} +export interface ChangePasswordProps { + inLineAlertProps: InLineAlertProps; + handleHideChangePassword: (clearState?: () => void) => void; + handleSetInLineAlert: (value?: InLineAlertProps) => void; +} +export interface CustomerInformationCardProps { + createdAt: string; + orderedCustomerData: CustomerDataProps[]; + slots?: { + CustomerData?: SlotProps; + }; + showChangePassword: boolean; + showEditForm: boolean; + handleShowChangePassword: () => void; + handleShowEditForm: () => void; +} +export interface EditCustomerInformationProps { + inLineAlertProps: InLineAlertProps; + errorPasswordEmpty: boolean; + passwordValue: string; + showPasswordOnEmailChange: boolean; + formFieldsList: AttributesFormModel[] | []; + submitLoading: boolean; + handleUpdateCustomerInformation: (event: SubmitEvent, isValid: boolean) => Promise; + handleHideEditForm: (clearState?: () => void) => void; + handleInputChange: (value: Record) => void; + handleSetPassword: (value: string) => void; + handleOnBlurPassword: (event: Event) => void; +} +export interface UseCustomerInformationProps { + handleSetInLineAlert: (value?: InLineAlertProps) => void; +} +export interface UseChangePasswordProps { + passwordConfigs: PasswordConfigsProps; + handleSetInLineAlert: (value?: InLineAlertProps) => void; + handleHideChangePassword: (clearState?: () => void) => void; +} +export {}; +//# sourceMappingURL=customerInformation.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/form.types.d.ts b/scripts/__dropins__/storefront-account/types/form.types.d.ts index af3d5e0165..fe3cc9d882 100644 --- a/scripts/__dropins__/storefront-account/types/form.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/form.types.d.ts @@ -47,6 +47,9 @@ export interface FormInputsProps { onChange?: (event: Event) => void; onBlur?: (event: Event) => void; onFocus?: (event: Event) => void; + slots?: { + [key: string]: SlotProps; + }; } export {}; //# sourceMappingURL=form.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/index.d.ts b/scripts/__dropins__/storefront-account/types/index.d.ts index 21d1924b67..ecfb5c1ab8 100644 --- a/scripts/__dropins__/storefront-account/types/index.d.ts +++ b/scripts/__dropins__/storefront-account/types/index.d.ts @@ -10,6 +10,10 @@ export * from './api/updateCustomerAddress.types'; export * from './api/getCustomer.types'; export * from './api/removeCustomerAddress.types'; export * from './api/getOrderHistoryList.types'; +export * from './api/updateCustomerPassword.types'; +export * from './api/storeConfig.types'; export * from './ordersList.types'; export * from './emptyList.types'; +export * from './customerInformation.types'; +export * from './notification.types'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/notification.types.d.ts b/scripts/__dropins__/storefront-account/types/notification.types.d.ts new file mode 100644 index 0000000000..ad69c8eca1 --- /dev/null +++ b/scripts/__dropins__/storefront-account/types/notification.types.d.ts @@ -0,0 +1,19 @@ +import { VNode } from 'preact'; +import { HTMLAttributes } from 'preact/compat'; + +export type AdditionalActionsAlertProps = Array<{ + label: string; + onClick: (event: Event) => void; +}>; +export interface InLineAlertProps { + type?: 'success' | 'warning' | 'error'; + text?: string; + icon?: VNode>; +} +export type statusTypes = '' | 'success' | 'error' | 'pending'; +export interface ValidateLengthConfigProps { + status?: statusTypes; + icon?: statusTypes; + message?: string; +} +//# sourceMappingURL=notification.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts index e50d5a2e57..e4fd484f5a 100644 --- a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts @@ -18,6 +18,11 @@ export interface OrdersListProps extends HTMLAttributes { }; routeOrdersList?: () => string; routeOrderDetails?: () => string; + routeReturnDetails?: (params: { + orderNumber: string; + orderToken: string; + returnNumber: string; + }) => string; withFilter?: boolean; ordersInMinifiedView?: 1 | 2 | 3; pageSize: number; @@ -35,6 +40,11 @@ export interface OrdersListCardProps extends HTMLAttributes { }; routeTracking?: (shipping: ShipmentsTracingModel) => string; routeOrderProduct?: (product: OrderItem) => string; + routeReturnDetails?: (params: { + orderNumber: string; + orderToken: string; + returnNumber: string; + }) => string; } export interface OrdersListActionProps { minifiedView: boolean; diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index b04b17341e..69462980d3 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,4 +1,6 @@ -import{Initializer as E}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{f as i,h as n}from"./chunks/fetch-graphql.js";import{g as x,r as P,s as U,a as Y,b as q}from"./chunks/fetch-graphql.js";import{h as m}from"./chunks/network-error.js";import{P as l,a as u,G as c,O as _,B as p,R as O,c as f}from"./chunks/transform-order-details.js";import{O as h,A as D}from"./chunks/getGuestOrder.graphql.js";import{t as T}from"./chunks/getCustomer.js";import{a as z,g as H}from"./chunks/getCustomer.js";import{g as j}from"./chunks/getAttributesForm.js";import{g as V}from"./chunks/getStoreConfig.js";import{g as X}from"./chunks/getCustomerOrdersReturn.js";import{c as ee,r as re}from"./chunks/requestGuestOrderCancel.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";const G=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{Initializer as I}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{f as n,h as m}from"./chunks/fetch-graphql.js";import{g as P,r as U,s as Y,a as q,b as Q}from"./chunks/fetch-graphql.js";import{h as l}from"./chunks/network-error.js";import{P as u,a as _,G as c,O as p,B as O,R as h,c as T}from"./chunks/transform-order-details.js";import{O as D,A as R}from"./chunks/getGuestOrder.graphql.js";import{t as G}from"./chunks/getCustomer.js";import{a as H,g as K}from"./chunks/getCustomer.js";import{g as J}from"./chunks/getAttributesForm.js";import{g as W}from"./chunks/getStoreConfig.js";import{g as Z}from"./chunks/getCustomerOrdersReturn.js";import{c as re,r as te}from"./chunks/requestGuestOrderCancel.js";import{r as se}from"./chunks/reorderItems.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";const b=` query ORDER_BY_NUMBER($orderNumber: String!) { customer { orders( @@ -84,15 +86,15 @@ query ORDER_BY_NUMBER($orderNumber: String!) { } } } -${l} ${u} -${c} ${_} +${c} ${p} -${h} -${D} ${O} -`,I=async(e,r)=>await i(G,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?n(t.errors):f(r??"orderData",t)}).catch(m),b=` +${D} +${R} +${h} +`,f=async(e,r,t)=>await n(b,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(a=>{var s;return(s=a.errors)!=null&&s.length?m(a.errors):T(t??"orderData",a,r)}).catch(l),y=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -178,12 +180,12 @@ query ORDER_BY_TOKEN($token: String!) { } } } -${l} ${u} -${c} ${_} +${c} ${p} -${h} -${D} ${O} -`,g=async e=>await i(b,{method:"GET",cache:"no-cache",variables:{token:e}}).then(r=>{var t;return(t=r.errors)!=null&&t.length?n(r.errors):T(r)}).catch(m),y=async e=>{var o;const r=(e==null?void 0:e.orderRef)??"",t=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((o=e==null?void 0:e.orderRef)==null?void 0:o.length)>20,a=(e==null?void 0:e.orderData)??null;if(a){s.emit("order/data",a);return}if(!r){console.error("Order Token or number not received.");return}const d=t?await g(r):await I(r);d?s.emit("order/data",d):s.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},R=new E({init:async e=>{const r={};R.config.setConfig({...r,...e}),y(e).catch(console.error)},listeners:()=>[]}),M=R.config;export{ee as cancelOrder,M as config,i as fetchGraphQl,j as getAttributesForm,x as getConfig,z as getCustomer,X as getCustomerOrdersReturn,H as getGuestOrder,I as getOrderDetailsById,V as getStoreConfig,g as guestOrderByToken,R as initialize,P as removeFetchGraphQlHeader,re as requestGuestOrderCancel,U as setEndpoint,Y as setFetchGraphQlHeader,q as setFetchGraphQlHeaders}; +${D} +${R} +${h} +`,A=async(e,r)=>await n(y,{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),$=async e=>{var i;const r=(e==null?void 0:e.orderRef)??"",t=(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){d.emit("order/data",{...s,returnNumber:t});return}if(!r){console.error("Order Token or number not received.");return}const o=a?await A(r,t):await f(r,t,"orderData");o?d.emit("order/data",{...o,returnNumber:t}):d.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}),$(e).catch(console.error)},listeners:()=>[]}),v=E.config;export{re as cancelOrder,v as config,n as fetchGraphQl,J as getAttributesForm,P as getConfig,H as getCustomer,Z as getCustomerOrdersReturn,K as getGuestOrder,f as getOrderDetailsById,W as getStoreConfig,A as guestOrderByToken,E as initialize,U as removeFetchGraphQlHeader,se as reorderItems,te as requestGuestOrderCancel,Y as setEndpoint,q as setFetchGraphQlHeader,Q as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/getOrderDetailsById.d.ts b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/getOrderDetailsById.d.ts index b86f40f175..d06579bdaa 100644 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/getOrderDetailsById.d.ts +++ b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/getOrderDetailsById.d.ts @@ -1,4 +1,4 @@ import { TransformedData } from '../../data/models'; -export declare const getOrderDetailsById: (orderId?: string, queryType?: T | undefined) => Promise>; +export declare const getOrderDetailsById: (orderId?: string, returnRef?: string, queryType?: T | undefined) => Promise>; //# sourceMappingURL=getOrderDetailsById.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 index cb7cc6ceea..32e34d1e89 100644 --- a/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const RETURNS_FRAGMENT = "\n fragment OrderReturns on Returns {\n __typename\n items {\n number\n status\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"; +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/guestOrderByToken/guestOrderByToken.d.ts b/scripts/__dropins__/storefront-order/api/guestOrderByToken/guestOrderByToken.d.ts index 03d25258fb..2c69a8a610 100644 --- a/scripts/__dropins__/storefront-order/api/guestOrderByToken/guestOrderByToken.d.ts +++ b/scripts/__dropins__/storefront-order/api/guestOrderByToken/guestOrderByToken.d.ts @@ -1,4 +1,4 @@ import { OrderDataModel } from '../../data/models'; -export declare const guestOrderByToken: (token?: string) => Promise; +export declare const guestOrderByToken: (token?: string, returnRef?: string) => Promise; //# sourceMappingURL=guestOrderByToken.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 ff703dfa8b..0bdab16aa0 100644 --- a/scripts/__dropins__/storefront-order/api/index.d.ts +++ b/scripts/__dropins__/storefront-order/api/index.d.ts @@ -9,4 +9,5 @@ export * from './getStoreConfig'; export * from './getCustomerOrdersReturn'; export * from './cancelOrder'; export * from './requestGuestOrderCancel'; +export * from './reorderItems'; //# sourceMappingURL=index.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 new file mode 100644 index 0000000000..d1743c1dca --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/reorderItems/graphql/reorderItems.graphql.d.ts @@ -0,0 +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"; +//# sourceMappingURL=reorderItems.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/reorderItems/index.d.ts b/scripts/__dropins__/storefront-order/api/reorderItems/index.d.ts new file mode 100644 index 0000000000..7b7db498bd --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/reorderItems/index.d.ts @@ -0,0 +1,2 @@ +export * from './reorderItems'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/reorderItems/reorderItems.d.ts b/scripts/__dropins__/storefront-order/api/reorderItems/reorderItems.d.ts new file mode 100644 index 0000000000..cb5497ee51 --- /dev/null +++ b/scripts/__dropins__/storefront-order/api/reorderItems/reorderItems.d.ts @@ -0,0 +1,4 @@ +import { ReorderItemsProps } from '../../types/api/reorderItems.types'; + +export declare const reorderItems: (orderNumber: string) => Promise; +//# sourceMappingURL=reorderItems.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/OrderCancel.js b/scripts/__dropins__/storefront-order/chunks/OrderCancel.js index 86adcf991d..80820a2827 100644 --- a/scripts/__dropins__/storefront-order/chunks/OrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/OrderCancel.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsx as h,Fragment as v,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as _,useState as D,useEffect as w,useCallback as T}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as C from"@dropins/tools/preact-compat.js";import{memo as V,useCallback as L}from"@dropins/tools/preact-compat.js";import{classes as k}from"@dropins/tools/lib.js";import{Field as q,Picker as A,Input as I,InputDate as R,Checkbox as O,TextArea as N}from"@dropins/tools/components.js";const j=l=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.8052 14.4968C10.8552 14.4968 9.9752 14.0268 9.4452 13.2368L9.4152 13.1868L9.3852 13.1268C8.1352 11.2268 7.5352 8.96681 7.6852 6.68681C7.7552 4.42681 9.6052 2.61681 11.8652 2.60681H12.0052C14.2752 2.47681 16.2152 4.21681 16.3452 6.47681C16.3452 6.55681 16.3452 6.62681 16.3452 6.70681C16.4852 8.94681 15.9052 11.1768 14.6852 13.0568L14.6052 13.1768C14.0552 13.9868 13.1352 14.4668 12.1652 14.4768H12.0052C11.9352 14.4768 11.8652 14.4868 11.7952 14.4868L11.8052 14.4968Z",stroke:"currentColor"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M4.3252 21.5469C4.3552 20.4169 4.4752 19.2869 4.6752 18.1769C4.8952 17.1669 6.4752 16.0269 8.9052 15.1569C9.2352 15.0369 9.4852 14.7869 9.5952 14.4569L9.8052 14.0269",stroke:"currentColor"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.425 14.4069L14.165 14.1569C14.375 14.5969 14.725 14.9569 15.155 15.1869C16.945 15.7969 19.125 16.9569 19.375 18.2069C19.585 19.3069 19.685 20.4269 19.675 21.5369",stroke:"currentColor"})),H=l=>l.reduce((u,{code:i,required:$,defaultValue:c})=>($&&(u[i]=c),u),{}),S=({fieldsConfig:l,onSubmit:u})=>{const{requiredFieldError:i}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),$=_(null),[c,n]=D({}),[o,t]=D({});w(()=>{if(n({}),!l||!l.length)return;const s=H(l);n(s)},[l==null?void 0:l.length]),w(()=>()=>{var s;n({}),(s=$.current)==null||s.reset()},[]);const p=T((s,e)=>{const r=l.find(d=>d.code===s);return r!=null&&r.required&&!e?i:""},[l,i]),b=T(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,f=a==="checkbox"?d:r;n(E=>({...E,[e]:f}))},[]),x=T(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,f=a==="checkbox"?d:r;t(E=>({...E,[e]:p(e,f)}))},[p]),F=T(s=>{s.preventDefault();let e=!0,r={},a=null;for(const[d,f]of Object.entries(c)){const E=p(d,f);E&&(r[d]=E,e=!1,a||(a=d))}if(t(r),a&&$.current){const d=$.current.elements.namedItem(a);d==null||d.focus()}u==null||u(s,e)},[c,p,u]);return{formData:c,errors:o,formRef:$,handleChange:b,handleBlur:x,handleSubmit:F}},U=V(({loading:l,values:u,fields:i=[],errors:$,className:c="",onChange:n,onBlur:o})=>{const t=`${c}__item`,p=L((e,r,a)=>{const d=e.options.map(f=>({text:f.label,value:f.value}));return h(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:h(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:n,value:r||e.defaultValue})},e.id)},[c,l,t,o,n]),b=L((e,r,a)=>{const d=e.id==="email",f=d?h(j,{}):void 0,E=d?"username":"";return h(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:h(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:f,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id)},[c,l,t,o,n]),x=L((e,r,a)=>h(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:h(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]),F=L((e,r,a)=>h(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:h(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]),s=L((e,r,a)=>h(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:h(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]);return i.length?h(v,{children:i.map(e=>{var d;const r=($==null?void 0:$[e.id])??"",a=(u==null?void 0:u[e.id])??"";switch(e.fieldType){case"TEXT":return(d=e==null?void 0:e.options)!=null&&d.length?p(e,a,r):b(e,a,r);case"MULTILINE":return b(e,a,r);case"SELECT":return p(e,a,r);case"DATE":return x(e,a,r);case"BOOLEAN":return F(e,a,r);case"TEXTAREA":return s(e,a,r);default:return null}})}):null}),K=V(({name:l,loading:u,children:i,className:$="defaultForm",fieldsConfig:c,onSubmit:n})=>{const{formData:o,errors:t,formRef:p,handleChange:b,handleBlur:x,handleSubmit:F}=S({fieldsConfig:c,onSubmit:n});return M("form",{className:k(["order-form",$]),onSubmit:F,name:l,ref:p,children:[h(U,{className:$,loading:u,fields:c,onChange:b,onBlur:x,errors:t,values:o}),i]})});export{K as F}; diff --git a/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js b/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js index eaed8403d5..3d4677af97 100644 --- a/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/chunks/OrderCancelForm.js @@ -1 +1,3 @@ -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"@dropins/tools/preact-compat.js";import{useState as n}from"@dropins/tools/preact-hooks.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}; +/*! 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-compat.js";import"@dropins/tools/preact.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 43667a604f..abd7886ea4 100644 --- a/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js +++ b/scripts/__dropins__/storefront-order/chunks/OrderLoaders.js @@ -1 +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,f as O,v as a}; diff --git a/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js new file mode 100644 index 0000000000..6f2cdf54c1 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/ReturnsListContent.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r,jsxs as s,Fragment as o}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as H}from"@dropins/tools/preact-hooks.js";import{classes as W,Slot as G}from"@dropins/tools/lib.js";import{IllustratedMessage as K,Icon as y,Card as k,ContentGrid as R,Image as D,Header as I,Pagination as r1}from"@dropins/tools/components.js";import*as l from"@dropins/tools/preact-compat.js";import{useMemo as e1}from"@dropins/tools/preact-compat.js";import"./OrderCancel.js";import{f as n1}from"./returnOrdersHelper.js";import"@dropins/tools/event-bus.js";import{C as O}from"./OrderLoaders.js";import"@dropins/tools/preact.js";import{Text as U}from"@dropins/tools/i18n.js";const q=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"})))),t1=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"})),J=({typeList:L,isEmpty:C,minifiedView:M,message:n})=>{const t=e1(()=>{switch(L){case"orders":return{icon:t1,text:r("p",{children:n}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[L,n]);return!C||!L||!t.text?null:r(K,{className:W(["order-empty-list",t.className,M?"order-empty-list--minified":""]),message:t.text,icon:r(y,{source:t.icon}),"data-testid":"emptyList"})},Q={size:"32",stroke:"2"},M1=({minifiedViewKey:L,withReturnNumber:C=!1,withOrderNumber:M=!1,slots:n,pageInfo:t,withReturnsListButton:E=!0,isMobile:b=!1,returnsInMinifiedView:X=1,translations:a={},orderReturns:i=[],minifiedView:h=!1,withHeader:Z=!0,withThumbnails:w=!0,selectedPage:$=1,handleSetSelectPage:V,routeReturnDetails:m,routeOrderDetails:p,routeTracking:_,routeReturnsList:g,routeProductDetails:d,loading:N})=>{const A=h?X:i.length,B=d!=null&&d()?"a":"span",f=H(()=>i.slice(0,A).map((e,T)=>{var S,z;return r(k,{variant:"secondary",className:"order-returns-list-content__cards-list",children:s("div",{className:"order-returns-list-content__cards-grid",children:[s("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(U,{id:`Order.Returns.${L}.returnsList.resturnStatus.${n1(e.returnStatus)}`})}),C?s("p",{children:[a.returnNumber," ",r("a",{href:(m==null?void 0:m({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,M?s("p",{children:[a.orderNumber," ",r("a",{href:(p==null?void 0:p({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(S=e==null?void 0:e.tracking)==null?void 0:S.map((c,x)=>{var u,v;return s("p",{children:[`${a.carrier} ${(v=(u=c==null?void 0:c.carrier)==null?void 0:u.label)==null?void 0:v.toLocaleUpperCase()}: `,r("a",{href:`${(_==null?void 0:_(c))||"#"}`,target:"_blank",rel:"noreferrer",children:c.trackingNumber})]},`${c.trackingNumber}_${x}`)}),n!=null&&n.ReturnItemsDetails?r(G,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:n==null?void 0:n.ReturnItemsDetails,context:{items:e.items}}):e.items.length?s("p",{children:[e.items.length," ",r(U,{id:`Order.Returns.${L}.returnsList.itemText`,plural:e.items.length,fields:{count:e.items.length}})]}):null]}),w?r(R,{maxColumns:b?3:9,emptyGridContent:r(o,{}),className:W(["order-returns-list-content__images",["order-returns-list-content__images-3",b]]),children:(z=e==null?void 0:e.items)==null?void 0:z.map((c,x)=>{var j,F;const u=(j=c.thumbnail)==null?void 0:j.label,v=(F=c.thumbnail)==null?void 0:F.url;return r(B,{href:(d==null?void 0:d(c))??"#",children:r(D,{alt:u,src:v,width:85,height:114})},x+c.uid)})}):null,n!=null&&n.DetailsActionParams?r(G,{className:"order-returns-list-content__actions","data-testid":"detailsActionParams",name:"DetailsActionParams",slot:n==null?void 0:n.DetailsActionParams,context:{returnOrderItem:e}}):r("a",{href:(m==null?void 0:m({returnNumber:e.returnNumber,token:e.token,orderNumber:e.orderNumber}))??"#",className:"order-returns-list-content__actions",children:r(y,{source:q,...Q})})]})},T)}),[i,A,L,C,a,m,M,p,n,w,b,d,_,B]),Y=H(()=>s(o,{children:[Z?r(I,{title:a.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,N?r(O,{withCard:!1}):s(o,{children:[f,r(J,{minifiedView:h,typeList:"orders",isEmpty:!i.length,message:a.emptyOrdersListMessage}),E?r("a",{className:"order-returns-list-content__actions",href:(g==null?void 0:g())??"#",children:r(k,{variant:"secondary",className:"order-returns-list-content__card",children:s("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:a.viewAllOrdersButton}),r(y,{source:q,...Q})]})})}):null]})]}),[g,E,Z,a,f,h,i.length,N]),P=H(()=>s(o,{children:[Z?r(I,{title:a.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,N?r(O,{withCard:!1}):s(o,{children:[r(J,{minifiedView:h,typeList:"orders",isEmpty:!i.length,message:a.emptyOrdersListMessage}),f,(t==null?void 0:t.totalPages)>1?r(r1,{totalPages:t==null?void 0:t.totalPages,currentPage:$,onChange:V}):null]})]}),[f,h,i,a,t,$,V,N,Z]);return r("div",{className:"order-returns-list-content",children:h?Y:P})};export{M1 as R}; diff --git a/scripts/__dropins__/storefront-order/chunks/convertCase.js b/scripts/__dropins__/storefront-order/chunks/convertCase.js index 7b19e142ba..7401b56b25 100644 --- a/scripts/__dropins__/storefront-order/chunks/convertCase.js +++ b/scripts/__dropins__/storefront-order/chunks/convertCase.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ const b=s=>s.replace(/_([a-z])/g,(o,e)=>e.toUpperCase()),c=(s,o,e)=>{const u=["string","boolean","number"],p=b;return Array.isArray(s)?s.map(r=>u.includes(typeof r)||r===null?r:typeof r=="object"?c(r,o,e):r):s!==null&&typeof s=="object"?Object.entries(s).reduce((r,[t,n])=>{const f=e&&e[t]?e[t]:p(t);return r[f]=u.includes(typeof n)||n===null?n:c(n,o,e),r},{}):s};export{c as a,b as c}; diff --git a/scripts/__dropins__/storefront-order/chunks/fetch-graphql.js b/scripts/__dropins__/storefront-order/chunks/fetch-graphql.js index b405754305..75489de79e 100644 --- a/scripts/__dropins__/storefront-order/chunks/fetch-graphql.js +++ b/scripts/__dropins__/storefront-order/chunks/fetch-graphql.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{FetchGraphQL as s}from"@dropins/tools/fetch-graphql.js";const h=e=>{const r=e.map(a=>a.message).join(" ");throw Error(r)},{setEndpoint:o,setFetchGraphQlHeader:c,removeFetchGraphQlHeader:n,setFetchGraphQlHeaders:p,fetchGraphQl:d,getConfig:g}=new s().getMethods();export{c as a,p as b,d as f,g,h,n as r,o as s}; diff --git a/scripts/__dropins__/storefront-order/chunks/formatDateToLocale.js b/scripts/__dropins__/storefront-order/chunks/formatDateToLocale.js new file mode 100644 index 0000000000..a6dca51049 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/formatDateToLocale.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const m=(e,a="en-US",o={})=>{const n={...{day:"2-digit",month:"2-digit",year:"numeric"},...o},t=new Date(e);return isNaN(t.getTime())?"Invalid Date":new Intl.DateTimeFormat(a,n).format(t)};export{m as f}; diff --git a/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js b/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js index c423ea40dd..3f61b8c1dd 100644 --- a/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js +++ b/scripts/__dropins__/storefront-order/chunks/getAttributesForm.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{h as l}from"./network-error.js";import{f as m,h as _}from"./fetch-graphql.js";import{c as f,a as T}from"./convertCase.js";const b=o=>{let e=[];for(const t of o)if(!(t.frontend_input!=="MULTILINE"||t.multiline_count<2))for(let i=2;i<=t.multiline_count;i++){const a={...t,name:`${t.code}_${i}`,code:`${t.code}_${i}`,id:`${t.code}_${i}`};e.push(a)}return e},h=o=>{var u,c,d;const e=((c=(u=o==null?void 0:o.data)==null?void 0:u.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const t=(d=e.filter(r=>{var n;return!((n=r.frontend_input)!=null&&n.includes("HIDDEN"))}))==null?void 0:d.map(({code:r,...n})=>{const s=r!=="country_id"?r:"country_code";return{...n,name:s,id:s,code:s}}),i=b(t);return t.concat(i).map(r=>{const n=f(r.code);return T({...r,customUpperCode:n},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((r,n)=>r.orderNumber-n.orderNumber)},E=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomer.js b/scripts/__dropins__/storefront-order/chunks/getCustomer.js index 6351463d47..12e7d94435 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomer.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomer.js @@ -1,4 +1,6 @@ -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=>{var r,u;if(!((r=t==null?void 0:t.data)!=null&&r.guestOrder))return null;const a=(u=t==null?void 0:t.data)==null?void 0:u.guestOrder;return l(a)},k=t=>{var r,u;if(!((r=t==null?void 0:t.data)!=null&&r.guestOrderByToken))return null;const a=(u=t==null?void 0:t.data)==null?void 0:u.guestOrderByToken;return l(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=` +/*! 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 diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js index e5c626a509..790ac7bf5e 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{h as R}from"./network-error.js";import{f as e,h as E}from"./fetch-graphql.js";import{R as _,P as T,a as o,G as s,O as c,t as u}from"./transform-order-details.js";const h=` query GET_CUSTOMER_ORDERS_RETURN { customer { diff --git a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js index 56cf6d80e5..a9383424b9 100644 --- a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js +++ b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.graphql.js @@ -1,3 +1,5 @@ +/*! 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 { diff --git a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js index da8e0df02d..a3e3933f13 100644 --- a/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-order/chunks/getStoreConfig.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as i,h as s}from"./fetch-graphql.js";function n(p){return p?{orderCancellationEnabled:p.order_cancellation_enabled,orderCancellationReasons:p.order_cancellation_reasons,shoppingCartDisplayPrice:p.shopping_cart_display_price,shoppingOrdersDisplaySubtotal:p.shopping_cart_display_subtotal,shoppingOrdersDisplayShipping:p.shopping_cart_display_shipping,shoppingOrdersDisplayGrandTotal:p.shopping_cart_display_grand_total,shoppingOrdersDisplayTaxGiftWrapping:p.shopping_cart_display_tax_gift_wrapping,shoppingOrdersDisplayFullSummary:p.shopping_cart_display_full_summary,shoppingOrdersDisplayZeroTax:p.shopping_cart_display_zero_tax}:null}const a=` query STORE_CONFIG_QUERY { storeConfig { diff --git a/scripts/__dropins__/storefront-order/chunks/network-error.js b/scripts/__dropins__/storefront-order/chunks/network-error.js index e796708ca2..b7780a4913 100644 --- a/scripts/__dropins__/storefront-order/chunks/network-error.js +++ b/scripts/__dropins__/storefront-order/chunks/network-error.js @@ -1 +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}; diff --git a/scripts/__dropins__/storefront-order/chunks/redirectTo.js b/scripts/__dropins__/storefront-order/chunks/redirectTo.js new file mode 100644 index 0000000000..70554833ed --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/redirectTo.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const a=(e,n,r)=>{if(typeof e!="function")return;const t=e(r);if(!n||Object.keys(n).length===0){window.location.href=t;return}const o=new URLSearchParams;Object.entries(n).forEach(([i,s])=>{o.append(i,String(s))});const c=t.includes("?")?"&":"?";window.location.href=`${t}${c}${o.toString()}`};export{a as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/reorderItems.js b/scripts/__dropins__/storefront-order/chunks/reorderItems.js new file mode 100644 index 0000000000..00cd1961a1 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/reorderItems.js @@ -0,0 +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 + } + } + } + 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 31857f9aaa..e01dd91a6e 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,3 +1,5 @@ +/*! 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 }) { diff --git a/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js new file mode 100644 index 0000000000..b4ba3d8a05 --- /dev/null +++ b/scripts/__dropins__/storefront-order/chunks/returnOrdersHelper.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const E={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"},t=e=>typeof e!="string"?"":E[e]??"";export{t as f}; diff --git a/scripts/__dropins__/storefront-order/chunks/setTaxStatus.js b/scripts/__dropins__/storefront-order/chunks/setTaxStatus.js index 8a463a1e70..afa80511a9 100644 --- a/scripts/__dropins__/storefront-order/chunks/setTaxStatus.js +++ b/scripts/__dropins__/storefront-order/chunks/setTaxStatus.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ const s=t=>{let e=!1,a=!1;switch(t){case 1:a=!0;break;case 2:e=!0;break;case 3:e=!0,a=!0;break;default:e=!1,a=!1}return{taxIncluded:e,taxExcluded:a}};export{s}; diff --git a/scripts/__dropins__/storefront-order/chunks/transform-order-details.js b/scripts/__dropins__/storefront-order/chunks/transform-order-details.js index 214cb49425..b07a982a39 100644 --- a/scripts/__dropins__/storefront-order/chunks/transform-order-details.js +++ b/scripts/__dropins__/storefront-order/chunks/transform-order-details.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{a as F}from"./convertCase.js";const J=` fragment ProductDetails on ProductInterface { __typename @@ -100,6 +102,7 @@ import{a as F}from"./convertCase.js";const J=` items { number status + created_at shipping { tracking { status { @@ -134,4 +137,4 @@ import{a as F}from"./convertCase.js";const J=` } } } -`,B=n=>{var s;if(!((s=n==null?void 0:n.items)!=null&&s.length))return null;const a=n==null?void 0:n.items,u=n==null?void 0:n.page_info;return{ordersReturn:a.map(l=>{var f,b;const{order:_,status:t,number:y}=l,v=((b=(f=l==null?void 0:l.shipping)==null?void 0:f.tracking)==null?void 0:b.map(i=>{const{status:p,carrier:g,tracking_number:q}=i;return{status:p,carrier:g,trackingNumber:q}}))??[],O=l.items.map(i=>{var h;const p=i==null?void 0:i.quantity,g=i==null?void 0:i.status,q=i==null?void 0:i.request_quantity,e=i==null?void 0:i.uid,R=i==null?void 0:i.order_item,E=((h=M([R]))==null?void 0:h.reduce((T,N)=>N,{}))??{};return{uid:e,quantity:p,status:g,requestQuantity:q,orderItem:E}});return{returnStatus:t,token:_==null?void 0:_.token,orderNumber:_==null?void 0:_.number,returnNumber:y,items:O,tracking:v}}),...u?{pageInfo:{pageSize:u.page_size,totalPages:u.total_pages,currentPage:u.current_page}}:{}}},U=n=>n||0,Q=n=>{var a,u,c;return{...n,canonicalUrl:(n==null?void 0:n.canonical_url)||"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((u=n==null?void 0:n.thumbnail)==null?void 0:u.label)||"",url:((c=n==null?void 0:n.thumbnail)==null?void 0:c.url)||""}}},j=n=>{if(!n||!("selected_options"in n))return;const a={};for(const u of n.selected_options)a[u.label]=u.value;return a},w=n=>{const a=n==null?void 0:n.map(c=>({uid:c.uid,label:c.label,values:c.values.map(s=>s.product_name).join(", ")})),u={};return a==null||a.forEach(c=>{u[c.label]=c.values}),Object.keys(u).length>0?u:null},K=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(a=>a.title).join(", ")}:null,M=n=>n==null?void 0:n.filter(a=>a.__typename).map(a=>{var u,c,s,l,_,t,y,v,O,f,b,i,p,g,q,e,R,E,h,T,N,k,C,D,P,G,A,x,S,L;return{type:a==null?void 0:a.__typename,productName:a.product_name,productUrlKey:a.product_url_key,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,id:a==null?void 0:a.id,discounted:((l=(s=(c=(u=a==null?void 0:a.product)==null?void 0:u.price_range)==null?void 0:c.maximum_price)==null?void 0:s.regular_price)==null?void 0:l.value)*(a==null?void 0:a.quantity_ordered)!==((_=a==null?void 0:a.product_sale_price)==null?void 0:_.value)*(a==null?void 0:a.quantity_ordered),total:{value:((t=a==null?void 0:a.product_sale_price)==null?void 0:t.value)*(a==null?void 0:a.quantity_ordered)||0,currency:((y=a==null?void 0:a.product_sale_price)==null?void 0:y.currency)||""},totalInclTax:{value:((v=a==null?void 0:a.product_sale_price)==null?void 0:v.value)*(a==null?void 0:a.quantity_ordered)||0,currency:(O=a==null?void 0:a.product_sale_price)==null?void 0:O.currency},price:{value:((f=a==null?void 0:a.product_sale_price)==null?void 0:f.value)||0,currency:(b=a==null?void 0:a.product_sale_price)==null?void 0:b.currency},priceInclTax:{value:((i=a==null?void 0:a.product_sale_price)==null?void 0:i.value)||0,currency:(p=a==null?void 0:a.product_sale_price)==null?void 0:p.currency},totalQuantity:U(a==null?void 0:a.quantity_ordered),regularPrice:{value:(R=(e=(q=(g=a==null?void 0:a.product)==null?void 0:g.price_range)==null?void 0:q.maximum_price)==null?void 0:e.regular_price)==null?void 0:R.value,currency:(N=(T=(h=(E=a==null?void 0:a.product)==null?void 0:E.price_range)==null?void 0:h.maximum_price)==null?void 0:T.regular_price)==null?void 0:N.currency},product:Q(a==null?void 0:a.product),thumbnail:{label:((C=(k=a==null?void 0:a.product)==null?void 0:k.thumbnail)==null?void 0:C.label)||"",url:((P=(D=a==null?void 0:a.product)==null?void 0:D.thumbnail)==null?void 0:P.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((G=a.gift_card)==null?void 0:G.sender_name)||"",senderEmail:((A=a.gift_card)==null?void 0:A.sender_email)||"",recipientEmail:((x=a.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((S=a.gift_card)==null?void 0:S.recipient_name)||"",message:((L=a.gift_card)==null?void 0:L.message)||""}:void 0,configurableOptions:j(a),bundleOptions:a.__typename==="BundleOrderItem"?w(a.bundle_options):null,itemPrices:a.prices,downloadableLinks:a.__typename==="DownloadableOrderItem"?K(a==null?void 0:a.downloadable_links):null}}),z=n=>{var O,f,b,i,p,g;const a=M(n.items),u=((O=B(n==null?void 0:n.returns))==null?void 0:O.ordersReturn)??[],{total:c,...s}=F({...n,items:a,returns:u},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(f=n==null?void 0:n.payment_methods)==null?void 0:f[0],_=(l==null?void 0:l.type)||"",t=(l==null?void 0:l.name)||"",y=(b=s==null?void 0:s.items)==null?void 0:b.reduce((q,e)=>q+(e==null?void 0:e.totalQuantity),0);return{...c,...s,totalQuantity:y,shipping:{amount:((i=s==null?void 0:s.total)==null?void 0:i.totalShipping.value)??0,currency:((g=(p=s.total)==null?void 0:p.totalShipping)==null?void 0:g.currency)||"",code:s.shippingMethod??""},payments:[{code:_,name:t}]}},$=(n,a)=>{var u,c,s,l,_,t,y;if((l=(s=(c=(u=a==null?void 0:a.data)==null?void 0:u.customer)==null?void 0:c.orders)==null?void 0:s.items)!=null&&l.length&&n==="orderData"){const v=(y=(t=(_=a==null?void 0:a.data)==null?void 0:_.customer)==null?void 0:t.orders)==null?void 0:y.items[0];return z(v)}return null};export{Y as B,W as G,X as O,J as P,Z as R,V as a,z as b,$ as c,B as t}; +`,B=n=>{var t;if(!((t=n==null?void 0:n.items)!=null&&t.length))return null;const a=n==null?void 0:n.items,s=n==null?void 0:n.page_info;return{ordersReturn:a.map(l=>{var q,v;const{order:i,status:_,number:y,created_at:p}=l,b=((v=(q=l==null?void 0:l.shipping)==null?void 0:q.tracking)==null?void 0:v.map(u=>{const{status:g,carrier:f,tracking_number:e}=u;return{status:g,carrier:f,trackingNumber:e}}))??[],h=l.items.map(u=>{var N;const g=u==null?void 0:u.quantity,f=u==null?void 0:u.status,e=u==null?void 0:u.request_quantity,O=u==null?void 0:u.uid,R=u==null?void 0:u.order_item,E=((N=M([R]))==null?void 0:N.reduce((k,T)=>T,{}))??{};return{uid:O,quantity:g,status:f,requestQuantity:e,...E}});return{createdReturnAt:p,returnStatus:_,token:i==null?void 0:i.token,orderNumber:i==null?void 0:i.number,returnNumber:y,items:h,tracking:b}}).sort((l,i)=>+i.returnNumber-+l.returnNumber),...s?{pageInfo:{pageSize:s.page_size,totalPages:s.total_pages,currentPage:s.current_page}}:{}}},U=n=>n||0,Q=n=>{var a,s,c;return{...n,canonicalUrl:(n==null?void 0:n.canonical_url)||"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((s=n==null?void 0:n.thumbnail)==null?void 0:s.label)||"",url:((c=n==null?void 0:n.thumbnail)==null?void 0:c.url)||""}}},j=n=>{if(!n||!("selected_options"in n))return;const a={};for(const s of n.selected_options)a[s.label]=s.value;return a},w=n=>{const a=n==null?void 0:n.map(c=>({uid:c.uid,label:c.label,values:c.values.map(t=>t.product_name).join(", ")})),s={};return a==null||a.forEach(c=>{s[c.label]=c.values}),Object.keys(s).length>0?s:null},K=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(a=>a.title).join(", ")}:null,M=n=>n==null?void 0:n.filter(a=>a.__typename).map(a=>{var s,c,t,l,i,_,y,p,b,h,q,v,u,g,f,e,O,R,E,N,k,T,C,D,P,A,G,x,S,L;return{type:a==null?void 0:a.__typename,productName:a.product_name,productUrlKey:a.product_url_key,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,id:a==null?void 0:a.id,discounted:((l=(t=(c=(s=a==null?void 0:a.product)==null?void 0:s.price_range)==null?void 0:c.maximum_price)==null?void 0:t.regular_price)==null?void 0:l.value)*(a==null?void 0:a.quantity_ordered)!==((i=a==null?void 0:a.product_sale_price)==null?void 0:i.value)*(a==null?void 0:a.quantity_ordered),total:{value:((_=a==null?void 0:a.product_sale_price)==null?void 0:_.value)*(a==null?void 0:a.quantity_ordered)||0,currency:((y=a==null?void 0:a.product_sale_price)==null?void 0:y.currency)||""},totalInclTax:{value:((p=a==null?void 0:a.product_sale_price)==null?void 0:p.value)*(a==null?void 0:a.quantity_ordered)||0,currency:(b=a==null?void 0:a.product_sale_price)==null?void 0:b.currency},price:{value:((h=a==null?void 0:a.product_sale_price)==null?void 0:h.value)||0,currency:(q=a==null?void 0:a.product_sale_price)==null?void 0:q.currency},priceInclTax:{value:((v=a==null?void 0:a.product_sale_price)==null?void 0:v.value)||0,currency:(u=a==null?void 0:a.product_sale_price)==null?void 0:u.currency},totalQuantity:U(a==null?void 0:a.quantity_ordered),regularPrice:{value:(O=(e=(f=(g=a==null?void 0:a.product)==null?void 0:g.price_range)==null?void 0:f.maximum_price)==null?void 0:e.regular_price)==null?void 0:O.value,currency:(k=(N=(E=(R=a==null?void 0:a.product)==null?void 0:R.price_range)==null?void 0:E.maximum_price)==null?void 0:N.regular_price)==null?void 0:k.currency},product:Q(a==null?void 0:a.product),thumbnail:{label:((C=(T=a==null?void 0:a.product)==null?void 0:T.thumbnail)==null?void 0:C.label)||"",url:((P=(D=a==null?void 0:a.product)==null?void 0:D.thumbnail)==null?void 0:P.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((A=a.gift_card)==null?void 0:A.sender_name)||"",senderEmail:((G=a.gift_card)==null?void 0:G.sender_email)||"",recipientEmail:((x=a.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((S=a.gift_card)==null?void 0:S.recipient_name)||"",message:((L=a.gift_card)==null?void 0:L.message)||""}:void 0,configurableOptions:j(a),bundleOptions:a.__typename==="BundleOrderItem"?w(a.bundle_options):null,itemPrices:a.prices,downloadableLinks:a.__typename==="DownloadableOrderItem"?K(a==null?void 0:a.downloadable_links):null}}),z=(n,a)=>{var q,v,u,g,f,e;const s=M(n.items),c=((q=B(n==null?void 0:n.returns))==null?void 0:q.ordersReturn)??[],t=a?c.filter(O=>O.returnNumber===a):c,{total:l,...i}=F({...n,items:s,returns:t},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),_=(v=n==null?void 0:n.payment_methods)==null?void 0:v[0],y=(_==null?void 0:_.type)||"",p=(_==null?void 0:_.name)||"",b=(u=i==null?void 0:i.items)==null?void 0:u.reduce((O,R)=>O+(R==null?void 0:R.totalQuantity),0);return{...l,...i,totalQuantity:b,shipping:{amount:((g=i==null?void 0:i.total)==null?void 0:g.totalShipping.value)??0,currency:((e=(f=i.total)==null?void 0:f.totalShipping)==null?void 0:e.currency)||"",code:i.shippingMethod??""},payments:[{code:y,name:p}]}},$=(n,a,s)=>{var c,t,l,i,_,y,p;if((i=(l=(t=(c=a==null?void 0:a.data)==null?void 0:c.customer)==null?void 0:t.orders)==null?void 0:l.items)!=null&&i.length&&n==="orderData"){const b=(p=(y=(_=a==null?void 0:a.data)==null?void 0:_.customer)==null?void 0:y.orders)==null?void 0:p.items[0];return z(b,s)}return null};export{Y as B,W as G,X as O,J as P,Z as R,V as a,z as b,$ as c,B as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/useIsMobile.js b/scripts/__dropins__/storefront-order/chunks/useIsMobile.js index 976df87285..9f24ca2937 100644 --- a/scripts/__dropins__/storefront-order/chunks/useIsMobile.js +++ b/scripts/__dropins__/storefront-order/chunks/useIsMobile.js @@ -1 +1,3 @@ -import{jsx as r,jsxs as a,Fragment as p}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as A,useState as X,useCallback as K,useEffect as r1}from"@dropins/tools/preact-hooks.js";import{classes as F,Slot as T,debounce as e1}from"@dropins/tools/lib.js";import{IllustratedMessage as n1,Icon as x,Card as B,ContentGrid as t1,Image as L1,Header as j,Pagination as s1}from"@dropins/tools/components.js";import*as o from"@dropins/tools/preact-compat.js";import{useMemo as a1}from"@dropins/tools/preact-compat.js";import"./OrderCancel.js";import{C as R}from"./OrderLoaders.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{Text as Y}from"@dropins/tools/i18n.js";const G=n=>o.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",...n},o.createElement("g",{id:"Large"},o.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),o.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},o.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"})))),i1=n=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},o.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"})),U=({typeList:n,isEmpty:h,minifiedView:c,message:t})=>{const L=a1(()=>{switch(n){case"orders":return{icon:i1,text:r("p",{children:t}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[n,t]);return!h||!n||!L.text?null:r(n1,{className:F(["order-empty-list",L.className,c?"order-empty-list--minified":""]),message:L.text,icon:r(x,{source:L.icon}),"data-testid":"emptyList"})},c1={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"},d1=n=>typeof n!="string"?"":c1[n]??"",k={size:"32",stroke:"2"},E1=({minifiedViewKey:n,withReturnNumber:h=!1,withOrderNumber:c=!1,slots:t,pageInfo:L,withReturnsListButton:y=!0,isMobile:v=!1,returnsInMinifiedView:J=1,translations:s={},orderReturns:d=[],minifiedView:C=!1,withHeader:Z=!0,withThumbnails:w=!0,selectedPage:H=1,handleSetSelectPage:I,routeReturnDetails:l,routeOrderDetails:u,routeTracking:_,routeReturnsList:E,routeProductDetails:m,loading:N})=>{const S=C?J:d.length,V=m!=null&&m()?"a":"span",g=A(()=>d.slice(0,S).map((e,D)=>{var P,$;return r(B,{variant:"secondary",className:"order-returns-list-content__cards-list",children:a("div",{className:"order-returns-list-content__cards-grid",children:[a("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(Y,{id:`Order.Returns.${n}.returnsList.resturnStatus.${d1(e.returnStatus)}`})}),h?a("p",{children:[s.returnNumber," ",r("a",{href:(l==null?void 0:l({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,c?a("p",{children:[s.orderNumber," ",r("a",{href:(u==null?void 0:u({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(P=e==null?void 0:e.tracking)==null?void 0:P.map((i,b)=>{var M,f;return a("p",{children:[`${s.carrier} ${(f=(M=i==null?void 0:i.carrier)==null?void 0:M.label)==null?void 0:f.toLocaleUpperCase()}: `,r("a",{href:`${(_==null?void 0:_(i))||"#"}`,target:"_blank",rel:"noreferrer",children:i.trackingNumber})]},`${i.trackingNumber}_${b}`)}),t!=null&&t.ReturnItemsDetails?r(T,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:t==null?void 0:t.ReturnItemsDetails,context:{items:e.items}}):e.items.length?a("p",{children:[e.items.length," ",r(Y,{id:`Order.Returns.${n}.returnsList.itemText`,plural:e.items.length,fields:{count:e.items.length}})]}):null]}),w?r(t1,{maxColumns:v?3:9,emptyGridContent:r(p,{}),className:F(["order-returns-list-content__images",["order-returns-list-content__images-3",v]]),children:($=e==null?void 0:e.items)==null?void 0:$.map((i,b)=>{var z,O;const M=i.orderItem,f=(z=M.thumbnail)==null?void 0:z.label,Q=(O=M.thumbnail)==null?void 0:O.url;return r(V,{href:(m==null?void 0:m(i.orderItem))??"#",children:r(L1,{alt:f,src:Q,width:85,height:114})},b+i.uid)})}):null,t!=null&&t.DetailsActionParams?r(T,{className:"order-returns-list-content__actions","data-testid":"detailsActionParams",name:"DetailsActionParams",slot:t==null?void 0:t.DetailsActionParams,context:{returnOrderItem:e}}):r("a",{href:(l==null?void 0:l({returnNumber:e.returnNumber,token:e.token,orderNumber:e.orderNumber}))??"#",className:"order-returns-list-content__actions",children:r(x,{source:G,...k})})]})},D)}),[d,S,s,t,w,v,u,l,_,m,V,c,n,h]),W=A(()=>a(p,{children:[Z?r(j,{title:s.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,N?r(R,{withCard:!1}):a(p,{children:[g,r(U,{minifiedView:C,typeList:"orders",isEmpty:!d.length,message:s.emptyOrdersListMessage}),y?r("a",{className:"order-returns-list-content__actions",href:(E==null?void 0:E())??"#",children:r(B,{variant:"secondary",className:"order-returns-list-content__card",children:a("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:s.viewAllOrdersButton}),r(x,{source:G,...k})]})})}):null]})]}),[E,y,Z,s,g,C,d.length,N]),q=A(()=>a(p,{children:[Z?r(j,{title:s.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,N?r(R,{withCard:!1}):a(p,{children:[r(U,{minifiedView:C,typeList:"orders",isEmpty:!d.length,message:s.emptyOrdersListMessage}),g,(L==null?void 0:L.totalPages)>1?r(s1,{totalPages:L==null?void 0:L.totalPages,currentPage:H,onChange:I}):null]})]}),[g,C,d,s,L,H,I,N,Z]);return r("div",{className:"order-returns-list-content",children:C?W:q})},N1=()=>{const[n,h]=X(window.innerWidth<768),c=K(e1(()=>{h(window.innerWidth<768)},1e3),[]);return r1(()=>(window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]),n};export{E1 as R,N1 as u}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{debounce as t}from"@dropins/tools/lib.js";import{useState as o,useCallback as s,useEffect as r}from"@dropins/tools/preact-hooks.js";const w=()=>{const[i,n]=o(window.innerWidth<768),e=s(t(()=>{n(window.innerWidth<768)},1e3),[]);return r(()=>(window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[e]),i};export{w as u}; diff --git a/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts b/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts index ba081beddd..23bca034cb 100644 --- a/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts +++ b/scripts/__dropins__/storefront-order/components/OrderCostSummaryContent/Blocks.d.ts @@ -13,7 +13,7 @@ export declare const Shipping: ({ translations, shoppingOrdersDisplayShipping, o shoppingOrdersDisplayShipping: TaxTypes; order: OrderDataModel; translations: translationsTypes; -}) => import("preact").JSX.Element; +}) => import("preact").JSX.Element | null; export declare const Discounts: ({ translations, order, totalGiftcardValue, totalGiftcardCurrency, }: { totalGiftcardValue: number; totalGiftcardCurrency: string; diff --git a/scripts/__dropins__/storefront-order/components/Reorder/Reorder.d.ts b/scripts/__dropins__/storefront-order/components/Reorder/Reorder.d.ts new file mode 100644 index 0000000000..949fdaf763 --- /dev/null +++ b/scripts/__dropins__/storefront-order/components/Reorder/Reorder.d.ts @@ -0,0 +1,5 @@ +import { FunctionComponent } from 'preact'; +import { ReorderProps } from '../../types'; + +export declare const Reorder: FunctionComponent; +//# sourceMappingURL=Reorder.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/Reorder/index.d.ts b/scripts/__dropins__/storefront-order/components/Reorder/index.d.ts new file mode 100644 index 0000000000..0ce496a22b --- /dev/null +++ b/scripts/__dropins__/storefront-order/components/Reorder/index.d.ts @@ -0,0 +1,3 @@ +export * from './Reorder'; +export { Reorder as default } from '.'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/ShippingStatusCard/ShippingStatusReturnCard.d.ts b/scripts/__dropins__/storefront-order/components/ShippingStatusCard/ShippingStatusReturnCard.d.ts new file mode 100644 index 0000000000..d8df51bdb7 --- /dev/null +++ b/scripts/__dropins__/storefront-order/components/ShippingStatusCard/ShippingStatusReturnCard.d.ts @@ -0,0 +1,5 @@ +import { ShippingStatusReturnCardProps } from '../../types'; +import { FunctionComponent } from 'preact'; + +export declare const ShippingStatusReturnCard: FunctionComponent; +//# sourceMappingURL=ShippingStatusReturnCard.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/components/ShippingStatusCard/index.d.ts b/scripts/__dropins__/storefront-order/components/ShippingStatusCard/index.d.ts index 54994b5bfe..b6675dd7c0 100644 --- a/scripts/__dropins__/storefront-order/components/ShippingStatusCard/index.d.ts +++ b/scripts/__dropins__/storefront-order/components/ShippingStatusCard/index.d.ts @@ -1,3 +1,4 @@ export * from './ShippingStatusCard'; +export * from './ShippingStatusReturnCard'; export { ShippingStatusCard as default } from './ShippingStatusCard'; //# sourceMappingURL=index.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 f22da483a0..65eb2118f4 100644 --- a/scripts/__dropins__/storefront-order/components/index.d.ts +++ b/scripts/__dropins__/storefront-order/components/index.d.ts @@ -10,4 +10,5 @@ export * from './ReturnsListContent'; export * from './OrderProductListContent'; export * from './OrderCostSummaryContent'; export * from './OrderCancel'; +export * from './Reorder'; //# 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 efc559a331..2caf144835 100644 --- a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts +++ b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts @@ -175,6 +175,11 @@ export declare const transformMockOrderInput: { test: null; prop: undefined; }[]; + returns: { + status: string; + number: string; + items: never[]; + }[]; shipments: { id: string; tracking: { diff --git a/scripts/__dropins__/storefront-order/containers/CustomerDetails.js b/scripts/__dropins__/storefront-order/containers/CustomerDetails.js index 6d8be62d84..f7640a3db6 100644 --- a/scripts/__dropins__/storefront-order/containers/CustomerDetails.js +++ b/scripts/__dropins__/storefront-order/containers/CustomerDetails.js @@ -1 +1,3 @@ -import{jsx as t,jsxs as d,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as f}from"@dropins/tools/lib.js";import{useMemo as L,useCallback as O,useState as k,useEffect as D}from"@dropins/tools/preact-hooks.js";import{events as S}from"@dropins/tools/event-bus.js";import{c as W}from"../chunks/convertCase.js";import{g as P}from"../chunks/getAttributesForm.js";import{Card as Z,Header as z,Price as B,Icon as $}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import*as i from"@dropins/tools/preact-compat.js";import{D as q}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact.js";import{useText as F}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const K=a=>i.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},i.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"}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),R=a=>i.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},i.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}),i.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}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),i.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}),i.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})),G=({loading:a,order:e,withHeader:g=!0,title:c,paymentIconsMap:h={},normalizeAddress:m})=>{var A,M,E,N,T;const n=F({emailTitle:"Order.CustomerDetails.email.title",shippingAddressTitle:"Order.CustomerDetails.shippingAddress.title",shippingMethodsTitle:"Order.CustomerDetails.shippingMethods.title",billingAddressTitle:"Order.CustomerDetails.billingAddress.title",billingMethodsTitle:"Order.CustomerDetails.billingMethods.title",headerText:"Order.CustomerDetails.headerText",freeShipping:"Order.CustomerDetails.freeShipping"}),p=L(()=>({checkmo:K,card:R,...h}),[h]),_=O(H=>{var w;return(w=m[H])==null?void 0:w.map((s,V)=>t("p",{children:s.label?`${s.label}: ${Array.isArray(s.value)?s.value.join(" "):s==null?void 0:s.value}`:Array.isArray(s.value)?s.value.join(" "):s==null?void 0:s.value},V))},[m]);if(!e||a)return t(q,{});const o=(e==null?void 0:e.email)??"",l=(A=e==null?void 0:e.shipping)==null?void 0:A.code,r=(M=e==null?void 0:e.shipping)==null?void 0:M.amount,C=(E=e==null?void 0:e.shipping)==null?void 0:E.currency,u=e==null?void 0:e.payments,v=u&&u.length>0,b=v?(N=u[0])==null?void 0:N.name:"",y=v?(T=u[0])==null?void 0:T.code:"",x=v&&b!=="";return d(Z,{"data-testid":"order-details",variant:"secondary",className:f(["order-customer-details-content"]),children:[g?t(z,{title:c??n.headerText}):null,d("div",{className:"order-customer-details-content__container",children:[d("div",{className:"order-customer-details-content__container-email",children:[t("div",{className:"order-customer-details-content__container-title",children:n.emailTitle}),t("p",{children:o})]}),d("div",{className:"order-customer-details-content__container-shipping_address",children:[t("div",{className:"order-customer-details-content__container-title",children:n.shippingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("shippingAddress")})]}),d("div",{className:"order-customer-details-content__container-billing_address",children:[t("div",{className:"order-customer-details-content__container-title",children:n.billingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("billingAddress")})]}),d("div",{className:"order-customer-details-content__container-shipping_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:n.shippingMethodsTitle}),l?t(j,{children:r?d("p",{"data-testid":"shipping_methods_price",children:[t(B,{amount:r,currency:C})," ",l]}):t("p",{"data-testid":"shipping_methods_placeholder",children:n.freeShipping})}):null]}),d("div",{className:"order-customer-details-content__container-payment_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:n.billingMethodsTitle}),x&&d("p",{"data-testid":"billing_methods_description",className:f([["order-customer-details-content__container-payment_methods--icon",!!p[y]]]),children:[t($,{source:p[y]}),b]})]})]})]})},I=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],J=({orderData:a})=>{const[e,g]=k(!0),[c,h]=k(a),[m,n]=k([]);D(()=>{const o=S.on("order/data",l=>{h(l)},{eager:!0});return()=>{o==null||o.off()}},[]),D(()=>{P("shortRequest").then(o=>{if(o){const l=o.map(({name:r,orderNumber:C,label:u})=>({name:W(r),orderNumber:C,label:I.includes(r)?null:u}));n(l)}}).finally(()=>{g(!1)})},[]);const p=O(o=>{if(!m.length||!c||!c[o])return[];const l=Object.fromEntries(Object.entries(c[o]).map(([r,C])=>[r.toLowerCase(),C]));return m.filter(({name:r})=>l[r.toLowerCase()]).map(r=>({name:r.name,orderNumber:r.orderNumber,value:l[r.name.toLowerCase()],label:r.label}))},[m,c]),_=L(()=>({billingAddress:p("billingAddress"),shippingAddress:p("shippingAddress")}),[p]);return{order:c,normalizeAddress:_,loading:e}},de=({paymentIconsMap:a,orderData:e,title:g,className:c})=>{const{order:h,normalizeAddress:m,loading:n}=J({orderData:e});return t("div",{className:f(["order-customer-details",c]),children:t(G,{loading:n,order:h,title:g,paymentIconsMap:a,normalizeAddress:m})})};export{de as CustomerDetails,de as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r,jsxs as i,Fragment as K}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as G,classes as g}from"@dropins/tools/lib.js";import{useState as y,useEffect as H,useCallback as V,useMemo as j}from"@dropins/tools/preact-hooks.js";import{events as J}from"@dropins/tools/event-bus.js";import{c as Q}from"../chunks/convertCase.js";import{g as U}from"../chunks/getAttributesForm.js";import{Icon as X,Price as Y,Card as ee,Header as te}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import*as a from"@dropins/tools/preact-compat.js";import{f as re}from"../chunks/returnOrdersHelper.js";import{f as ne}from"../chunks/formatDateToLocale.js";import{D as se}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact.js";import{Text as ie,useText as oe}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const ce=d=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},a.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"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ae=d=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},a.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}),a.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}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),a.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}),a.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})),de=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],le=({orderData:d})=>{const[t,_]=y(!0),[l,p]=y(d),[u,e]=y([]);H(()=>{const n=J.on("order/data",m=>{p(m)},{eager:!0});return()=>{n==null||n.off()}},[]),H(()=>{U("shortRequest").then(n=>{if(n){const m=n.map(({name:s,orderNumber:C,label:f})=>({name:Q(s),orderNumber:C,label:de.includes(s)?null:f}));e(m)}}).finally(()=>{_(!1)})},[]);const o=V(n=>{if(!u.length||!l||!l[n])return[];const m=Object.fromEntries(Object.entries(l[n]).map(([s,C])=>[s.toLowerCase(),C]));return u.filter(({name:s})=>m[s.toLowerCase()]).map(s=>({name:s.name,orderNumber:s.orderNumber,value:m[s.name.toLowerCase()],label:s.label}))},[u,l]),h=j(()=>({billingAddress:o("billingAddress"),shippingAddress:o("shippingAddress")}),[o]);return{order:l,normalizeAddress:h,loading:t}},me=({loading:d,order:t,withHeader:_=!0,title:l,paymentIconsMap:p={},normalizeAddress:u,translations:e,slots:o})=>{var L,O,E,T,w,S;const h=!!(t!=null&&t.returnNumber),n=(L=t==null?void 0:t.returns)==null?void 0:L[0],m=j(()=>({checkmo:ce,card:ae,...p}),[p]),s=V(q=>{var x;return(x=u[q])==null?void 0:x.map((c,F)=>r("p",{children:c.label?`${c.label}: ${Array.isArray(c.value)?c.value.join(" "):c==null?void 0:c.value}`:Array.isArray(c.value)?c.value.join(" "):c==null?void 0:c.value},F))},[u]);if(!t||d)return r(se,{});const C=(t==null?void 0:t.email)??"",f=(O=t==null?void 0:t.shipping)==null?void 0:O.code,N=(E=t==null?void 0:t.shipping)==null?void 0:E.amount,R=(T=t==null?void 0:t.shipping)==null?void 0:T.currency,v=t==null?void 0:t.payments,k=v&&v.length>0,D=k?(w=v[0])==null?void 0:w.name:"",M=k?(S=v[0])==null?void 0:S.code:"",W=k&&D!=="",b=s("shippingAddress")??[],A=s("billingAddress")??[],I=i("div",{className:"order-customer-details-content__container-email",children:[r("div",{className:"order-customer-details-content__container-title",children:e==null?void 0:e.emailTitle}),r("p",{children:C})]}),P=h?i("div",{className:"order-customer-details-content__container-return-information",children:[r("div",{className:"order-customer-details-content__container-title",children:e==null?void 0:e.returnInformationTitle}),r("div",{className:"order-customer-details-content__container-description",children:o!=null&&o.OrderReturnInformation?r(G,{"data-testid":"OrderReturnInformation",name:"OrderReturnInformation",slot:o==null?void 0:o.OrderReturnInformation,context:n}):i(K,{children:[i("p",{children:[e.createdReturnAt,r("span",{children:ne(n==null?void 0:n.createdReturnAt)})]}),i("p",{children:[e.returnStatusLabel,r(ie,{id:`Order.CustomerDetails.returnStatus.${re(n==null?void 0:n.returnStatus)}`})]}),i("p",{children:[e.orderNumberLabel,r("span",{children:n==null?void 0:n.orderNumber})]})]})})]}):null,Z=b.length?i("div",{className:"order-customer-details-content__container-shipping_address",children:[r("div",{className:"order-customer-details-content__container-title",children:e.shippingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:b})]}):null,$=A.length?i("div",{className:g(["order-customer-details-content__container-billing_address",["order-customer-details-content__container-billing_address--fullwidth",!b.length]]),children:[r("div",{className:"order-customer-details-content__container-title",children:e.billingAddressTitle}),r("div",{className:"order-customer-details-content__container-description",children:A})]}):null,z=W?i("div",{className:g(["order-customer-details-content__container-payment_methods",["order-customer-details-content__container-payment_methods--fullwidth",!f]]),children:[r("div",{className:"order-customer-details-content__container-title",children:e==null?void 0:e.paymentMethodsTitle}),i("p",{"data-testid":"payment_methods_description",className:g([["order-customer-details-content__container-payment_methods--icon",!!m[M]]]),children:[r(X,{source:m[M]}),D]})]}):null,B=f?i("div",{className:"order-customer-details-content__container-shipping_methods",children:[r("div",{className:"order-customer-details-content__container-title",children:e==null?void 0:e.shippingMethodsTitle}),N?i("p",{"data-testid":"shipping_methods_price",children:[r(Y,{amount:N,currency:R})," ",f]}):r("p",{"data-testid":"shipping_methods_placeholder",children:e==null?void 0:e.freeShipping})]}):null;return i(ee,{"data-testid":"order-details",variant:"secondary",className:g(["order-customer-details-content"]),children:[_?r(te,{title:l??(e==null?void 0:e.headerText)}):null,i("div",{className:g(["order-customer-details-content__container",["order-customer-details-content__container--no-margin",b.length||A.length]]),children:[I,Z,h?P:$,h?null:B,h?null:z]})]})},Oe=({paymentIconsMap:d,orderData:t,title:_,className:l,slots:p})=>{const u=oe({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:e,normalizeAddress:o,loading:h}=le({orderData:t});return r("div",{className:g(["order-customer-details",l]),children:r(me,{slots:p,loading:h,order:e,title:_,paymentIconsMap:d,normalizeAddress:o,translations:u})})};export{Oe as CustomerDetails,Oe as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js index 1718f08925..aa5ede1190 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js @@ -1 +1,3 @@ -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/preact.js";import"@dropins/tools/event-bus.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}; +/*! 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}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js index 1c837ad547..05f3f9a4a7 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCostSummary.js @@ -1 +1,3 @@ -import{jsxs as i,jsx as c,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{classes as H}from"@dropins/tools/lib.js";import{useState as _,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{Price as d,Icon as b,Accordion as f,AccordionSection as E,Card as D,Header as k}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import*as y from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{a 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 A=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),I=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.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"})),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(v,{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,o,s;return 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(v,{children:[c(d,{weight:"normal",currency:(o=t==null?void 0:t.totalShipping)==null?void 0:o.currency,amount:(s=t==null?void 0:t.totalShipping)==null?void 0:s.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 l,r,o;return!((l=a==null?void 0:a.discounts)!=null&&l.length)&&!t?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:(r=a==null?void 0:a.discounts)!=null&&r.length?(o=a==null?void 0:a.discounts)==null?void 0:o.map(({amount:s},m)=>{const u=(s==null?void 0:s.value)??0;return c(d,{weight:"normal",sale:!0,currency:s==null?void 0:s.currency,amount:-(u+t)},m)}):null})]}),!(a!=null&&a.discounts.length)&&t?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(b,{source:j,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"})]},n))})},U=({translations:e,renderTaxAccordion:a,totalAccordionTaxValue:t,order:n})=>{var o,s,m;const[l,r]=_(!1);return a?c(f,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:A,iconClose:I,children:i(E,{onStateChange:r,title:e.accordionTitle,secondaryText:c(v,{children:l?null:c(d,{weight:"normal",amount:t,currency:(s=n==null?void 0:n.totalTax)==null?void 0:s.currency})}),renderContentWhenClosed:!1,children:[(m=n==null?void 0:n.taxes)==null?void 0:m.map((u,x)=>{var p,h;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:u==null?void 0:u.title}),c("p",{children:c(d,{weight:"normal",amount:(p=u==null?void 0:u.amount)==null?void 0:p.value,currency:(h=u==null?void 0:u.amount)==null?void 0:h.currency})})]},x)}),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:(o=n==null?void 0:n.totalTax)==null?void 0:o.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},G=({translations:e,shoppingOrdersDisplaySubtotal:a,order:t})=>{var n,l,r,o;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:((o=t==null?void 0:t.grandTotal)==null?void 0:o.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},R=({translations:e,loading:a,storeConfig:t,order:n,withHeader:l=!0})=>{var p,h,S,O,w,L;if(a||!n)return c(z,{});const r=((p=n==null?void 0:n.totalGiftcard)==null?void 0:p.value)??0,o=((h=n.totalGiftcard)==null?void 0:h.currency)??"",s=((S=n.subtotal)==null?void 0:S.value)??0,m=((O=n.totalShipping)==null?void 0:O.value)??0,u=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),x=u?(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(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:s,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(W,{translations:e,order:n,totalShipping:m,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(q,{translations:e,order:n,totalGiftcardValue:r,totalGiftcardCurrency:o}),c(F,{order:n}),c(U,{order:n,translations:e,renderTaxAccordion:u,totalAccordionTaxValue:x}),c(G,{translations:e,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})},J=({orderData:e})=>{const[a,t]=_(!0),[n,l]=_(e),[r,o]=_(null);return T(()=>{N().then(s=>{if(s){const{shoppingCartDisplayPrice:m,shoppingOrdersDisplayShipping:u,shoppingOrdersDisplaySubtotal:x,...p}=s;o(h=>({...h,...p,shoppingCartDisplayPrice:C(m),shoppingOrdersDisplayShipping:C(u),shoppingOrdersDisplaySubtotal:C(x)}))}}).finally(()=>{t(!1)})},[]),T(()=>{const s=V.on("order/data",m=>{l(m)},{eager:!0});return()=>{s==null||s.off()}},[]),{loading:a,storeConfig:r,order:n}},rt=({withHeader:e,orderData:a,children:t,className:n,...l})=>{const{loading:r,storeConfig:o,order:s}=J({orderData:a}),m=B({headerText:"Order.OrderCostSummary.headerText",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"});return c("div",{...l,className:H(["order-cost-summary",n]),children:c(R,{order:s,withHeader:e,loading:r,storeConfig:o,translations:m})})};export{rt as OrderCostSummary,rt as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as s,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{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"@dropins/tools/preact.js";import{a 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=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"})),j=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"})),P=({orderData:a})=>{const[e,t]=g(!0),[n,i]=g(a),[l,o]=g(null);return T(()=>{N().then(u=>{if(u){const{shoppingCartDisplayPrice:p,shoppingOrdersDisplayShipping:r,shoppingOrdersDisplaySubtotal:m,...h}=u;o(y=>({...y,...h,shoppingCartDisplayPrice:C(p),shoppingOrdersDisplayShipping:C(r),shoppingOrdersDisplaySubtotal:C(m)}))}}).finally(()=>{t(!1)})},[]),T(()=>{const u=V.on("order/data",p=>{i(p)},{eager:!0});return()=>{u==null||u.off()}},[]),{loading:e,storeConfig:l,order:n}},W=({translations:a,order:e,subTotalValue:t,shoppingOrdersDisplaySubtotal:n})=>{var i,l;return s("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[s("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:(i=e==null?void 0:e.subtotal)==null?void 0:i.currency,amount:t})]}),s("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:a.incl}):null,n.taxExcluded&&n.taxIncluded?s(S,{children:[c(d,{currency:(l=e==null?void 0:e.subtotal)==null?void 0:l.currency,amount:t,size:"small"})," ",c("span",{children:a.excl})]}):null]})]})},q=({translations:a,shoppingOrdersDisplayShipping:e,order:t,totalShipping:n})=>{var i,l,o,u;return t!=null&&t.isVirtual?null:s("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[s("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.shipping}),(i=t==null?void 0:t.totalShipping)!=null&&i.value?c(d,{weight:"normal",currency:(l=t==null?void 0:t.totalShipping)==null?void 0:l.currency,amount:n}):c("span",{children:a.freeShipping})]}),s("div",{className:"order-cost-summary-content__description--subheader",children:[e.taxIncluded&&e.taxExcluded?s(S,{children:[c(d,{weight:"normal",currency:(o=t==null?void 0:t.totalShipping)==null?void 0:o.currency,amount:(u=t==null?void 0:t.totalShipping)==null?void 0:u.value,size:"small"}),s("span",{children:[" ",a.excl]})]}):null,e.taxIncluded&&!e.taxExcluded?c("span",{children:a.incl}):null]})]})},F=({translations:a,order:e,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var l,o,u,p,r;const i=(l=e==null?void 0:e.discounts)==null?void 0:l.every(m=>m.amount.value===0);return!((o=e==null?void 0:e.discounts)!=null&&o.length)&&(i||!t||t<1)||(u=e==null?void 0:e.discounts)!=null&&u.length&&i?null:s("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[s("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.discount}),c("span",{children:(p=e==null?void 0:e.discounts)!=null&&p.length?(r=e==null?void 0:e.discounts)==null?void 0:r.map(({amount:m},h)=>{const _=((m==null?void 0:m.value)??0)+t;return _===0?null:c(d,{weight:"normal",sale:!0,currency:m==null?void 0:m.currency,amount:-_},h)}):null})]}),t>0?s("div",{className:"order-cost-summary-content__description--subheader",children:[s("span",{children:[c(f,{source:j,size:"16"}),c("span",{children:a.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},U=({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)=>s("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},n))})},R=({translations:a,renderTaxAccordion:e,totalAccordionTaxValue:t,order:n})=>{var o,u,p;const[i,l]=g(!1);return e?c(b,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:I,iconClose:A,children:s(E,{onStateChange:l,title:a.accordionTitle,secondaryText:c(S,{children:i?null:c(d,{weight:"normal",amount:t,currency:(u=n==null?void 0:n.totalTax)==null?void 0:u.currency})}),renderContentWhenClosed:!1,children:[(p=n==null?void 0:n.taxes)==null?void 0:p.map((r,m)=>{var h,y;return s("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:r==null?void 0:r.title}),c("p",{children:c(d,{weight:"normal",amount:(h=r==null?void 0:r.amount)==null?void 0:h.value,currency:(y=r==null?void 0:r.amount)==null?void 0:y.currency})})]},m)}),s("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:s("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.tax}),c(d,{currency:(o=n==null?void 0:n.totalTax)==null?void 0:o.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},G=({translations:a,shoppingOrdersDisplaySubtotal:e,order:t})=>{var n,i,l,o;return s("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--total",children:[s("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:(i=t==null?void 0:t.grandTotal)==null?void 0:i.value,weight:"bold",size:"medium"})]}),e.taxExcluded&&e.taxIncluded?s("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:a.totalExcludingTaxes}),c(d,{currency:(l=t==null?void 0:t.grandTotal)==null?void 0:l.currency,amount:((o=t==null?void 0:t.grandTotal)==null?void 0:o.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},J=({translations:a,loading:e,storeConfig:t,order:n,withHeader:i=!0})=>{var h,y,_,O,w,L;if(e||!n)return c(z,{});const l=((h=n==null?void 0:n.totalGiftcard)==null?void 0:h.value)??0,o=((y=n.totalGiftcard)==null?void 0:y.currency)??"",u=((_=n.subtotal)==null?void 0:_.value)??0,p=((O=n.totalShipping)==null?void 0:O.value)??0,r=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),m=r?(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 s(D,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[i?c(k,{title:a.headerText}):null,s("div",{className:"order-cost-summary-content__wrapper",children:[c(W,{translations:a,order:n,subTotalValue:u,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(q,{translations:a,order:n,totalShipping:p,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(F,{translations:a,order:n,totalGiftcardValue:l,totalGiftcardCurrency:o}),c(U,{order:n}),c(R,{order:n,translations:a,renderTaxAccordion:r,totalAccordionTaxValue:m}),c(G,{translations:a,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})},ut=({withHeader:a,orderData:e,children:t,className:n,...i})=>{const{loading:l,storeConfig:o,order:u}=P({orderData:e}),p=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",{...i,className:H(["order-cost-summary",n]),children:c(J,{order:u,withHeader:a,loading:l,storeConfig:o,translations:p})})};export{ut as OrderCostSummary,ut as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderProductList.js b/scripts/__dropins__/storefront-order/containers/OrderProductList.js index 68cb04ce6c..5b81ee8c84 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderProductList.js +++ b/scripts/__dropins__/storefront-order/containers/OrderProductList.js @@ -1 +1,3 @@ -import{jsx as a,jsxs as b,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{Card as U,Header as X,Price as Y,CartItem as g,Icon as I,Image as P}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as C}from"@dropins/tools/lib.js";import*as u from"@dropins/tools/preact-compat.js";import{useMemo as T,useCallback as p,useState as S,useEffect as R}from"@dropins/tools/preact-hooks.js";import{Fragment as ee}from"@dropins/tools/preact.js";import{O as te}from"../chunks/OrderLoaders.js";import{events as le}from"@dropins/tools/event-bus.js";import{useText as ne}from"@dropins/tools/i18n.js";import{s as ae}from"../chunks/setTaxStatus.js";import{g as se}from"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const ie=v=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...v},u.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"}),u.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"})),me=({loading:v,taxConfig:e,order:y=null,withHeader:O=!0,showConfigurableOptions:r,routeProductDetails:f})=>{const h=ne({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),i=T(()=>{if(!y)return[];const{items:m}=y;return[{type:"cancelled",list:m.filter(s=>s.quantityCanceled),title:h.cancelled},{type:"",list:m.filter(s=>!s.quantityCanceled),title:h.allOrders}]},[y,h]);return y?a(U,{variant:"secondary",className:"order-order-product-list-content",children:i.filter(m=>m.list.length).map((m,s)=>{var k;return b(ee,{children:[O?a(X,{title:`${m.title} (${m.list.length})`}):null,a("ul",{className:"order-order-product-list-content__items",children:(k=m.list)==null?void 0:k.map(E=>a("li",{"data-testid":"order-product-list-content-item",children:a(re,{loading:v,product:E,itemType:m.type,taxConfig:e,translations:h,showConfigurableOptions:r,routeProductDetails:f})},E.id))})]},s)})}):a(te,{})},re=({loading:v,product:e,itemType:y,taxConfig:O,translations:r,showConfigurableOptions:f,routeProductDetails:h})=>{var _,c,x,Q,H,V,$,M,q,F,G,Z,j,z,W,B,K;const{taxExcluded:i,taxIncluded:m}=O,s=p((d,D,J)=>a(Y,{amount:d,currency:D,weight:"normal",...J}),[]);let k={};const E=y==="cancelled",A=(c=(_=e==null?void 0:e.product)==null?void 0:_.stockStatus)==null?void 0:c.includes("IN_STOCK"),t=(e==null?void 0:e.giftCard)||{},l=(x=e==null?void 0:e.itemPrices)==null?void 0:x.priceIncludingTax,n=(Q=e==null?void 0:e.itemPrices)==null?void 0:Q.originalPrice,o=(H=e==null?void 0:e.itemPrices)==null?void 0:H.price,L=e.discounted&&((V=e.price)==null?void 0:V.value)!==(n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),N={..."configurableOptions"in e?e.configurableOptions:{},..."bundleOptions"in e?e.bundleOptions:{},..."senderName"in t&&(t!=null&&t.senderName)?{[r.sender]:t==null?void 0:t.senderName}:{},..."senderEmail"in t&&(t!=null&&t.senderEmail)?{[r.sender]:t==null?void 0:t.senderEmail}:{},..."recipientName"in t&&(t!=null&&t.recipientName)?{[r.recipient]:t==null?void 0:t.recipientName}:{},..."recipientEmail"in t&&(t!=null&&t.recipientEmail)?{[r.recipient]:t==null?void 0:t.recipientEmail}:{},..."message"in t&&(t!=null&&t.message)?{[r.message]:t==null?void 0:t.message}:{},..."downloadableLinks"in e&&(e!=null&&e.downloadableLinks)?{[`${($=e==null?void 0:e.downloadableLinks)==null?void 0:$.count} ${r.downloadableCount}`]:(M=e==null?void 0:e.downloadableLinks)==null?void 0:M.result}:{}};if(m&&i){const d=L?n==null?void 0:n.value:(l==null?void 0:l.value)*(e==null?void 0:e.totalQuantity);k={taxExcluded:!0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:b(w,{children:[s(d,n==null?void 0:n.currency,{variant:e.discounted&&(l==null?void 0:l.value)!==d?"strikethrough":"default"}),e.discounted&&(l==null?void 0:l.value)!==d?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((o==null?void 0:o.value)*e.totalQuantity,o==null?void 0:o.currency)}}else if(!m&&i)k={taxExcluded:void 0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:b(w,{children:[s((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),l==null?void 0:l.currency,{variant:L?"strikethrough":"default"}),L?s((q=e.price)==null?void 0:q.value,(F=e.price)==null?void 0:F.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((o==null?void 0:o.value)*(e==null?void 0:e.totalQuantity),o==null?void 0:o.currency)};else if(m&&!i){const d=L?n.value:l.value*e.totalQuantity;k={taxExcluded:void 0,taxIncluded:!0,price:s(l==null?void 0:l.value,l==null?void 0:l.currency),total:b(w,{children:[s(d,l==null?void 0:l.currency,{variant:L?"strikethrough":"default",weight:"bold"}),L?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]})}}return a(g,{loading:v,alert:E&&A?b("span",{children:[a(I,{source:ie}),r.outOfStock]}):a(w,{}),configurations:(f==null?void 0:f(N))??N,title:h?a("a",{"data-testid":"product-name",className:C(["cart-summary-item__title",["cart-summary-item__title--strikethrough",E]]),href:h(e),children:(G=e==null?void 0:e.product)==null?void 0:G.name}):a("div",{"data-testid":"product-name",className:C(["cart-summary-item__title",["cart-summary-item__title--strikethrough",E]]),children:(Z=e==null?void 0:e.product)==null?void 0:Z.name}),sku:a("div",{children:(j=e==null?void 0:e.product)==null?void 0:j.sku}),quantity:e.totalQuantity,image:h?a("a",{href:h(e),children:a(P,{src:(z=e==null?void 0:e.product)==null?void 0:z.thumbnail.url,alt:(W=e==null?void 0:e.product)==null?void 0:W.thumbnail.label,loading:"lazy",width:"90",height:"120"})}):a(P,{src:(B=e==null?void 0:e.product)==null?void 0:B.thumbnail.url,alt:(K=e==null?void 0:e.product)==null?void 0:K.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...k})},he=({orderData:v})=>{const[e,y]=S(!0),[O,r]=S(v),[f,h]=S({taxIncluded:!1,taxExcluded:!1});return R(()=>{se().then(i=>{i&&h(ae(i==null?void 0:i.shoppingCartDisplayPrice))}).finally(()=>{y(!1)})},[]),R(()=>{const i=le.on("order/data",m=>{r(m)},{eager:!0});return()=>{i==null||i.off()}},[]),{loading:e,taxConfig:f,order:O}},Ce=({className:v,orderData:e,withHeader:y,showConfigurableOptions:O,routeProductDetails:r})=>{const{loading:f,taxConfig:h,order:i}=he({orderData:e});return a("div",{className:C(["order-order-product-list",v]),children:a(me,{loading:f,taxConfig:h,order:i,withHeader:y,showConfigurableOptions:O,routeProductDetails:r})})};export{Ce as OrderProductList,Ce as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r,jsxs as E,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{Card as Y,Header as g,Price as D,CartItem as I,Icon as T,Image as A}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as S}from"@dropins/tools/lib.js";import{useState as N,useEffect as J,useMemo as p,useCallback as ee}from"@dropins/tools/preact-hooks.js";import{events as te}from"@dropins/tools/event-bus.js";import{s as ne}from"../chunks/setTaxStatus.js";import{g as le}from"../chunks/getStoreConfig.js";import*as C from"@dropins/tools/preact-compat.js";import{Fragment as se}from"@dropins/tools/preact.js";import{O as ae}from"../chunks/OrderLoaders.js";import{useText as re}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const ie=v=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...v},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:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),me=({orderData:v})=>{const[e,s]=N(!0),[O,u]=N(v),[y,f]=N({taxIncluded:!1,taxExcluded:!1});return J(()=>{le().then(i=>{i&&f(ne(i==null?void 0:i.shoppingCartDisplayPrice))}).finally(()=>{s(!1)})},[]),J(()=>{const i=te.on("order/data",o=>{u(o)},{eager:!0});return()=>{i==null||i.off()}},[]),{loading:e,taxConfig:y,order:O}},he=({loading:v,taxConfig:e,order:s=null,withHeader:O=!0,showConfigurableOptions:u,routeProductDetails:y})=>{const f=!!(s!=null&&s.returnNumber),i=s==null?void 0:s.returnNumber,o=re({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"}),h=p(()=>{if(!s)return[];if(!f){const d=(s==null?void 0:s.items)??[],t=d.filter(a=>a.quantityReturned),n=d.filter(a=>a.quantityCanceled),l=d.filter(a=>!a.quantityCanceled);return[{type:"returned",list:t,title:o.returned},{type:"cancelled",list:n,title:o.cancelled},{type:"allItems",list:l,title:o.allOrders}].filter(a=>a.list.length>0)}const m=s.returns.find(d=>d.returnNumber===i);return[{type:"returned",list:(m==null?void 0:m.items)??[],title:o.returned}]},[s,f,o,i]);return s?h.every(m=>m.list.length===0)?null:r(Y,{variant:"secondary",className:"order-order-product-list-content",children:h.map((m,k)=>{var d;return E(se,{children:[O?r(g,{title:`${m.title} (${m.list.length})`}):null,r("ul",{className:"order-order-product-list-content__items",children:(d=m.list)==null?void 0:d.map(t=>r("li",{"data-testid":"order-product-list-content-item",children:r(ue,{loading:v,product:t,itemType:m.type,taxConfig:e,translations:o,showConfigurableOptions:u,routeProductDetails:y})},t.id))})]},k)})}):r(ae,{})},ue=({loading:v,product:e,itemType:s,taxConfig:O,translations:u,showConfigurableOptions:y,routeProductDetails:f})=>{var x,q,H,V,$,M,P,Q,F,G,R,Z,j,z,W,B,K;const{taxExcluded:i,taxIncluded:o}=O,h=ee((c,U,X)=>r(D,{amount:c,currency:U,weight:"normal",...X}),[]);let m={};const k=s==="cancelled",d=(q=(x=e==null?void 0:e.product)==null?void 0:x.stockStatus)==null?void 0:q.includes("IN_STOCK"),t=(e==null?void 0:e.giftCard)||{},n=(H=e==null?void 0:e.itemPrices)==null?void 0:H.priceIncludingTax,l=(V=e==null?void 0:e.itemPrices)==null?void 0:V.originalPrice,a=($=e==null?void 0:e.itemPrices)==null?void 0:$.price,b=s==="returned"?e==null?void 0:e.requestQuantity:e==null?void 0:e.totalQuantity,L=e.discounted&&((M=e.price)==null?void 0:M.value)!==(l==null?void 0:l.value)*b,_={..."configurableOptions"in e?e.configurableOptions:{},..."bundleOptions"in e?e.bundleOptions:{},..."senderName"in t&&(t!=null&&t.senderName)?{[u.sender]:t==null?void 0:t.senderName}:{},..."senderEmail"in t&&(t!=null&&t.senderEmail)?{[u.sender]:t==null?void 0:t.senderEmail}:{},..."recipientName"in t&&(t!=null&&t.recipientName)?{[u.recipient]:t==null?void 0:t.recipientName}:{},..."recipientEmail"in t&&(t!=null&&t.recipientEmail)?{[u.recipient]:t==null?void 0:t.recipientEmail}:{},..."message"in t&&(t!=null&&t.message)?{[u.message]:t==null?void 0:t.message}:{},..."downloadableLinks"in e&&(e!=null&&e.downloadableLinks)?{[`${(P=e==null?void 0:e.downloadableLinks)==null?void 0:P.count} ${u.downloadableCount}`]:(Q=e==null?void 0:e.downloadableLinks)==null?void 0:Q.result}:{}};if(o&&i){const c=L?l==null?void 0:l.value:(n==null?void 0:n.value)*b;m={taxExcluded:!0,taxIncluded:void 0,price:h(l==null?void 0:l.value,l==null?void 0:l.currency),total:E(w,{children:[h(c,l==null?void 0:l.currency,{variant:e.discounted&&(n==null?void 0:n.value)!==c?"strikethrough":"default"}),e.discounted&&(n==null?void 0:n.value)!==c?h(n==null?void 0:n.value,n==null?void 0:n.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:h((a==null?void 0:a.value)*b,a==null?void 0:a.currency)}}else if(!o&&i)m={taxExcluded:void 0,taxIncluded:void 0,price:h(l==null?void 0:l.value,l==null?void 0:l.currency),total:E(w,{children:[h((l==null?void 0:l.value)*b,n==null?void 0:n.currency,{variant:L?"strikethrough":"default"}),L?h((F=e.price)==null?void 0:F.value,(G=e.price)==null?void 0:G.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:h((a==null?void 0:a.value)*(e==null?void 0:e.totalQuantity),a==null?void 0:a.currency)};else if(o&&!i){const c=L?l.value:n.value*b;m={taxExcluded:void 0,taxIncluded:!0,price:h(n==null?void 0:n.value,n==null?void 0:n.currency),total:E(w,{children:[h(c,n==null?void 0:n.currency,{variant:L?"strikethrough":"default",weight:"bold"}),L?h(n==null?void 0:n.value,n==null?void 0:n.currency,{sale:!0,weight:"bold"}):null]})}}return r(I,{loading:v,alert:k&&d?E("span",{children:[r(T,{source:ie}),u.outOfStock]}):r(w,{}),configurations:(y==null?void 0:y(_))??_,title:f?r("a",{"data-testid":"product-name",className:S(["cart-summary-item__title",["cart-summary-item__title--strikethrough",k]]),href:f(e),children:(R=e==null?void 0:e.product)==null?void 0:R.name}):r("div",{"data-testid":"product-name",className:S(["cart-summary-item__title",["cart-summary-item__title--strikethrough",k]]),children:(Z=e==null?void 0:e.product)==null?void 0:Z.name}),sku:r("div",{children:(j=e==null?void 0:e.product)==null?void 0:j.sku}),quantity:b,image:f?r("a",{href:f(e),children:r(A,{src:(z=e==null?void 0:e.product)==null?void 0:z.thumbnail.url,alt:(W=e==null?void 0:e.product)==null?void 0:W.thumbnail.label,loading:"lazy",width:"90",height:"120"})}):r(A,{src:(B=e==null?void 0:e.product)==null?void 0:B.thumbnail.url,alt:(K=e==null?void 0:e.product)==null?void 0:K.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...m})},Ce=({className:v,orderData:e,withHeader:s,showConfigurableOptions:O,routeProductDetails:u})=>{const{loading:y,taxConfig:f,order:i}=me({orderData:e});return r("div",{className:S(["order-order-product-list",v]),children:r(he,{loading:y,taxConfig:f,order:i,withHeader:s,showConfigurableOptions:O,routeProductDetails:u})})};export{Ce as OrderProductList,Ce as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderReturns.js b/scripts/__dropins__/storefront-order/containers/OrderReturns.js index 5a95ce32c0..7443681d7b 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderReturns.js +++ b/scripts/__dropins__/storefront-order/containers/OrderReturns.js @@ -1 +1,3 @@ -import{jsx as m}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as p}from"@dropins/tools/lib.js";import"@dropins/tools/preact-compat.js";import{useState as d,useEffect as R}from"@dropins/tools/preact-hooks.js";import{u as L,R as O}from"../chunks/useIsMobile.js";import"@dropins/tools/preact.js";import{events as b}from"@dropins/tools/event-bus.js";import{useText as g}from"@dropins/tools/i18n.js";import"../chunks/OrderLoaders.js";const w=({orderData:s})=>{const[i,n]=d(s),[u,o]=d([]);return R(()=>{const t=b.on("order/data",e=>{n(e),o(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:u}},I=({slots:s,className:i,orderData:n,withHeader:u,withThumbnails:o,routeReturnDetails:t,routeProductDetails:e,routeTracking:l})=>{const{orderReturns:a}=w({orderData:n}),f=L(),r="fullSizeView",c=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 m("div",{className:p(["order-order-returns",i]),children:a.length?m(O,{pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:f,withOrderNumber:!1,withReturnNumber:!0,orderReturns:a,translations:c,withHeader:u,withThumbnails:o,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:l,loading:!1}):null})};export{I as OrderReturns,I as default}; +/*! 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{u as O}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as b}from"../chunks/ReturnsListContent.js";import"@dropins/tools/preact.js";import{useText as g}from"@dropins/tools/i18n.js";import"../chunks/returnOrdersHelper.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}},j=({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{j as OrderReturns,j as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index 3cf8faf510..67f81b4e89 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderSearch.js +++ b/scripts/__dropins__/storefront-order/containers/OrderSearch.js @@ -1 +1,3 @@ -import{jsxs as v,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as _}from"@dropins/tools/lib.js";import{Card as U,InLineAlert as C,Icon as x,Button as V}from"@dropins/tools/components.js";import{F as L}from"../chunks/OrderCancel.js";import*as R from"@dropins/tools/preact-compat.js";import{useState as D,useCallback as O,useEffect as g,useMemo as k}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as w}from"@dropins/tools/event-bus.js";import{Text as S,useText as H}from"@dropins/tools/i18n.js";import{a as A,g as P}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 X=e=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},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"})),B=({onSubmit:e,loading:t,inLineAlert:o,fieldsConfig:a})=>v(U,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(S,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(S,{id:"Order.OrderSearchForm.description"})}),o.text?s(C,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:o.type,variant:"secondary",heading:o.text,icon:s(x,{source:X})}):null,s(L,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:a,onSubmit:e,children:s("div",{className:"order-order-search-form__button-container",children:s(V,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(S,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});var E=(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))(E||{});const j=e=>{if(!e)return null;const t=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(a=>{t.has(a.name)||t.set(a.name,"false"),a.checked&&t.set(a.name,"true")}),t&&typeof t.entries=="function"){const a=t.entries();if(a&&typeof a[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(a)))||{}}return{}},p=(e,t)=>{if(typeof e!="function")return;const o=e();if(!t||Object.keys(t).length===0){window.location.href=o;return}const a=new URLSearchParams;Object.entries(t).forEach(([u,f])=>{a.append(u,String(f))});const c=o.includes("?")?"&":"?";window.location.href=`${o}${c}${a.toString()}`},I=e=>{try{return new URL(window.location.href).searchParams.get(e)}catch{return null}},q=({onError:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c})=>{const[u,f]=D({text:"",type:"success"}),[y,h]=D(!1),m=H({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",postcode:"Order.OrderSearchForm.postcode",number:"Order.OrderSearchForm.orderNumber"}),b=O(async r=>{const n=I("orderRef"),i=n&&n.length>20;if(!r&&!n||!(r!=null&&r.number)&&!(r!=null&&r.token)&&!n)return null;if(t){const d=await A();(d==null?void 0:d.email)===r.email?p(a,{orderRef:r==null?void 0:r.number}):i||p(c,{orderRef:r.token})}else i||p(c,{orderRef:r==null?void 0:r.token})},[t,a,c]);g(()=>{const r=w.on("order/data",n=>{b(n)},{eager:!0});return()=>{r==null||r.off()}},[b]),g(()=>{const r=I("orderRef"),n=r&&r.length>20?r:null;r&&(n?p(c,{orderRef:r}):t?p(a,{orderRef:r}):o==null||o({render:!0,formValues:{number:r}}))},[t,a,c,o]);const M=k(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:E.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.postcode,options:[],defaultValue:"",fieldType:E.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:E.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:O(async(r,n)=>{if(!n)return null;h(!0);const i=j(r.target);await P(i).then(l=>{l||f({text:m.invalidSearch,type:"warning"}),w.emit("order/data",l)}).catch(async l=>{var N;let d=!0;e==null||e({error:l.message});const T=t?await A():{email:""};(T==null?void 0:T.email)===(i==null?void 0:i.email)?p(a,{orderRef:i.number}):d=o==null?void 0:o({render:T===null||((N=l==null?void 0:l.message)==null?void 0:N.includes("Please login to view the order.")),formValues:i}),d&&f({text:l.message,type:"warning"})}).finally(()=>{h(!1)})},[t,e,o,a,m.invalidSearch]),inLineAlert:u,loading:y,normalizeFieldsConfig:M}},ce=({className:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c,onError:u})=>{const{onSubmit:f,loading:y,inLineAlert:h,normalizeFieldsConfig:m}=q({onError:u,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c});return s("div",{className:_(["order-order-search",e]),children:s(B,{onSubmit:f,loading:y,inLineAlert:h,fieldsConfig:m})})};export{ce as OrderSearch,ce as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as w,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as _}from"@dropins/tools/lib.js";import{Card as U,InLineAlert as C,Icon as x,Button as V}from"@dropins/tools/components.js";import{F as L}from"../chunks/OrderCancel.js";import{useState as R,useCallback as D,useEffect as O,useMemo as H}from"@dropins/tools/preact-hooks.js";import{events as g}from"@dropins/tools/event-bus.js";import*as A from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{Text as N,useText as k}from"@dropins/tools/i18n.js";import{r as d}from"../chunks/redirectTo.js";import{a as I,g as P}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 q=e=>A.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},A.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:e,loading:a,inLineAlert:o,fieldsConfig:t})=>w(U,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(N,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(N,{id:"Order.OrderSearchForm.description"})}),o.text?s(C,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:o.type,variant:"secondary",heading:o.text,icon:s(x,{source:q})}):null,s(L,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:a,fieldsConfig:t,onSubmit:e,children:s("div",{className:"order-order-search-form__button-container",children:s(V,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:a,children:s(N,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});var h=(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))(h||{});const B=e=>{if(!e)return null;const a=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(t=>{a.has(t.name)||a.set(t.name,"false"),t.checked&&a.set(t.name,"true")}),a&&typeof a.entries=="function"){const t=a.entries();if(t&&typeof t[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(t)))||{}}return{}},M=e=>{try{return new URL(window.location.href).searchParams.get(e)}catch{return null}},G=({onError:e,isAuth:a,renderSignIn:o,routeCustomerOrder:t,routeGuestOrder:m})=>{const[E,p]=R({text:"",type:"success"}),[y,u]=R(!1),i=k({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",postcode:"Order.OrderSearchForm.postcode",number:"Order.OrderSearchForm.orderNumber"}),S=D(async r=>{const c=M("orderRef"),n=c&&c.length>20;if(!r&&!c||!(r!=null&&r.number)&&!(r!=null&&r.token)&&!c)return null;if(a){const f=await I();(f==null?void 0:f.email)===r.email?d(t,{orderRef:r==null?void 0:r.number}):n||d(m,{orderRef:r.token})}else n||d(m,{orderRef:r==null?void 0:r.token})},[a,t,m]);O(()=>{const r=g.on("order/data",c=>{S(c)},{eager:!0});return()=>{r==null||r.off()}},[S]),O(()=>{const r=M("orderRef"),c=r&&r.length>20?r:null;r&&(c?d(m,{orderRef:r}):a?d(t,{orderRef:r}):o==null||o({render:!0,formValues:{number:r}}))},[a,t,m,o]);const v=H(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:i.email,options:[],defaultValue:"",fieldType:h.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:i.postcode,options:[],defaultValue:"",fieldType:h.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:i.number,options:[],defaultValue:"",fieldType:h.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[i]);return{onSubmit:D(async(r,c)=>{if(!c)return null;u(!0);const n=B(r.target);await P(n).then(l=>{l||p({text:i.invalidSearch,type:"warning"}),g.emit("order/data",l)}).catch(async l=>{var b;let f=!0;e==null||e({error:l.message});const T=a?await I():{email:""};(T==null?void 0:T.email)===(n==null?void 0:n.email)?d(t,{orderRef:n.number}):f=o==null?void 0:o({render:T===null||((b=l==null?void 0:l.message)==null?void 0:b.includes("Please login to view the order.")),formValues:n}),f&&p({text:l.message,type:"warning"})}).finally(()=>{u(!1)})},[a,e,o,t,i.invalidSearch]),inLineAlert:E,loading:y,normalizeFieldsConfig:v}},le=({className:e,isAuth:a,renderSignIn:o,routeCustomerOrder:t,routeGuestOrder:m,onError:E})=>{const{onSubmit:p,loading:y,inLineAlert:u,normalizeFieldsConfig:i}=G({onError:E,isAuth:a,renderSignIn:o,routeCustomerOrder:t,routeGuestOrder:m});return s("div",{className:_(["order-order-search",e]),children:s(X,{onSubmit:p,loading:y,inLineAlert:u,fieldsConfig:i})})};export{le as OrderSearch,le as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index d16bfb11e7..951cce66bc 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderStatus.js +++ b/scripts/__dropins__/storefront-order/containers/OrderStatus.js @@ -1,4 +1,6 @@ -import{jsx as s,jsxs as p,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{Card as T,Header as x,Button as R,InLineAlert as L,Modal as M}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{Slot as $,classes as E}from"@dropins/tools/lib.js";import{useMemo as F,useState as U}from"@dropins/tools/preact-compat.js";import{useState as O,useEffect as N}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as _}from"@dropins/tools/event-bus.js";import{O as K}from"../chunks/OrderCancelForm.js";import{useText as m,Text as y}from"@dropins/tools/i18n.js";import{C as b}from"../chunks/OrderLoaders.js";import{G as P}from"../chunks/getGuestOrder.graphql.js";import{f as G,h as V}from"../chunks/fetch-graphql.js";import{b as k}from"../chunks/transform-order-details.js";import{g as q}from"../chunks/getStoreConfig.js";import"../chunks/requestGuestOrderCancel.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/convertCase.js";const S={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"},H=({slots:t,title:a,status:r,orderData:e})=>{const n=String(r).toLocaleLowerCase(),o=m(`Order.OrderStatusContent.${S[n]}.title`),c=m(`Order.OrderStatusContent.${S[n]}.message`),i=m(`Order.OrderStatusContent.${S[n]}.messageWithoutDate`);if(!r)return s("div",{});const l=e!=null&&e.orderStatusChangeDate?c==null?void 0:c.message.replace("{DATE}",e==null?void 0:e.orderStatusChangeDate):i.messageWithoutDate;return p(T,{className:"order-order-status-content",variant:"secondary",children:[s(x,{title:a??o.title}),p("div",{className:"order-order-status-content__wrapper",children:[s("div",{className:"order-order-status-content__wrapper-description",children:s("p",{children:l})}),s(W,{orderData:e,slots:t})]})]})};var f=(t=>(t.CANCEL="CANCEL",t.RETURN="RETURN",t.REORDER="REORDER",t))(f||{});const W=({className:t,children:a,orderData:r,slots:e,...n})=>{const o=m({cancel:"Order.OrderStatusContent.actions.cancel",return:"Order.OrderStatusContent.actions.return",reorder:"Order.OrderStatusContent.actions.reorder"}),c=F(()=>{const i=r==null?void 0:r.availableActions,l=!!(i!=null&&i.length);return s(w,{children:e!=null&&e.OrderActions?s($,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:e==null?void 0:e.OrderActions,context:r}):s("div",{"data-testid":"availableActionsList",className:E(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!l]]),children:i==null?void 0:i.map(d=>{switch(d){case f.CANCEL:return!!r&&s(Q,{orderRef:r.token??atob(r.id)});case f.RETURN:return s(R,{variant:"secondary",children:o.return});case f.REORDER:return s(R,{variant:"secondary",children:o.reorder})}})})})},[r,e==null?void 0:e.OrderActions,o]);return s("div",{...n,className:E(["order-order-actions",t]),children:c})},v=()=>{const[t,a]=O(null);return N(()=>{const r=sessionStorage.getItem("orderStoreConfig"),e=r?JSON.parse(r):null;e?a(e):q().then(n=>{n&&(sessionStorage.setItem("orderStoreConfig",JSON.stringify(n)),a(n))})},[]),t},j=({orderData:t})=>{const[a,r]=O(t),[e,n]=O(t==null?void 0:t.status);return N(()=>{const o=_.on("order/data",c=>{r(c),n(c.status)},{eager:!0});return()=>{o==null||o.off()}},[]),{orderStatus:e,order:a}},J=` +/*! 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 U,Header as F,Button as E,InLineAlert as P,Modal as K}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{f as k}from"../chunks/returnOrdersHelper.js";import{classes as y,Slot as G}from"@dropins/tools/lib.js";import{f as b}from"../chunks/formatDateToLocale.js";import{useState as O,useEffect as I,useCallback as V}from"@dropins/tools/preact-hooks.js";import{events as v}from"@dropins/tools/event-bus.js";import{useMemo as q,useState as H}from"@dropins/tools/preact-compat.js";import{r as x}from"../chunks/redirectTo.js";import"@dropins/tools/preact.js";import{O as W}from"../chunks/OrderCancelForm.js";import{useText as C,Text as L}from"@dropins/tools/i18n.js";import{r as j}from"../chunks/reorderItems.js";import{C as J}from"../chunks/OrderLoaders.js";import{G as z}from"../chunks/getGuestOrder.graphql.js";import{f as B,h as Q}from"../chunks/fetch-graphql.js";import{b as X}from"../chunks/transform-order-details.js";import{g as Y}from"../chunks/getStoreConfig.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/convertCase.js";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"},Z=({slots:r,title:t,status:n,orderData:e,routeCreateReturn:i,onError:s,routeOnSuccess:d})=>{var M;const l=!!(e!=null&&e.returnNumber),a=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[a]}.title`),h=C(`Order.OrderStatusContent.${w[a]}.message`),R=C(`Order.OrderStatusContent.${w[a]}.messageWithoutDate`),u=C({title:`Order.OrderStatusContent.resturnStatus.${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=(u==null?void 0:u.returnMessage.replace("{ORDER_CREATE_DATE}",b(e==null?void 0:e.orderDate)).replace("{RETURN_CREATE_DATE}",b(p)))??"",T=l?t??u.title:t??g.title;return N(U,{className:"order-order-status-content",variant:"secondary",children:[c(F,{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(ee,{orderData:e,slots:r,routeCreateReturn:i,routeOnSuccess:d,onError:s})]})]})};var _=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(_||{});const D=({orderData:r})=>{const[t,n]=O(r),[e,i]=O(r==null?void 0:r.status);return I(()=>{const s=v.on("order/data",d=>{n(d),i(d.status)},{eager:!0});return()=>{s==null||s.off()}},[]),{orderStatus:e,order:t}},ee=({className:r,orderData:t,slots:n,routeCreateReturn:e,routeOnSuccess:i,onError:s})=>{const d=C({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=q(()=>{const a=t==null?void 0:t.availableActions,o=!!(a!=null&&a.length),m=!!(t!=null&&t.returnNumber),p=()=>{x(e,{},t)};return c(S,{children:n!=null&&n.OrderActions?c(G,{"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:a==null?void 0:a.map(g=>{switch(g){case _.CANCEL:return c(S,{children:m?null:!!t&&c(se,{orderRef:t.token??atob(t.id)})});case _.RETURN:return c(E,{variant:"secondary",onClick:p,children:m?d.createAnotherReturn:d.createReturn});case _.REORDER:return c(S,{children:m?null:c(oe,{orderData:t,onError:s,routeOnSuccess:i,children:d.reorder})})}})})})},[s,t,i,e,n,d]);return c("div",{className:y(["order-order-actions",r]),children:l})},$=()=>{const[r,t]=O(null);return I(()=>{const n=sessionStorage.getItem("orderStoreConfig"),e=n?JSON.parse(n):null;e?t(e):Y().then(i=>{i&&(sessionStorage.setItem("orderStoreConfig",JSON.stringify(i)),t(i))})},[]),r},re=` mutation CONFIRM_CANCEL_ORDER_MUTATION( $orderId: ID!, $confirmationKey: String! @@ -16,5 +18,5 @@ import{jsx as s,jsxs as p,Fragment as w}from"@dropins/tools/preact-jsx-runtime.j } } } -${P} -`,z=async(t,a)=>G(J,{variables:{orderId:t,confirmationKey:a}}).then(async({errors:r,data:e})=>{var c,i,l,d;const n=[...(c=e==null?void 0:e.confirmCancelOrder)!=null&&c.errorV2?[(i=e==null?void 0:e.confirmCancelOrder)==null?void 0:i.errorV2]:[],...r??[]];let o=null;return(l=e==null?void 0:e.confirmCancelOrder)!=null&&l.order&&(o=k((d=e==null?void 0:e.confirmCancelOrder)==null?void 0:d.order),_.emit("order/data",o)),n.length>0?V(n):o}),B=({enableOrderCancellation:t})=>{const a=m({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[r,e]=O({text:"",status:void 0});return N(()=>{if(!t)return;const n=new URLSearchParams(window.location.search),o=n.get("orderId"),c=n.get("confirmationKey");o&&c&&z(atob(o),c).then(()=>{e({text:a.orderCancelled,status:"success"})}).catch(i=>{e({text:i.message,status:"warning"})})},[t,a.orderCancelled]),{confirmOrderCancellation:r}},Oe=({slots:t,orderData:a,className:r,statusTitle:e,status:n})=>{const{orderStatus:o,order:c}=j({orderData:a}),[i,l]=U(!1),d=()=>{l(!0);const C=new URL(window.location.href),I=C.searchParams.get("orderId"),A=C.searchParams.get("confirmationKey");I&&A&&(C.searchParams.delete("orderId"),C.searchParams.delete("confirmationKey"),window.history.replaceState({},document.title,C.toString()))},h=m({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),g=v(),{confirmOrderCancellation:u}=B({enableOrderCancellation:g==null?void 0:g.orderCancellationEnabled});return p("div",{className:E(["order-order-status",r]),children:[!i&&(u==null?void 0:u.status)!==void 0&&s(L,{heading:h.cancelOrder,onDismiss:d,description:u.text,type:u.status}),c?s(H,{title:e,status:n||o,slots:t,orderData:c}):s(b,{withCard:!1})]})},Q=({orderRef:t})=>{const[a,r]=O(!1),e=()=>{r(!0)},n=()=>{r(!1)},o=v(),c=(o==null?void 0:o.orderCancellationReasons)??[],i=l=>l.map((d,h)=>({text:d==null?void 0:d.description,value:h.toString()}));return _.on("order/data",l=>{const d=String(l.status).toLocaleLowerCase();(d==="guest order cancellation requested"||d==="canceled")&&n()}),p(w,{children:[s(R,{variant:"secondary",onClick:e,"data-testid":"cancel-button",children:s(y,{id:"Order.OrderStatusContent.actions.cancel"})}),a&&s(M,{centered:!0,size:"medium",onClose:n,className:"order-order-cancel__modal",title:s("h2",{className:"order-order-cancel__title",children:s(y,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:s(K,{orderRef:t,cancelReasons:i(c)})})]})};export{Oe as OrderStatus,Oe as default}; +${z} +`,te=async(r,t)=>B(re,{variables:{orderId:r,confirmationKey:t}}).then(async({errors:n,data:e})=>{var d,l,a,o;const i=[...(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(a=e==null?void 0:e.confirmCancelOrder)!=null&&a.order&&(s=X((o=e==null?void 0:e.confirmCancelOrder)==null?void 0:o.order),v.emit("order/data",s)),i.length>0?Q(i):s}),ne=({enableOrderCancellation:r})=>{const t=C({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[n,e]=O({text:"",status:void 0});return I(()=>{if(!r)return;const i=new URLSearchParams(window.location.search),s=i.get("orderId"),d=i.get("confirmationKey");s&&d&&te(atob(s),d).then(()=>{e({text:t.orderCancelled,status:"success"})}).catch(l=>{e({text:l.message,status:"warning"})})},[r,t.orderCancelled]),{confirmOrderCancellation:n}},ve=({slots:r,orderData:t,className:n,statusTitle:e,status:i,routeCreateReturn:s,onError:d,routeOnSuccess:l})=>{const{orderStatus:a,order:o}=D({orderData:t}),[m,p]=H(!1),g=()=>{p(!0);const f=new URL(window.location.href),A=f.searchParams.get("orderId"),T=f.searchParams.get("confirmationKey");A&&T&&(f.searchParams.delete("orderId"),f.searchParams.delete("confirmationKey"),window.history.replaceState({},document.title,f.toString()))},h=C({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),R=$(),{confirmOrderCancellation:u}=ne({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(P,{heading:h.cancelOrder,onDismiss:g,description:u.text,type:u.status}),o?c(Z,{title:e,status:i||a,slots:r,orderData:o,routeCreateReturn:s,onError:d,routeOnSuccess:l}):c(J,{withCard:!1})]})},se=({orderRef:r})=>{const[t,n]=O(!1),e=()=>{n(!0)},i=()=>{n(!1)},s=$(),d=(s==null?void 0:s.orderCancellationReasons)??[],l=a=>a.map((o,m)=>({text:o==null?void 0:o.description,value:m.toString()}));return v.on("order/data",a=>{const o=String(a.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(L,{id:"Order.OrderStatusContent.actions.cancel"})}),t&&c(K,{centered:!0,size:"medium",onClose:i,className:"order-order-cancel__modal",title:c("h2",{className:"order-order-cancel__title",children:c(L,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:c(W,{orderRef:r,cancelReasons:l(d)})})]})},oe=({onError:r,routeOnSuccess:t,orderData:n,children:e})=>{const[i,s]=O(!1),d=V(()=>{s(!0);const l=n==null?void 0:n.number;j(l).then(({success:a,userInputErrors:o})=>{a&&x(t,{}),o.length&&(r==null||r(o))}).catch(a=>{r==null||r(a.message)}).finally(()=>{s(!1)})},[n,t,r]);return c(E,{type:"button",disabled:i,variant:"secondary",className:"order-reorder",onClick:d,children:e})};export{ve as OrderStatus,ve as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index eaf0064599..6f63b76398 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1 +1,3 @@ -import{jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as S}from"@dropins/tools/lib.js";import"@dropins/tools/preact-compat.js";import{useState as i,useEffect as $,useCallback as h}from"@dropins/tools/preact-hooks.js";import{u as I,R as y}from"../chunks/useIsMobile.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getCustomerOrdersReturn.js";import{useText as M}from"@dropins/tools/i18n.js";import"../chunks/OrderLoaders.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";const f={totalPages:1,currentPage:1,pageSize:1},T=()=>{const[s,n]=i(!0),[u,t]=i([]),[o,a]=i(f),[m,d]=i(1);$(()=>{A().then(e=>{t((e==null?void 0:e.ordersReturn)??[]),a((e==null?void 0:e.pageInfo)??f)}).finally(()=>{n(!1)})},[]);const l=h(e=>{d(e)},[]);return{pageInfo:o,selectedPage:m,loading:s,orderReturns:u,handleSetSelectPage:l}},J=({slots:s,withReturnsListButton:n,className:u,minifiedView:t,withHeader:o,withThumbnails:a,returnsInMinifiedView:m,routeReturnDetails:d,routeOrderDetails:l,routeTracking:e,routeReturnsList:g,routeProductDetails:L})=>{const{pageInfo:R,selectedPage:p,handleSetSelectPage:O,loading:b,orderReturns:P}=T(),w=I(),r=t?"minifiedView":"fullSizeView",N=M({viewAllOrdersButton:`Order.Returns.${r}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return c("div",{className:S(["order-returns-list",u]),children:c(y,{minifiedViewKey:r,withOrderNumber:!0,withReturnNumber:!0,slots:s,selectedPage:p,handleSetSelectPage:O,pageInfo:R,withReturnsListButton:n,isMobile:w,orderReturns:P,translations:N,withHeader:o,returnsInMinifiedView:m,withThumbnails:a,minifiedView:t,routeReturnDetails:d,routeOrderDetails:l,routeTracking:e,routeReturnsList:g,routeProductDetails:L,loading:b})})};export{J as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{classes as S}from"@dropins/tools/lib.js";import{useState as i,useEffect as $,useCallback as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as I}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import"@dropins/tools/preact-compat.js";import{R as A}from"../chunks/ReturnsListContent.js";import"@dropins/tools/preact.js";import{useText as M}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/OrderLoaders.js";const f={totalPages:1,currentPage:1,pageSize:1},T=()=>{const[s,n]=i(!0),[o,t]=i([]),[u,a]=i(f),[m,d]=i(1);$(()=>{I().then(r=>{t((r==null?void 0:r.ordersReturn)??[]),a((r==null?void 0:r.pageInfo)??f)}).finally(()=>{n(!1)})},[]);const l=h(r=>{d(r)},[]);return{pageInfo:u,selectedPage:m,loading:s,orderReturns:o,handleSetSelectPage:l}},W=({slots:s,withReturnsListButton:n,className:o,minifiedView:t,withHeader:u,withThumbnails:a,returnsInMinifiedView:m,routeReturnDetails:d,routeOrderDetails:l,routeTracking:r,routeReturnsList:g,routeProductDetails:L})=>{const{pageInfo:p,selectedPage:R,handleSetSelectPage:O,loading:b,orderReturns:P}=T(),w=y(),e=t?"minifiedView":"fullSizeView",N=M({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 c("div",{className:S(["order-returns-list",o]),children:c(A,{minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:s,selectedPage:R,handleSetSelectPage:O,pageInfo:p,withReturnsListButton:n,isMobile:w,orderReturns:P,translations:N,withHeader:u,returnsInMinifiedView:m,withThumbnails:a,minifiedView:t,routeReturnDetails:d,routeOrderDetails:l,routeTracking:r,routeReturnsList:g,routeProductDetails:L,loading:b})})};export{W as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js index 4071f51c2f..61e1658aca 100644 --- a/scripts/__dropins__/storefront-order/containers/ShippingStatus.js +++ b/scripts/__dropins__/storefront-order/containers/ShippingStatus.js @@ -1 +1,3 @@ -import{jsxs as s,jsx as e,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as x,classes as F}from"@dropins/tools/lib.js";import{Card as f,Header as m,Accordion as w,AccordionSection as G,ContentGrid as q,Image as $}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{useText as V,Text as H}from"@dropins/tools/i18n.js";import{C as W}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact-compat.js";import{useState as z,useEffect as B}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as J}from"@dropins/tools/event-bus.js";var T=(n=>(n.PENDING="pending",n.SHIPPING="shipping",n.COMPLETE="complete",n.PROCESSING="processing",n.HOLD="on hold",n.CANCELED="Canceled",n.SUSPECTED_FRAUD="suspected fraud",n.PAYMENT_REVIEW="payment review",n))(T||{});const K=({slots:n,orderData:i,collapseThreshold:t=10,routeProductDetails:c})=>{var I,u,v,O,L;const d=V({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",notYetShippedImagesTitle:"Order.ShippingStatusCard.notYetShippedImagesTitle",noInfoTitle:"Order.OrderStatusContent.noInfoTitle"}),g=c?"a":"span",a=(I=i==null?void 0:i.status)==null?void 0:I.toLocaleLowerCase(),M=((u=i==null?void 0:i.shipments)==null?void 0:u.length)===1&&(a==null?void 0:a.includes(T.COMPLETE)),l=(v=i==null?void 0:i.items)==null?void 0:v.filter(r=>(r==null?void 0:r.quantityShipped)===0);if(!i||a!=null&&a.includes(T.CANCELED))return null;if(!((O=i==null?void 0:i.shipments)!=null&&O.length))return s(f,{variant:"secondary",className:"order-shipping-status-card",children:[e(m,{title:d.shippingInfoTitle}),e("div",{className:"order-shipping-status-card__header",children:s("div",{className:"order-shipping-status-card__header--content",children:[i!=null&&i.carrier?e("p",{children:i==null?void 0:i.carrier}):null,e("p",{children:d.noInfoTitle})]})})]});const R=e(H,{id:"Order.ShippingStatusCard.notYetShippedItem",plural:l==null?void 0:l.length});return s(S,{children:[(L=i==null?void 0:i.shipments)==null?void 0:L.map(({tracking:r,items:h,id:o},U)=>{const Y=e(H,{id:"Order.ShippingStatusCard.notYetShippedItem",plural:h==null?void 0:h.length});return s(f,{variant:"secondary",className:"order-shipping-status-card",children:[e(m,{title:d.shippingCardTitle}),r==null?void 0:r.map(p=>{var C;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:[d.carrier," ",(C=p==null?void 0:p.carrier)==null?void 0:C.toLocaleUpperCase()," | ",p==null?void 0:p.number]}),e("p",{children:p==null?void 0:p.title})]}),n!=null&&n.DeliveryTrackActions?e(x,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:n==null?void 0:n.DeliveryTrackActions,context:{trackInformation:p}}):null]},p.number)}),M?null:e(w,{actionIconPosition:"right","data-testid":"dropinAccordion",children:e(G,{"data-position":U+1,defaultOpen:t>=(h==null?void 0:h.length),title:s(S,{children:[`${d.notYetShippedImagesTitle} (${h==null?void 0:h.length} `,Y,")"]}),children:e(q,{maxColumns:6,emptyGridContent:e(S,{}),className:"order-shipping-status-card__images",children:h==null?void 0:h.map(p=>{var y,_,A,b,E,N;const C=(A=(_=(y=p==null?void 0:p.orderItem)==null?void 0:y.product)==null?void 0:_.thumbnail)==null?void 0:A.label,j=(N=(E=(b=p==null?void 0:p.orderItem)==null?void 0:b.product)==null?void 0:E.thumbnail)==null?void 0:N.url;return e(g,{href:(c==null?void 0:c(p))??"#",children:e($,{alt:C,src:j||"",width:85,height:114})},p.id)})})})}),n!=null&&n.DeliveryTimeLine?e(x,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:n==null?void 0:n.DeliveryTimeLine,context:{}}):null]},o)}),l!=null&&l.length?s(f,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[e(m,{title:d.notYetShippedTitle}),e(w,{actionIconPosition:"right",children:e(G,{defaultOpen:t>=(l==null?void 0:l.length),title:s(S,{children:[`${d.notYetShippedImagesTitle} (${l==null?void 0:l.length} `,R,")"]}),children:e("div",{className:"order-shipping-status-card__images",children:l==null?void 0:l.map(r=>{var h,o;return e(g,{href:(c==null?void 0:c(r))??"#",children:e($,{alt:(h=r.thumbnail)==null?void 0:h.label,src:((o=r.thumbnail)==null?void 0:o.url)||"",width:85,height:114})},r.id)})})})})]}):null]})},Q=({orderData:n})=>{const[i,t]=z(n);return B(()=>{const c=J.on("order/data",d=>{t(d)},{eager:!0});return()=>{c==null||c.off()}},[]),{order:i}},rn=({slots:n,className:i,collapseThreshold:t,orderData:c,routeProductDetails:d})=>{const{order:g}=Q({orderData:c});return e("div",{className:F(["order-shipping-status",i]),children:g?e(K,{slots:n,orderData:g,collapseThreshold:t,routeProductDetails:d}):e(W,{withCard:!1})})};export{rn as ShippingStatus,rn as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as u,jsx as n,Fragment as b}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L,Slot as A}from"@dropins/tools/lib.js";import{Card as N,Header as _,Accordion as o,AccordionSection as x,ContentGrid as W,Image as E}from"@dropins/tools/components.js";import"../chunks/OrderCancel.js";import{useState as y,useEffect as J}from"@dropins/tools/preact-hooks.js";import{events as K}from"@dropins/tools/event-bus.js";import{u as Q}from"../chunks/useIsMobile.js";import{Text as $,useText as X}from"@dropins/tools/i18n.js";import{C as Z}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";var R=(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))(R||{});const Y=({orderData:e})=>{const[r,i]=y(!0),[c,d]=y(e),[m,f]=y(!1);return J(()=>{const a=K.on("order/data",t=>{d(t),f(t==null?void 0:t.isVirtual),i(!1)},{eager:!0});return()=>{a==null||a.off()}},[]),{loading:r,order:c,isVirtualProduct:m}},P=({slots:e,collapseThreshold:r,translations:i,returnData:c,routeTracking:d,routeProductDetails:m})=>{var t;const f=Q(),a=m?"a":"span";return u(N,{variant:"secondary",className:L(["order-shipping-status-card","order-shipping-status-card--return-order"]),children:[n(_,{title:i.returnOrderCardTitle}),u("div",{children:[(t=c==null?void 0:c.tracking)==null?void 0:t.map((l,C)=>{var S,p;return u("p",{children:[`${i.carrier} ${(p=(S=l==null?void 0:l.carrier)==null?void 0:S.label)==null?void 0:p.toLocaleUpperCase()}: `,n("a",{href:`${(d==null?void 0:d(l))??"#"}`,rel:"noreferrer",children:l.trackingNumber})]},`${l.trackingNumber}_${C}`)}),e!=null&&e.ReturnItemsDetails?n(A,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:e==null?void 0:e.ReturnItemsDetails,context:{items:c.items}}):null,n(o,{actionIconPosition:"right","data-testid":"dropinAccordion",children:n(x,{defaultOpen:r>=c.items.length,title:n($,{id:"Order.ShippingStatusCard.itemText",plural:c.items.length,fields:{count:c.items.length}}),children:n(W,{maxColumns:f?3:9,emptyGridContent:n(b,{}),className:L(["order-shipping-status-card__images",["order-shipping-status-card__images-3",f]]),children:c.items.map((l,C)=>{var I,T;const S=(I=l.thumbnail)==null?void 0:I.label,p=(T=l.thumbnail)==null?void 0:T.url;return n(a,{href:(m==null?void 0:m(l))??"#","data-testid":`${C}${l.uid}`,children:n(E,{alt:S,src:p,width:85,height:114})},`${C}${l.uid}`)})})})})]})]})},k=({translations:e,slots:r,orderData:i,collapseThreshold:c=10,routeProductDetails:d,routeTracking:m})=>{var I,T,w,G,M;const f=!!(i!=null&&i.returnNumber),a=i==null?void 0:i.returnNumber,t=d?"a":"span",l=(I=i==null?void 0:i.status)==null?void 0:I.toLocaleLowerCase(),S=((T=i==null?void 0:i.shipments)==null?void 0:T.length)===1&&(l==null?void 0:l.includes(R.COMPLETE)),p=(w=i==null?void 0:i.items)==null?void 0:w.filter(g=>(g==null?void 0:g.quantityShipped)===0);if(f&&(i!=null&&i.returns.length)){const g=i.returns.find(s=>s.returnNumber===a);return n(b,{children:g&&g.tracking.length>0?n(P,{slots:r,collapseThreshold:c,translations:e,returnData:g,routeTracking:m,routeProductDetails:d}):null})}return!i||l!=null&&l.includes(R.CANCELED)?null:(G=i==null?void 0:i.shipments)!=null&&G.length?u(b,{children:[(M=i==null?void 0:i.shipments)==null?void 0:M.map(({tracking:g,items:s,id:O},z)=>u(N,{variant:"secondary",className:"order-shipping-status-card",children:[n(_,{title:e.shippingCardTitle}),g==null?void 0:g.map(h=>{var v;return u("div",{className:"order-shipping-status-card__header",role:"status",children:[u("div",{className:"order-shipping-status-card__header--content",children:[u("p",{children:[e.carrier," ",(v=h==null?void 0:h.carrier)==null?void 0:v.toLocaleUpperCase()," | ",h==null?void 0:h.number]}),n("p",{children:h==null?void 0:h.title})]}),r!=null&&r.DeliveryTrackActions?n(A,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:r==null?void 0:r.DeliveryTrackActions,context:{trackInformation:h}}):null]},h.number)}),S?null:n(o,{actionIconPosition:"right","data-testid":"dropinAccordion",children:n(x,{"data-position":z+1,defaultOpen:c>=(s==null?void 0:s.length),title:n(b,{children:n($,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:s==null?void 0:s.length,fields:{count:s==null?void 0:s.length}})}),children:n(W,{maxColumns:6,emptyGridContent:n(b,{}),className:"order-shipping-status-card__images",children:s==null?void 0:s.map(h=>{var V,U,H,j,F,q;const v=(H=(U=(V=h==null?void 0:h.orderItem)==null?void 0:V.product)==null?void 0:U.thumbnail)==null?void 0:H.label,B=(q=(F=(j=h==null?void 0:h.orderItem)==null?void 0:j.product)==null?void 0:F.thumbnail)==null?void 0:q.url;return n(t,{href:(d==null?void 0:d(h))??"#",children:n(E,{alt:v,src:B||"",width:85,height:114})},h.id)})})})}),r!=null&&r.DeliveryTimeLine?n(A,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:r==null?void 0:r.DeliveryTimeLine,context:{}}):null]},O)),p!=null&&p.length?u(N,{variant:"secondary",className:"order-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[n(_,{title:e.notYetShippedTitle}),n(o,{actionIconPosition:"right",children:n(x,{defaultOpen:c>=(p==null?void 0:p.length),title:n($,{id:"Order.ShippingStatusCard.notYetShippedImagesTitle",plural:p==null?void 0:p.length,fields:{count:p==null?void 0:p.length}}),children:n("div",{className:"order-shipping-status-card__images",children:p==null?void 0:p.map(g=>{var s,O;return n(t,{href:(d==null?void 0:d(g))??"#",children:n(E,{alt:(s=g.thumbnail)==null?void 0:s.label,src:((O=g.thumbnail)==null?void 0:O.url)||"",width:85,height:114})},g.id)})})})})]}):null]}):u(N,{variant:"secondary",className:"order-shipping-status-card",children:[n(_,{title:e.shippingInfoTitle}),n("div",{className:"order-shipping-status-card__header",children:u("div",{className:"order-shipping-status-card__header--content",children:[i!=null&&i.carrier?n("p",{children:i==null?void 0:i.carrier}):null,n("p",{children:e.noInfoTitle})]})})]})},gi=({slots:e,className:r,collapseThreshold:i,orderData:c,routeOrderDetails:d,routeTracking:m,routeProductDetails:f})=>{const{loading:a,order:t,isVirtualProduct:l}=Y({orderData:c}),C=X({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"});return!a&&l?null:n("div",{className:L(["order-shipping-status",r]),children:!a&&t?n(k,{translations:C,routeOrderDetails:d,routeTracking:m,slots:e,orderData:t,collapseThreshold:i,routeProductDetails:f}):n(Z,{withCard:!1})})};export{gi as ShippingStatus,gi as default}; diff --git a/scripts/__dropins__/storefront-order/data/models/customer-orders-return.d.ts b/scripts/__dropins__/storefront-order/data/models/customer-orders-return.d.ts index 8090cbc77d..0893517063 100644 --- a/scripts/__dropins__/storefront-order/data/models/customer-orders-return.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/customer-orders-return.d.ts @@ -1,7 +1,6 @@ import { OrderItemModel } from './order-details'; -export interface OrdersReturnItemsPropsModel { - orderItem: OrderItemModel; +export interface OrdersReturnItemsPropsModel extends OrderItemModel { quantity: number; requestQuantity: number; status: string; @@ -23,6 +22,7 @@ export interface OrdersReturnPropsModel { orderNumber: string; returnStatus: string; returnNumber: string; + createdReturnAt: string; tracking: OrdersReturnTrackingProps[]; items: OrdersReturnItemsPropsModel[]; } 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 5dcfb5d5fb..46f864bdda 100644 --- a/scripts/__dropins__/storefront-order/data/models/order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/models/order-details.d.ts @@ -19,6 +19,7 @@ export type OrderAddressModel = { }[]; } | null; export type OrderItemProductModel = { + __typename: string; stockStatus?: string; canonicalUrl?: string; urlKey?: string; @@ -87,6 +88,7 @@ export type OrderItemModel = { quantityRefunded: number; quantityReturned: number; quantityShipped: number; + requestQuantity: number; }; export type ShipmentItemsModel = { id: string; @@ -110,6 +112,7 @@ export type ShipmentsModel = { items: ShipmentItemsModel[]; }; export type OrderDataModel = { + returnNumber: string; id: string; orderStatusChangeDate?: string; number: string; @@ -120,6 +123,7 @@ export type OrderDataModel = { totalQuantity: number; shippingMethod?: string; carrier?: string; + orderDate: string; returns: OrdersReturnPropsModel[]; discounts: { amount: MoneyProps; diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-guest-order.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-guest-order.d.ts index 37fb6beeb4..bfd1ea97bb 100644 --- a/scripts/__dropins__/storefront-order/data/transforms/transform-guest-order.d.ts +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-guest-order.d.ts @@ -1,6 +1,6 @@ import { GuestOrderByTokenResponse, GuestOrderResponse } from '../../types'; import { OrderDataModel } from '../models'; -export declare const transformGuestOrder: (response: GuestOrderResponse) => OrderDataModel | null; -export declare const transformGuestOrderByToken: (response: GuestOrderByTokenResponse) => OrderDataModel | null; +export declare const transformGuestOrder: (response: GuestOrderResponse, returnRef?: string) => OrderDataModel | null; +export declare const transformGuestOrderByToken: (response: GuestOrderByTokenResponse, returnRef?: string) => OrderDataModel | null; //# sourceMappingURL=transform-guest-order.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts b/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts index cf3b00b105..5421b44993 100644 --- a/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts +++ b/scripts/__dropins__/storefront-order/data/transforms/transform-order-details.d.ts @@ -12,6 +12,6 @@ export declare const transformLinks: (links: { result: string; } | null; export declare const transformOrderItems: (items: OrderItemProps[]) => OrderItemModel[]; -export declare const transformOrderData: (orderData: OrderProps) => any; -export declare const transformOrderDetails: (queryType: QueryType, response: ResponseData) => TransformedData; +export declare const transformOrderData: (orderData: OrderProps, returnRef?: string) => any; +export declare const transformOrderDetails: (queryType: QueryType, response: ResponseData, returnRef?: string) => TransformedData; //# sourceMappingURL=transform-order-details.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/hooks/containers/useShippingStatus.d.ts b/scripts/__dropins__/storefront-order/hooks/containers/useShippingStatus.d.ts index 8e4d238edd..954bc47b8b 100644 --- a/scripts/__dropins__/storefront-order/hooks/containers/useShippingStatus.d.ts +++ b/scripts/__dropins__/storefront-order/hooks/containers/useShippingStatus.d.ts @@ -2,6 +2,8 @@ import { OrderDataModel } from '../../data/models'; import { UseShippingStatusProps } from '../../types'; export declare const useShippingStatus: ({ orderData }: UseShippingStatusProps) => { + loading: boolean; order: OrderDataModel | undefined; + isVirtualProduct: boolean; }; //# sourceMappingURL=useShippingStatus.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 d496045423..a97a660953 100644 --- a/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-order/i18n/en_US.json.d.ts @@ -2,6 +2,7 @@ declare const _default: { "Order": { "OrderCostSummary": { "headerText": "Order summary", + "headerReturnText": "Return summary", "subtotal": { "title": "Subtotal" }, @@ -90,6 +91,8 @@ declare const _default: { "OrderProductListContent": { "cancelledTitle": "Cancelled", "allOrdersTitle": "Your order", + "returnedTitle": "Your return", + "refundedTitle": "Your refunded", "downloadableCount": "Files", "stockStatus": { "inStock": "In stock", @@ -115,23 +118,46 @@ declare const _default: { } }, "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 info", + "shippingInfoTitle": "Shipping information", "notYetShippedTitle": "Not yet shipped", - "notYetShippedImagesTitle": "Package contents", - "notYetShippedItem": { - "singular": "item", - "plural": "items" + "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}", + "resturnStatus": { + "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", - "return": "Return or replace", + "createReturn": "Return or replace", + "createAnotherReturn": "Start another return", "reorder": "Reorder" }, "orderPending": { @@ -182,6 +208,25 @@ declare const _default: { "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" }, @@ -194,8 +239,11 @@ declare const _default: { "billingAddress": { "title": "Billing address" }, - "billingMethods": { + "paymentMethods": { "title": "Payment method" + }, + "returnInformation": { + "title": "Return details" } }, "Errors": { diff --git a/scripts/__dropins__/storefront-order/lib/convertToInputDateFormat.d.ts b/scripts/__dropins__/storefront-order/lib/convertToInputDateFormat.d.ts deleted file mode 100644 index 0a857dfb27..0000000000 --- a/scripts/__dropins__/storefront-order/lib/convertToInputDateFormat.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const convertToInputDateFormat: (dateTimeString: string) => string; -export declare const converDeliveryOrderDate: (dateTimeString: string) => string; -//# sourceMappingURL=convertToInputDateFormat.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/lib/formatDateToLocale.d.ts b/scripts/__dropins__/storefront-order/lib/formatDateToLocale.d.ts new file mode 100644 index 0000000000..c32256ba3c --- /dev/null +++ b/scripts/__dropins__/storefront-order/lib/formatDateToLocale.d.ts @@ -0,0 +1,31 @@ +/** + * Formats a date string according to a specified locale and options. + * Returns "Invalid Date" if the input date string is invalid. + * + * @param {string} date - The date string to be formatted. + * @param {string} [locale='en-US'] - The locale to use for formatting. Defaults to 'en-US'. + * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options to customize the output. + * @returns {string} The formatted date string, or "Invalid Date" if the input is invalid. + * + * @example + * // Default formatting (en-US locale, MM/DD/YYYY) + * console.log(formatDateToLocale('2023-08-29')); + * // Output: "08/29/2023" + * + * @example + * // Formatting with a specified locale (e.g., en-GB for DD/MM/YYYY) + * console.log(formatDateToLocale('2023-08-29', 'en-GB')); + * // Output: "29/08/2023" + * + * @example + * // Formatting with a specified locale and custom options (e.g., de-DE with long month format) + * console.log(formatDateToLocale('2023-08-29', 'de-DE', { month: 'long', year: 'numeric' })); + * // Output: "29. August 2023" + * + * @example + * // Handling an invalid date string + * console.log(formatDateToLocale('invalid-date')); + * // Output: "Invalid Date" + */ +export declare const formatDateToLocale: (date: string, locale?: string, options?: Intl.DateTimeFormatOptions) => string; +//# sourceMappingURL=formatDateToLocale.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/lib/redirectTo.d.ts b/scripts/__dropins__/storefront-order/lib/redirectTo.d.ts index 9a2297bfb7..16b9507c5e 100644 --- a/scripts/__dropins__/storefront-order/lib/redirectTo.d.ts +++ b/scripts/__dropins__/storefront-order/lib/redirectTo.d.ts @@ -1,3 +1,3 @@ export type QueryParams = Record; -export declare const redirectTo: (getUrl?: () => string, queryParams?: QueryParams) => void; +export declare const redirectTo: (getUrl?: ((params?: any) => string) | undefined, queryParams?: QueryParams, functionParams?: any) => void; //# sourceMappingURL=redirectTo.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 27d659e6e4..51988a98a5 100644 --- a/scripts/__dropins__/storefront-order/render.js +++ b/scripts/__dropins__/storefront-order/render.js @@ -1,2 +1,4 @@ -(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)}})('.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" "postcode" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--postcode{grid-area:postcode}.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 postcode" "number number" "button button"}}.order-order-status-content .dropin-card__content{gap:0}.order-order-status-content__wrapper p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.order-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.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{margin:0;padding:0;margin-bottom:var(--spacing-xsmall)}.order-shipping-status-card .order-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important;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)}.order-order-actions__wrapper--empty{display:none}.order-customer-details-content .dropin-card__content{gap:0}.order-customer-details-content__container{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.order-customer-details-content__container{display:grid;grid-template-columns:auto;grid-template-rows:auto auto auto;gap:var(--spacing-medium);grid-auto-flow:row}.order-customer-details-content__container-email{grid-area:1 / 1 / 2 / 2}.order-customer-details-content__container-shipping_address{grid-area:2 / 1 / 3 / 2}.order-customer-details-content__container-billing_address{grid-area:2 / 2 / 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-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-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:65px;height:65px}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin:0;padding:0}.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-order-cancel-reasons-form__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-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 a}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={OrderCostSummary:{headerText:"Order 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"},resturnStatus:{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"},resturnStatus:{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",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",postcode:"Zip Code",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping info",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:"Package contents",notYetShippedItem:{singular:"item",plural:"items"}},OrderStatusContent:{noInfoTitle:"Check back later for more details.",actions:{cancel:"Cancel order",return:"Return or replace",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",email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},billingMethods:{title:"Payment method"}},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]=n("en_US");return d(()=>{const e=c.on("locale",s=>{i(s)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},T=new a(r(h,{}));export{T as render}; +/*! 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)}})('.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" "postcode" "number" "button";gap:var(--spacing-medium)}.order-order-search-form__wrapper__item--email{grid-area:email}.order-order-search-form__wrapper__item--postcode{grid-area:postcode}.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 postcode" "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:65px;height:65px}.order-order-product-list-content__items{display:grid;gap:var(--spacing-medium);list-style:none;margin: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-order-cancel-reasons-form__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-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 d,useEffect as s}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={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"},resturnStatus:{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"},resturnStatus:{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:"Your return",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",postcode:"Zip Code",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}",resturnStatus:{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]=d("en_US");return s(()=>{const e=c.on("locale",a=>{i(a)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:o,langDefinitions:m,children:t})},v=new n(r(h,{}));export{v as render}; diff --git a/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts b/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts index eb6dcc6621..b3b80df6bf 100644 --- a/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/api/getOrderDetails.types.d.ts @@ -185,6 +185,7 @@ export declare enum AvailableActionsProps { export interface ReturnsItemsProps { number: string; status: string; + created_at: string; order: { number: string; token: string; diff --git a/scripts/__dropins__/storefront-order/types/api/reorderItems.types.d.ts b/scripts/__dropins__/storefront-order/types/api/reorderItems.types.d.ts new file mode 100644 index 0000000000..0e6aea61fd --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/api/reorderItems.types.d.ts @@ -0,0 +1,27 @@ +export interface UserInputErrorProps { + code: string; + message: string; + path: [string]; +} +export interface ReorderItemsResponse { + data: { + reorderItems: { + cart: { + itemsV2: { + items: { + uid: string; + }[]; + }; + }; + userInputErrors: UserInputErrorProps[]; + }; + }; + errors?: { + message: string; + }[]; +} +export interface ReorderItemsProps { + success: boolean; + userInputErrors: UserInputErrorProps[]; +} +//# sourceMappingURL=reorderItems.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/customerDetails.types.d.ts b/scripts/__dropins__/storefront-order/types/customerDetails.types.d.ts index 4b873ab9ca..425e0a61d7 100644 --- a/scripts/__dropins__/storefront-order/types/customerDetails.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/customerDetails.types.d.ts @@ -1,4 +1,5 @@ -import { OrderDataModel } from '../data/models'; +import { SlotProps } from '@dropins/tools/types/elsie/src/lib'; +import { OrderDataModel, OrdersReturnPropsModel } from '../data/models'; export interface KeysSortOrderProps { name: string; @@ -17,16 +18,20 @@ export interface CustomerDetailsProps { orderData?: OrderDataModel; withHeader?: boolean; title?: string; + slots: { + OrderReturnInformation: SlotProps; + }; } export interface UseCustomerDetails { orderData?: OrderDataModel; } export interface CustomerDetailsContentProps extends Omit { + translations: Record; loading: boolean; order?: OrderDataModel; normalizeAddress?: { - billingAddress: NormalizeAddressProps[][]; - shippingAddress: NormalizeAddressProps[][]; + billingAddress: NormalizeAddressProps[]; + shippingAddress: NormalizeAddressProps[]; }; } export interface CustomerAddressesModel { diff --git a/scripts/__dropins__/storefront-order/types/index.d.ts b/scripts/__dropins__/storefront-order/types/index.d.ts index 1081a7af0d..e207247e77 100644 --- a/scripts/__dropins__/storefront-order/types/index.d.ts +++ b/scripts/__dropins__/storefront-order/types/index.d.ts @@ -4,6 +4,7 @@ export * from './api/getGuestOrder.types'; export * from './api/getAttributesForm.types'; export * from './api/getCustomer.types'; export * from './api/getCustomerOrdersReturn.types'; +export * from './api/reorderItems.types'; export * from './orderSearch.types'; export * from './form.types'; export * from './orderStatus.types'; @@ -14,4 +15,5 @@ export * from './returnsList.types'; export * from './emptyList.types'; export * from './orderProductList.types'; export * from './orderCostSummary.types'; +export * from './reorder.types'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/orderStatus.types.d.ts b/scripts/__dropins__/storefront-order/types/orderStatus.types.d.ts index df2888169f..2df161a36a 100644 --- a/scripts/__dropins__/storefront-order/types/orderStatus.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/orderStatus.types.d.ts @@ -1,6 +1,6 @@ -import { HTMLAttributes } from 'preact/compat'; -import { OrderDataModel } from '../data/models'; +import { OrderDataModel, OrdersReturnPropsModel } from '../data/models'; import { SlotProps } from '@dropins/tools/types/elsie/src/lib'; +import { UserInputErrorProps } from '.'; export declare enum StatusEnumProps { PENDING = "pending", @@ -15,24 +15,32 @@ export declare enum StatusEnumProps { type DefaultSlotContext = { orderData?: OrderDataModel; }; -export interface OrderStatusProps extends HTMLAttributes { +export interface OrderStatusProps { + className?: string; orderData?: OrderDataModel; statusTitle?: string; status?: StatusEnumProps; slots?: { OrderActions: SlotProps; }; + routeCreateReturn?: (orderReturn: OrdersReturnPropsModel) => string; + routeOnSuccess?: () => string; + onError?: (errorInformation: UserInputErrorProps[] | string) => void; } export interface OrderStatusContentProps extends Omit { title?: string; status?: StatusEnumProps; orderData?: OrderDataModel; } -export interface OrderActionsProps extends HTMLAttributes { +export interface OrderActionsProps { + className?: string; orderData?: OrderDataModel; slots?: { OrderActions: SlotProps; }; + routeCreateReturn?: (orderReturn: OrdersReturnPropsModel) => string; + routeOnSuccess?: () => string; + onError?: (errorInformation: UserInputErrorProps[] | string) => void; } export interface UseOrderStatusProps { orderData?: OrderDataModel; diff --git a/scripts/__dropins__/storefront-order/types/reorder.types.d.ts b/scripts/__dropins__/storefront-order/types/reorder.types.d.ts new file mode 100644 index 0000000000..614e687e48 --- /dev/null +++ b/scripts/__dropins__/storefront-order/types/reorder.types.d.ts @@ -0,0 +1,9 @@ +import { OrderDataModel } from '../data/models'; +import { UserInputErrorProps } from '.'; + +export interface ReorderProps { + orderData?: OrderDataModel; + routeOnSuccess?: () => string; + onError?: (errorInformation: UserInputErrorProps[] | string) => void; +} +//# sourceMappingURL=reorder.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts b/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts index 6148ae2531..055870d026 100644 --- a/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts +++ b/scripts/__dropins__/storefront-order/types/shippingStatus.types.d.ts @@ -1,19 +1,33 @@ import { HTMLAttributes } from 'preact/compat'; import { SlotProps } from '@dropins/tools/types/elsie/src/lib'; -import { OrderDataModel } from '../data/models'; +import { OrderDataModel, OrdersReturnPropsModel, OrdersReturnTrackingProps } from '../data/models'; +type routeTypes = { + returnNumber?: string; + token?: string; + orderNumber?: string; +}; export interface ShippingStatusProps extends HTMLAttributes { orderData?: OrderDataModel; collapseThreshold?: number; slots?: { DeliveryTimeLine?: SlotProps; DeliveryTrackActions?: SlotProps; + ReturnItemsDetails?: SlotProps; }; - routeProductDetails?: (productData: any) => string; + routeOrderDetails?: ({ returnNumber, token, orderNumber, }: routeTypes) => string; + routeTracking?: (track: OrdersReturnTrackingProps) => string; + routeProductDetails?: (product: any) => string; } export interface UseShippingStatusProps { orderData?: OrderDataModel; } export interface ShippingStatusCardProps extends ShippingStatusProps { + translations: Record; } +export interface ShippingStatusReturnCardProps extends ShippingStatusCardProps { + collapseThreshold: number; + returnData: OrdersReturnPropsModel; +} +export {}; //# sourceMappingURL=shippingStatus.types.d.ts.map \ No newline at end of file diff --git a/scripts/constants.js b/scripts/constants.js index 409e212142..73493043c3 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -1,11 +1,16 @@ export const SUPPORT_PATH = '/support'; + +// GUEST export const ORDER_STATUS_PATH = '/order-status'; export const ORDER_DETAILS_PATH = '/order-details'; +export const RETURN_DETAILS_PATH = '/return-details'; // CUSTOMER export const CUSTOMER_PATH = '/customer'; -export const CUSTOMER_ORDER_DETAILS_PATH = `${CUSTOMER_PATH}/order-details`; +export const CUSTOMER_ORDER_DETAILS_PATH = `${CUSTOMER_PATH}${ORDER_DETAILS_PATH}`; +export const CUSTOMER_RETURN_DETAILS_PATH = `${CUSTOMER_PATH}${RETURN_DETAILS_PATH}`; export const CUSTOMER_ORDERS_PATH = `${CUSTOMER_PATH}/orders`; +export const CUSTOMER_RETURNS_PATH = `${CUSTOMER_PATH}/returns`; export const CUSTOMER_ADDRESS_PATH = `${CUSTOMER_PATH}/address`; export const CUSTOMER_LOGIN_PATH = `${CUSTOMER_PATH}/login`; export const CUSTOMER_ACCOUNT_PATH = `${CUSTOMER_PATH}/account`; diff --git a/scripts/initializers/order.js b/scripts/initializers/order.js index 0b64e87dcb..52981a19c4 100644 --- a/scripts/initializers/order.js +++ b/scripts/initializers/order.js @@ -7,8 +7,10 @@ import { fetchPlaceholders } from '../aem.js'; import { CUSTOMER_ORDER_DETAILS_PATH, - CUSTOMER_ORDERS_PATH, ORDER_DETAILS_PATH, + CUSTOMER_RETURN_DETAILS_PATH, + RETURN_DETAILS_PATH, + CUSTOMER_ORDERS_PATH, ORDER_STATUS_PATH, CUSTOMER_PATH, } from '../constants.js'; @@ -17,15 +19,25 @@ initializeDropin(async () => { const { pathname, searchParams } = new URL(window.location.href); const isAccountPage = pathname.includes(CUSTOMER_PATH); const orderRef = searchParams.get('orderRef'); + const returnRef = searchParams.get('returnRef'); const isTokenProvided = orderRef && orderRef.length > 20; // Handle redirects for user details pages - if (pathname === ORDER_DETAILS_PATH || pathname === CUSTOMER_ORDER_DETAILS_PATH) { - await handleUserOrdersRedirects(pathname, isAccountPage, orderRef, isTokenProvided); + if (pathname === ORDER_DETAILS_PATH + || pathname === CUSTOMER_ORDER_DETAILS_PATH + || pathname === RETURN_DETAILS_PATH + || pathname === CUSTOMER_RETURN_DETAILS_PATH) { + await handleUserOrdersRedirects(pathname, isAccountPage, orderRef, returnRef, isTokenProvided); } })(); -async function handleUserOrdersRedirects(pathname, isAccountPage, orderRef, isTokenProvided) { +async function handleUserOrdersRedirects( + pathname, + isAccountPage, + orderRef, + returnRef, + isTokenProvided, +) { const labels = await fetchPlaceholders(); const langDefinitions = { @@ -71,6 +83,7 @@ async function handleUserOrdersRedirects(pathname, isAccountPage, orderRef, isTo await initializers.mountImmediately(initialize, { langDefinitions, orderRef, + returnRef, }); } }