diff --git a/blocks/commerce-checkout/commerce-checkout.js b/blocks/commerce-checkout/commerce-checkout.js index a30347c86a..de1bafe8df 100644 --- a/blocks/commerce-checkout/commerce-checkout.js +++ b/blocks/commerce-checkout/commerce-checkout.js @@ -30,9 +30,9 @@ import { render as AccountProvider } from '@dropins/storefront-account/render.js // Cart Dropin import * as cartApi from '@dropins/storefront-cart/api.js'; import CartSummaryList from '@dropins/storefront-cart/containers/CartSummaryList.js'; +import Coupons from '@dropins/storefront-cart/containers/Coupons.js'; import EmptyCart from '@dropins/storefront-cart/containers/EmptyCart.js'; import OrderSummary from '@dropins/storefront-cart/containers/OrderSummary.js'; -import Coupons from '@dropins/storefront-cart/containers/Coupons.js'; import { render as CartProvider } from '@dropins/storefront-cart/render.js'; // Checkout Dropin @@ -41,7 +41,6 @@ import BillToShippingAddress from '@dropins/storefront-checkout/containers/BillT import EstimateShipping from '@dropins/storefront-checkout/containers/EstimateShipping.js'; import LoginForm from '@dropins/storefront-checkout/containers/LoginForm.js'; import MergedCartBanner from '@dropins/storefront-checkout/containers/MergedCartBanner.js'; -import OrderConfirmationHeader from '@dropins/storefront-checkout/containers/OrderConfirmationHeader.js'; import OutOfStock from '@dropins/storefront-checkout/containers/OutOfStock.js'; import PaymentMethods from '@dropins/storefront-checkout/containers/PaymentMethods.js'; import PlaceOrder from '@dropins/storefront-checkout/containers/PlaceOrder.js'; @@ -54,6 +53,7 @@ import { render as CheckoutProvider } from '@dropins/storefront-checkout/render. import * as orderApi from '@dropins/storefront-order/api.js'; import CustomerDetails from '@dropins/storefront-order/containers/CustomerDetails.js'; import OrderCostSummary from '@dropins/storefront-order/containers/OrderCostSummary.js'; +import OrderHeader from '@dropins/storefront-order/containers/OrderHeader.js'; import OrderProductList from '@dropins/storefront-order/containers/OrderProductList.js'; import OrderStatus from '@dropins/storefront-order/containers/OrderStatus.js'; import ShippingStatus from '@dropins/storefront-order/containers/ShippingStatus.js'; @@ -296,19 +296,17 @@ export default async function decorate(block) { if (!checked && billingFormRef?.current) { const { formData, isDataValid } = billingFormRef.current; - setAddressOnCart( - { data: formData, isDataValid }, - checkoutApi.setBillingAddress, - ); + setAddressOnCart({ + api: checkoutApi.setBillingAddress, + debounceMs: DEBOUNCE_TIME, + placeOrderBtn: placeOrder, + })({ data: formData, isDataValid }); } }, })($billToShipping), CheckoutProvider.render(ShippingMethods, { hideOnVirtualCart: true, - onCheckoutDataUpdate: () => { - cartApi.refreshCart().catch(console.error); - }, })($delivery), CheckoutProvider.render(PaymentMethods)($paymentMethods), @@ -409,17 +407,14 @@ export default async function decorate(block) { return success; }, - onPlaceOrder: async () => { + handlePlaceOrder: async ({ cartId }) => { await displayOverlaySpinner(); - try { - await checkoutApi.placeOrder(); - } catch (error) { - console.error(error); - throw error; - } finally { - await removeOverlaySpinner(); - } + orderApi.placeOrder(cartId) + .catch(console.error) + .finally(() => { + removeOverlaySpinner(); + }); }, })($placeOrder), ]); @@ -719,7 +714,7 @@ export default async function decorate(block) { block.replaceChildren(orderConfirmationFragment); - const onSignUpClick = async ({ inputsDefaultValueSet, addressesData }) => { + const handleSignUpClick = async ({ inputsDefaultValueSet, addressesData }) => { const signUpForm = document.createElement('div'); AuthProvider.render(SignUp, { routeSignIn: () => '/customer/login', @@ -731,9 +726,10 @@ export default async function decorate(block) { await showModal(signUpForm); }; - CheckoutProvider.render(OrderConfirmationHeader, { + OrderProvider.render(OrderHeader, { + handleEmailAvailability: checkoutApi.isEmailAvailable, + handleSignUpClick, orderData, - onSignUpClick, })($orderConfirmationHeader); OrderProvider.render(OrderStatus, { slots: { OrderActions: () => null } })( @@ -811,7 +807,7 @@ export default async function decorate(block) { removeModal(); }; - const handleCheckoutOrder = async (orderData) => { + const handleOrderPlaced = async (orderData) => { // Clear address form data sessionStorage.removeItem(SHIPPING_ADDRESS_DATA_KEY); sessionStorage.removeItem(BILLING_ADDRESS_DATA_KEY); @@ -834,6 +830,6 @@ export default async function decorate(block) { events.on('authenticated', handleAuthenticated); events.on('checkout/initialized', handleCheckoutInitialized, { eager: true }); - events.on('checkout/order', handleCheckoutOrder); events.on('checkout/updated', handleCheckoutUpdated); + events.on('order/placed', handleOrderPlaced); } diff --git a/package-lock.json b/package-lock.json index 95fcf2e483..672144dc47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ "@dropins/storefront-account": "1.0.0-beta3", "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "1.0.0-beta2", - "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "1.0.0-beta2", + "@dropins/storefront-checkout": "1.0.0-beta1", + "@dropins/storefront-order": "1.0.0-beta4", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.37.0" }, @@ -780,14 +780,14 @@ "integrity": "sha512-zB/CXZNQ9gazZJjTEgWbLPwxFvP+AzaM0Khk28gxWi67syJhwqHQTS+aTB84zFvZ2ARkPXg+nKrMPQl3rP3UyA==" }, "node_modules/@dropins/storefront-checkout": { - "version": "0.1.0-alpha61", - "resolved": "https://registry.npmjs.org/@dropins/storefront-checkout/-/storefront-checkout-0.1.0-alpha61.tgz", - "integrity": "sha512-w/6Me6NL1ImA8E3jSzazRihI6kLazVcOWTyXVycr0AgYz8Q2pBSCt9KlMzWZnFT9VsRuIn+wwMd8AsbQqQpetg==" + "version": "1.0.0-beta1", + "resolved": "https://registry.npmjs.org/@dropins/storefront-checkout/-/storefront-checkout-1.0.0-beta1.tgz", + "integrity": "sha512-pnPfRfhOtjjd+W+W3ftO7un+j9nJ8Rk29uaVo/rkB5ubF8FELIfexqzE+0PW48xRVPZhC8RkJyEGNKi/tNtUiA==" }, "node_modules/@dropins/storefront-order": { - "version": "1.0.0-beta2", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.0-beta2.tgz", - "integrity": "sha512-J1lvOdyMvxcIy0eQ9UFjI9Mriaw8YDgh8qp6WbuJwHrSFpqijmM3Z6kdNdNbkve8b/3BFTIwm9ZyePDSVB/Oeg==" + "version": "1.0.0-beta4", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.0-beta4.tgz", + "integrity": "sha512-ndtRT+QvE0KkHp0XO8xZSEL43VVDMSJC972PZk6IqrEbWK1YppDccHmGXBP73iKRknATKZgJcs9+lg488kIBnQ==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0-beta3", diff --git a/package.json b/package.json index 4d46a97f4e..9c83aa0509 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "@dropins/storefront-account": "1.0.0-beta3", "@dropins/storefront-auth": "1.0.0-beta2", "@dropins/storefront-cart": "1.0.0-beta2", - "@dropins/storefront-checkout": "0.1.0-alpha61", - "@dropins/storefront-order": "1.0.0-beta2", + "@dropins/storefront-checkout": "1.0.0-beta1", + "@dropins/storefront-order": "1.0.0-beta4", "@dropins/storefront-pdp": "1.0.0-beta3", "@dropins/tools": "^0.37.0" } diff --git a/scripts/__dropins__/storefront-checkout/api.js b/scripts/__dropins__/storefront-checkout/api.js index b33f821c9f..7d0063f0f2 100644 --- a/scripts/__dropins__/storefront-checkout/api.js +++ b/scripts/__dropins__/storefront-checkout/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{t as _,a as A,b as g}from"./chunks/synchronizeCheckout.js";import{d as Q,c as R,g as q,e as K,i as P,f as j,r as L,s as Y}from"./chunks/synchronizeCheckout.js";import{s as m,M as u,a as C,d as p,b as S}from"./chunks/fetch-graphql.js";import{D as V,F as W,I as X,f as Z,c as tt,e as st,S as et,U as it,j as at,k as rt,l as nt,r as ot,g as pt,h as dt,i as ct}from"./chunks/fetch-graphql.js";import{a as y,i as M}from"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import"@dropins/tools/lib.js";import{events as l}from"@dropins/tools/event-bus.js";import{i as gt}from"./chunks/isEmailAvailable.js";import{p as mt}from"./chunks/placeOrder2.js";import{a as I}from"./chunks/setBillingAddress.js";import{s as ft}from"./chunks/setBillingAddress.js";import{s as At}from"./chunks/setGuestEmailOnCart.js";import{s as St}from"./chunks/setPaymentMethod.js";import{CHECKOUT_DATA_FRAGMENT as T}from"./fragments.js";import{s as Mt}from"./chunks/setShippingMethods.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";const v=` +import{t as _,a as f,b as h}from"./chunks/synchronizeCheckout.js";import{d as k,c as z,g as Q,e as R,i as K,f as P,r as j,s as L}from"./chunks/synchronizeCheckout.js";import{s as l,M as m,a as A,d as p,b as C}from"./chunks/fetch-graphql.js";import{D as J,F as V,I as W,f as X,c as Z,e as tt,S as st,U as et,j as it,k as at,l as rt,r as nt,g as ot,h as pt,i as dt}from"./chunks/fetch-graphql.js";import{d as S,i as y}from"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{i as gt,s as ht}from"./chunks/setGuestEmailOnCart.js";import{a as M}from"./chunks/setBillingAddress.js";import{s as mt}from"./chunks/setBillingAddress.js";import{s as _t}from"./chunks/setPaymentMethod.js";import{CHECKOUT_DATA_FRAGMENT as I}from"./fragments.js";import{s as At}from"./chunks/setShippingMethods.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";const T=` mutation estimateShippingMethods( $cartId: String! $address: EstimateAddressInput! @@ -26,7 +26,7 @@ import{t as _,a as A,b as g}from"./chunks/synchronizeCheckout.js";import{d as Q, error_message } } -`,D=async r=>{var h;const e=m.cartId,{criteria:n}=r||{},{country_code:i,region_id:t,region_name:s,zip:o}=n||{},a=i||((h=y.value.data)==null?void 0:h.defaultCountry);if(!e)throw new u;if(!a)throw new C;const d=typeof t=="string"?parseInt(t,10):t,c=t||s?{...d&&{region_id:d},...s&&{region_code:s}}:void 0,f={country_code:a,...o&&{postcode:o},...c&&{region:c}};return await p({type:"mutation",query:v,options:{variables:{cartId:e,address:f}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:_})},E=` +`,N=async a=>{var g;const s=l.cartId,{criteria:r}=a||{},{country_code:e,region_id:t,region_name:i,zip:n}=r||{},o=e||((g=S.value.data)==null?void 0:g.defaultCountry);if(!s)throw new m;if(!o)throw new A;const d=typeof t=="string"?parseInt(t,10):t,c=t||i?{...d&&{region_id:d},...i&&{region_code:i}}:void 0,u={country_code:o,...n&&{postcode:n},...c&&{region:c}};return await p({type:"mutation",query:T,options:{variables:{cartId:s,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:_})},E=` mutation setShippingAddress($input: SetShippingAddressesOnCartInput!) { setShippingAddressesOnCart(input: $input) { cart { @@ -35,5 +35,5 @@ import{t as _,a as A,b as g}from"./chunks/synchronizeCheckout.js";import{d as Q, } } - ${T} -`,H=async({address:r,customerAddressId:e,pickupLocationCode:n})=>{const i=m.cartId;if(!i)throw new u;const t={cart_id:i,shipping_addresses:[]};if(e)t.shipping_addresses.push({customer_address_id:e});else if(n)t.shipping_addresses.push({pickup_location_code:n});else{if(!r)throw new S;t.shipping_addresses.push({address:A(r)})}const s=await p({type:"mutation",query:E,options:{variables:{input:t}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:g});if(!M.value)return l.emit("checkout/updated",s||null),s;const a=await p({type:"mutation",query:I,options:{variables:{input:{cart_id:i,billing_address:{same_as_shipping:!0}}}},path:"setBillingAddressOnCart.cart",signalType:"cart",transformer:g});return l.emit("checkout/updated",a||null),a};export{V as DEFAULT_COUNTRY,W as FetchError,X as InvalidArgument,Z as MissingBillingAddress,u as MissingCart,C as MissingCountry,tt as MissingEmail,st as MissingPaymentMethod,S as MissingShippinghAddress,et as STORE_CONFIG_DEFAULTS,it as UnexpectedError,Q as authenticateCustomer,R as config,D as estimateShippingMethods,at as fetchGraphQl,q as getCart,rt as getConfig,K as getCustomer,nt as getStoreConfig,P as initialize,j as initializeCheckout,gt as isEmailAvailable,mt as placeOrder,ot as removeFetchGraphQlHeader,L as resetCheckout,ft as setBillingAddress,pt as setEndpoint,dt as setFetchGraphQlHeader,ct as setFetchGraphQlHeaders,At as setGuestEmailOnCart,St as setPaymentMethod,H as setShippingAddress,Mt as setShippingMethodsOnCart,Y as synchronizeCheckout}; + ${I} +`,q=async({address:a,customerAddressId:s,pickupLocationCode:r})=>{const e=l.cartId;if(!e)throw new m;const t={cart_id:e,shipping_addresses:[]};if(s)t.shipping_addresses.push({customer_address_id:s});else if(r)t.shipping_addresses.push({pickup_location_code:r});else{if(!a)throw new C;t.shipping_addresses.push({address:f(a)})}const i=await p({type:"mutation",query:E,options:{variables:{input:t}},path:"setShippingAddressesOnCart.cart",queueName:"cartUpdate",signalType:"cart",transformer:h});return y.value?await p({type:"mutation",query:M,options:{variables:{input:{cart_id:e,billing_address:{same_as_shipping:!0}}}},path:"setBillingAddressOnCart.cart",queueName:"cartUpdate",signalType:"cart",transformer:h}):i};export{J as DEFAULT_COUNTRY,V as FetchError,W as InvalidArgument,X as MissingBillingAddress,m as MissingCart,A as MissingCountry,Z as MissingEmail,tt as MissingPaymentMethod,C as MissingShippinghAddress,st as STORE_CONFIG_DEFAULTS,et as UnexpectedError,k as authenticateCustomer,z as config,N as estimateShippingMethods,it as fetchGraphQl,Q as getCart,at as getConfig,R as getCustomer,rt as getStoreConfig,K as initialize,P as initializeCheckout,gt as isEmailAvailable,nt as removeFetchGraphQlHeader,j as resetCheckout,mt as setBillingAddress,ot as setEndpoint,pt as setFetchGraphQlHeader,dt as setFetchGraphQlHeaders,ht as setGuestEmailOnCart,_t as setPaymentMethod,q as setShippingAddress,At as setShippingMethodsOnCart,L as synchronizeCheckout}; diff --git a/scripts/__dropins__/storefront-checkout/api/fragments.d.ts b/scripts/__dropins__/storefront-checkout/api/fragments.d.ts index 12860eda2b..d992d36b96 100644 --- a/scripts/__dropins__/storefront-checkout/api/fragments.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/fragments.d.ts @@ -16,6 +16,4 @@ *******************************************************************/ export { CHECKOUT_DATA_FRAGMENT } from './graphql/CheckoutDataFragment.graphql'; export { CUSTOMER_FRAGMENT } from './graphql/CustomerFragment.graphql'; -export { ORDER_FRAGMENT } from './graphql/OrderFragment.graphql'; -export { ORDER_ITEM_FRAGMENT } from './graphql/OrderItemFragment.graphql'; //# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/graphql/OrderAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/graphql/OrderAddressFragment.graphql.d.ts deleted file mode 100644 index 19b23d6713..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/graphql/OrderAddressFragment.graphql.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************** - * ADOBE CONFIDENTIAL - * __________________ - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const ORDER_ADDRESS_FRAGMENT = "\n fragment ORDER_ADDRESS_FRAGMENT on OrderAddress {\n city\n company\n country_code\n fax\n firstname\n lastname\n middlename\n postcode\n prefix\n region\n region_id\n street\n suffix\n telephone\n vat_id\n custom_attributesV2 {\n code\n ... on AttributeValue {\n value\n }\n }\n }\n"; -//# sourceMappingURL=OrderAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts deleted file mode 100644 index d207dd7594..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************** - * ADOBE CONFIDENTIAL - * __________________ - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n title\n amount {\n currency\n value\n }\n rate\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; -export declare const ORDER_FRAGMENT: string; -//# sourceMappingURL=OrderFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/graphql/OrderItemFragment.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/graphql/OrderItemFragment.graphql.d.ts deleted file mode 100644 index 2c2543912d..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/graphql/OrderItemFragment.graphql.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export declare const PRODUCT_FRAGMENT = "\n fragment PRODUCT_FRAGMENT on ProductInterface {\n __typename\n canonical_url\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n image {\n url\n }\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n"; -export declare const PRICE_FRAGMENT = "\n fragment PRICE_FRAGMENT on OrderItemInterface {\n prices {\n price_including_tax {\n value\n currency\n }\n original_price {\n value\n currency\n }\n original_price_including_tax {\n value\n currency\n }\n price {\n value\n currency\n }\n }\n }\n"; -export declare const GIFT_CARD_FRAGMENT = "\n fragment GIFT_CARD_FRAGMENT on GiftCardOrderItem {\n ...PRICE_FRAGMENT\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n"; -export declare const ORDER_ITEM_FRAGMENT = "\n fragment ORDER_ITEM_FRAGMENT on OrderItemInterface {\n __typename\n status\n product_name\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_returned\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...PRODUCT_FRAGMENT\n }\n ...PRICE_FRAGMENT\n }\n"; -export declare const BUNDLE_ORDER_ITEM_FRAGMENT = "\n fragment BUNDLE_ORDER_ITEM_FRAGMENT on BundleOrderItem {\n ...PRICE_FRAGMENT\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n"; -//# sourceMappingURL=OrderItemFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/index.d.ts b/scripts/__dropins__/storefront-checkout/api/index.d.ts index a02994053f..903db33730 100644 --- a/scripts/__dropins__/storefront-checkout/api/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/index.d.ts @@ -24,7 +24,6 @@ export * from './getStoreConfig'; export * from './initialize'; export * from './initializeCheckout'; export * from './isEmailAvailable'; -export * from './placeOrder'; export * from './resetCheckout'; export * from './setBillingAddress'; export * from './setGuestEmailOnCart'; diff --git a/scripts/__dropins__/storefront-checkout/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-checkout/api/initialize/initialize.d.ts index 629f3b4124..27bec55bd5 100644 --- a/scripts/__dropins__/storefront-checkout/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/initialize/initialize.d.ts @@ -1,6 +1,6 @@ +import { Cart as CartModel, Customer as CustomerModel, OrderDataModel as OrderModel } from '../../data/models'; import { Lang } from '@dropins/tools/types/elsie/src/i18n'; import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib'; -import { Cart as CartModel, Customer as CustomerModel, Order as OrderModel } from '../../data/models'; export type ConfigProps = { langDefinitions?: Lang; diff --git a/scripts/__dropins__/storefront-checkout/api/placeOrder/fixtures.d.ts b/scripts/__dropins__/storefront-checkout/api/placeOrder/fixtures.d.ts deleted file mode 100644 index 312a4112e3..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/placeOrder/fixtures.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -export declare const customerOrder: (overrides?: Order) => Order; -export declare const customerOrderItem: (overrides?: Order) => Order; -export declare const customerOrderItemProduct: (overrides?: Order) => Order; -//# sourceMappingURL=fixtures.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/index.d.ts b/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/index.d.ts deleted file mode 100644 index 3cd80a35f2..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -export * from './placeOrder.graphql'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/placeOrder.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/placeOrder.graphql.d.ts deleted file mode 100644 index 8ab7ee3be4..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/placeOrder/graphql/placeOrder.graphql.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************** - * ADOBE CONFIDENTIAL - * __________________ - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const placeOrderMutation: string; -//# sourceMappingURL=placeOrder.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/placeOrder/index.d.ts b/scripts/__dropins__/storefront-checkout/api/placeOrder/index.d.ts deleted file mode 100644 index 53ee768186..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/placeOrder/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -export * from './placeOrder'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/placeOrder/placeOrder.d.ts b/scripts/__dropins__/storefront-checkout/api/placeOrder/placeOrder.d.ts deleted file mode 100644 index c15f61c993..0000000000 --- a/scripts/__dropins__/storefront-checkout/api/placeOrder/placeOrder.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************** - * ADOBE CONFIDENTIAL - * __________________ - * - * Copyright 2024 Adobe - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Adobe and its suppliers, if any. The intellectual - * and technical concepts contained herein are proprietary to Adobe - * and its suppliers and are protected by all applicable intellectual - * property laws, including trade secret and copyright laws. - * Dissemination of this information or reproduction of this material - * is strictly forbidden unless prior written permission is obtained - * from Adobe. - *******************************************************************/ -export declare const placeOrder: () => Promise; -//# sourceMappingURL=placeOrder.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/setShippingMethods/setShippingMethods.d.ts b/scripts/__dropins__/storefront-checkout/api/setShippingMethods/setShippingMethods.d.ts index e5a5e10a4e..633d7738d9 100644 --- a/scripts/__dropins__/storefront-checkout/api/setShippingMethods/setShippingMethods.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/setShippingMethods/setShippingMethods.d.ts @@ -1,18 +1,18 @@ /******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ + * ADOBE CONFIDENTIAL + * __________________ + * + * Copyright 2024 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + *******************************************************************/ export declare const setShippingMethodsOnCart: (shippingMethods: import('../../__generated__/types').InputMaybe[]) => Promise; //# sourceMappingURL=setShippingMethods.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/utils/dispatchApiCall.d.ts b/scripts/__dropins__/storefront-checkout/api/utils/dispatchApiCall.d.ts index 43e39210b9..bfeb150b10 100644 --- a/scripts/__dropins__/storefront-checkout/api/utils/dispatchApiCall.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/utils/dispatchApiCall.d.ts @@ -1,4 +1,5 @@ import { FetchOptions } from '..'; +import { QueueNames } from './enqueueRequest'; declare const signalTypes: { cart: import('@preact/signals-core').Signal<{ @@ -24,13 +25,14 @@ type SignalDataMap = { [K in SignalTypesKeys]: SignalTypesType[K]['value']['data']; }; type DispatchApiCallParams = { - type: 'query' | 'mutation'; - query: string; + defaultValueOnFail?: SignalDataMap[T]; options?: FetchOptions; path: string; + query: string; + queueName?: QueueNames; signalType: T; transformer?: (data: any) => SignalDataMap[T]; - defaultValueOnFail?: SignalDataMap[T]; + type: 'query' | 'mutation'; }; export declare function getValueAtPath(obj: any, path: string): any; declare function dispatchApiCall(params: DispatchApiCallParams): Promise; diff --git a/scripts/__dropins__/storefront-checkout/api/utils/enqueueRequest.d.ts b/scripts/__dropins__/storefront-checkout/api/utils/enqueueRequest.d.ts index 02e461972d..dc91b3473d 100644 --- a/scripts/__dropins__/storefront-checkout/api/utils/enqueueRequest.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/utils/enqueueRequest.d.ts @@ -1,18 +1,26 @@ /******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -export declare function enqueueRequest(requestFn: () => Promise): Promise; + * ADOBE CONFIDENTIAL + * __________________ + * + * Copyright 2024 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + *******************************************************************/ +type Queue = { + requests: (() => Promise)[]; + onComplete?: () => void; +}; +export declare const queues: Record<'cartUpdate' | 'default', Queue>; +export type QueueNames = keyof typeof queues; +export declare function enqueueRequest(requestFn: () => Promise, queueName?: keyof typeof queues): Promise; +export declare function setQueueCompleteHandler(queueName: keyof typeof queues, handler: () => void): void; +export {}; //# sourceMappingURL=enqueueRequest.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js b/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js index a5275b07c6..cd44d62bbf 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js +++ b/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as S,d as T,e as A,a as v,T as i}from"./store-config.js";import"./ServerErrorSignal.js";import{events as G}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},V=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class a extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class j extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class B extends a{constructor(){super("Cart ID is required")}}class z extends a{constructor(){super("Email is required")}}class Y extends a{constructor(){super("Payment method code is required")}}class $ extends a{constructor(){super("Shipping address is required")}}class J extends a{constructor(){super("Billing address is required")}}class K extends a{constructor(){super("Country Code is required")}}const p=[];function D(e){return new Promise((t,s)=>{p.push(e);const r=()=>{p[0]===e?e().then(t).catch(s).finally(()=>p.shift()):setTimeout(r,100)};r()})}const k=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!k.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}const C=e=>{throw e instanceof DOMException&&e.name==="AbortError"||G.emit("error",{source:"checkout",type:"network",error:e}),e},M={cart:S,customer:T,estimateShippingMethods:A,storeConfig:v};function U(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}const E={cart:null,customer:null,estimateShippingMethods:null,storeConfig:null};async function q(e){const{defaultValueOnFail:t,query:s,options:r,path:c,signalType:d,type:y,transformer:h}=e,n=M[d],g=Symbol();E[d]=g,n.value={...n.value,pending:!0};try{const{data:l,errors:f}=await(y==="mutation"?D(()=>_(s,r).catch(C)):_(s,{method:"GET",cache:"no-cache",...r}).catch(C));if(f){const m=I(f);if(m.length>0)throw new w(m)}let o=U(l,c);if(o===void 0)throw new Error(`No data found at path: ${c}`);return h&&(o=h(o)),n.value={...n.value,data:o},setTimeout(()=>{n.value={...n.value,pending:E[d]===g?!1:n.value.pending}},0),o}catch(l){if(t)return n.value={pending:!1,data:t},t;if(l.name==="AbortError")return;throw n.value={...n.value,pending:!1},l}}const N=` +import{c as T,b as q,e as b,d as v,T as l}from"./store-config.js";import"./ServerErrorSignal.js";import{events as A}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as G}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},j=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class D extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class i extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class B extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class z extends i{constructor(){super("Cart ID is required")}}class Y extends i{constructor(){super("Email is required")}}class $ extends i{constructor(){super("Payment method code is required")}}class J extends i{constructor(){super("Shipping address is required")}}class K extends i{constructor(){super("Billing address is required")}}class W extends i{constructor(){super("Country Code is required")}}const y={cartUpdate:{requests:[]},default:{requests:[]}};function k(e,t="default"){const s=y[t];return new Promise((r,a)=>{s.requests.push(e);const u=()=>{s.requests[0]===e?e().then(r).catch(a).finally(()=>{var o;s.requests.shift(),s.requests.length===0?(o=s.onComplete)==null||o.call(s):u()}):setTimeout(u,100)};u()})}function Z(e,t){const s=y[e];s.onComplete=t}const w=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!w.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}const C=e=>{throw e instanceof DOMException&&e.name==="AbortError"||A.emit("error",{source:"checkout",type:"network",error:e}),e},U={cart:T,customer:q,estimateShippingMethods:b,storeConfig:v};function M(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}const E={cart:null,customer:null,estimateShippingMethods:null,storeConfig:null};async function N(e){const{defaultValueOnFail:t,options:s,path:r,query:a,queueName:u,signalType:o,transformer:h,type:S}=e,n=U[o],g=Symbol();E[o]=g,n.value={...n.value,pending:!0};try{const{data:p,errors:f}=await(S==="mutation"?k(()=>_(a,s).catch(C),u):_(a,{method:"GET",cache:"no-cache",...s}).catch(C));if(f){const m=I(f);if(m.length>0)throw new D(m)}let c=M(p,r);if(c===void 0)throw new Error(`No data found at path: ${r}`);return h&&(c=h(c)),n.value={...n.value,data:c},setTimeout(()=>{n.value={...n.value,pending:E[o]===g?!1:n.value.pending}},0),c}catch(p){if(t)return n.value={pending:!1,data:t},t;if(p.name==="AbortError")return;throw n.value={...n.value,pending:!1},p}}const F=` query getStoreConfig { storeConfig { default_country @@ -9,4 +9,4 @@ import{c as S,d as T,e as A,a as v,T as i}from"./store-config.js";import"./Serve shopping_cart_display_shipping } } -`,F="US",u={defaultCountry:F,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:i.EXCLUDING_TAX}},W=async()=>await q({type:"query",query:N,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:O,defaultValueOnFail:u});function L(e){switch(e){case 1:return i.EXCLUDING_TAX;case 2:return i.INCLUDING_TAX;case 3:return i.INCLUDING_EXCLUDING_TAX;default:return i.EXCLUDING_TAX}}function O(e){if(!e)return u;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:c}=e;return{defaultCountry:t||u.defaultCountry,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||u.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:L(c)}}}const{setEndpoint:Z,setFetchGraphQlHeader:ee,removeFetchGraphQlHeader:te,setFetchGraphQlHeaders:se,fetchGraphQl:_,getConfig:re}=new b().getMethods();export{F as D,w as F,a as I,B as M,u as S,j as U,K as a,$ as b,z as c,q as d,Y as e,J as f,Z as g,ee as h,se as i,_ as j,re as k,W as l,C as m,te as r,V as s}; +`,L="US",d={defaultCountry:L,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:l.EXCLUDING_TAX}},ee=async()=>await N({type:"query",query:F,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:P,defaultValueOnFail:d});function O(e){switch(e){case 1:return l.EXCLUDING_TAX;case 2:return l.INCLUDING_TAX;case 3:return l.INCLUDING_EXCLUDING_TAX;default:return l.EXCLUDING_TAX}}function P(e){if(!e)return d;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:a}=e;return{defaultCountry:t||d.defaultCountry,isGuestCheckoutEnabled:s||d.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||d.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:O(a)}}}const{setEndpoint:te,setFetchGraphQlHeader:se,removeFetchGraphQlHeader:re,setFetchGraphQlHeaders:ne,fetchGraphQl:_,getConfig:ae}=new G().getMethods();export{L as D,D as F,i as I,z as M,d as S,B as U,W as a,J as b,Y as c,N as d,$ as e,K as f,te as g,se as h,ne as i,_ as j,ae as k,ee as l,C as m,Z as n,re as r,j as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/isEmailAvailable.js b/scripts/__dropins__/storefront-checkout/chunks/isEmailAvailable.js deleted file mode 100644 index 2b309924e9..0000000000 --- a/scripts/__dropins__/storefront-checkout/chunks/isEmailAvailable.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{c as e,j as r,m as o}from"./fetch-graphql.js";import"./store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const s=i=>!!(i!=null&&i.is_email_available),t=` - query isEmailAvailable($email: String!) { - isEmailAvailable(email: $email) { - is_email_available - } - } -`,m=i=>{if(!(!i||i.length===0))throw Error(i.map(a=>a.message).join(" "))},v=async i=>{if(!i)throw new e;const{data:a,errors:l}=await r(t,{method:"GET",cache:"no-cache",variables:{email:i}}).catch(o);return l&&m(l),s(a.isEmailAvailable)};export{v as i}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/placeOrder2.js b/scripts/__dropins__/storefront-checkout/chunks/placeOrder2.js deleted file mode 100644 index dbb21439db..0000000000 --- a/scripts/__dropins__/storefront-checkout/chunks/placeOrder2.js +++ /dev/null @@ -1,17 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{s as P,M as F,j as G,m as k,F as $,U as Q}from"./fetch-graphql.js";import{ORDER_FRAGMENT as X}from"../fragments.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as S}from"@dropins/tools/event-bus.js";import{merge as B}from"@dropins/tools/lib.js";import{c as H}from"./synchronizeCheckout.js";const K=e=>({id:P.cartId,totalQuantity:e.totalQuantity,possibleOnepageCheckout:!0,items:e.items.map(n=>{var a;return{canApplyMsrp:!0,formattedPrice:"",id:n.id,quantity:n.totalQuantity,product:{canonicalUrl:n.product.canonicalUrl||"",mainImageUrl:n.product.image||"",name:n.product.name,productId:0,productType:n.product.productType,sku:n.product.sku},prices:{price:{value:n.price.value,currency:n.price.currency}},configurableOptions:((a=n.selectedOptions)==null?void 0:a.map(t=>({optionLabel:t.label,valueLabel:t.value})))||[]}})}),V=e=>{var t,i,s;const n=e.coupons[0],a=(t=e.payments)==null?void 0:t[0];return{appliedCouponCode:(n==null?void 0:n.code)||"",email:e.email,grandTotal:e.total,orderId:e.number,orderType:"checkout",otherTax:0,salesTax:e.totalTax,shipping:{shippingMethod:((i=e.shipping)==null?void 0:i.code)||"",shippingAmount:((s=e.shipping)==null?void 0:s.amount)||0},subtotalExcludingTax:e.subtotal,subtotalIncludingTax:0,payments:a?[{paymentMethodCode:(a==null?void 0:a.code)||"",paymentMethodName:(a==null?void 0:a.name)||"",total:e.total}]:[]}},z=e=>e.replace(/_([a-z])/g,(n,a)=>a.toUpperCase()),b=(e,n,a)=>{const t=["string","boolean","number"],i=z;return Array.isArray(e)?e.map(s=>t.includes(typeof s)||s===null?s:typeof s=="object"?b(s,n,a):s):e!==null&&typeof e=="object"?Object.entries(e).reduce((s,[r,c])=>{const u=a&&a[r]?a[r]:i(r);return s[u]=t.includes(typeof c)||c===null?c:b(c,n,a),s},{}):e},J=e=>e||0,W=e=>{var n,a,t;return{...e,canonicalUrl:(e==null?void 0:e.canonical_url)||"",id:(e==null?void 0:e.uid)||"",name:(e==null?void 0:e.name)||"",sku:(e==null?void 0:e.sku)||"",image:((n=e==null?void 0:e.image)==null?void 0:n.url)||"",productType:(e==null?void 0:e.__typename)||"",thumbnail:{label:((a=e==null?void 0:e.thumbnail)==null?void 0:a.label)||"",url:((t=e==null?void 0:e.thumbnail)==null?void 0:t.url)||""}}},Y=e=>{if(!e||!("selected_options"in e))return;const n={};for(const a of e.selected_options)n[a.label]=a.value;return n},Z=e=>{const n=e==null?void 0:e.map(t=>({uid:t.uid,label:t.label,values:t.values.map(i=>i.product_name).join(", ")})),a={};return n==null||n.forEach(t=>{a[t.label]=t.values}),Object.keys(a).length>0?a:null},I=e=>(e==null?void 0:e.length)>0?{count:e.length,result:e.map(n=>n.title).join(", ")}:null,ee=e=>e==null?void 0:e.filter(n=>typeof n.__typename<"u").map(n=>{var a,t,i,s,r,c,u,p,_,y,f,g,l,m,h,o,d,O,C,v,E,T,x,w,q,N,R,L,A,M;return{type:n.__typename,productName:n.product_name,quantityCanceled:n.quantity_canceled||0,quantityInvoiced:n.quantity_invoiced||0,quantityOrdered:n.quantity_ordered||0,quantityRefunded:n.quantity_refunded||0,quantityReturned:n.quantity_returned||0,quantityShipped:n.quantity_shipped||0,id:n.id,discounted:((s=(i=(t=(a=n.product)==null?void 0:a.price_range)==null?void 0:t.maximum_price)==null?void 0:i.regular_price)==null?void 0:s.value)*n.quantity_ordered!==((r=n.product_sale_price)==null?void 0:r.value)*n.quantity_ordered,total:{value:((c=n.product_sale_price)==null?void 0:c.value)*n.quantity_ordered||0,currency:((u=n.product_sale_price)==null?void 0:u.currency)||""},totalInclTax:{value:((p=n.product_sale_price)==null?void 0:p.value)*n.quantity_ordered||0,currency:(_=n.product_sale_price)==null?void 0:_.currency},price:{value:((y=n.product_sale_price)==null?void 0:y.value)||0,currency:(f=n.product_sale_price)==null?void 0:f.currency},priceInclTax:{value:((g=n.product_sale_price)==null?void 0:g.value)||0,currency:(l=n.product_sale_price)==null?void 0:l.currency},totalQuantity:J(n.quantity_ordered),regularPrice:{value:(d=(o=(h=(m=n.product)==null?void 0:m.price_range)==null?void 0:h.maximum_price)==null?void 0:o.regular_price)==null?void 0:d.value,currency:(E=(v=(C=(O=n.product)==null?void 0:O.price_range)==null?void 0:C.maximum_price)==null?void 0:v.regular_price)==null?void 0:E.currency},product:W(n.product),thumbnail:{label:((x=(T=n.product)==null?void 0:T.thumbnail)==null?void 0:x.label)||"",url:((q=(w=n.product)==null?void 0:w.thumbnail)==null?void 0:q.url)||""},giftCard:n.__typename==="GiftCardOrderItem"?{senderName:((N=n.gift_card)==null?void 0:N.sender_name)||"",senderEmail:((R=n.gift_card)==null?void 0:R.sender_email)||"",recipientEmail:((L=n.gift_card)==null?void 0:L.recipient_email)||"",recipientName:((A=n.gift_card)==null?void 0:A.recipient_name)||"",message:((M=n.gift_card)==null?void 0:M.message)||""}:void 0,configurableOptions:Y(n),bundleOptions:n.__typename==="BundleOrderItem"?Z(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?I(n.downloadable_links):null}}),ne=e=>{var p,_,y,f,g,l,m;const n=ee(e.items),{total:a,...t}=b({...e,items:n},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),i=(p=e==null?void 0:e.payment_methods)==null?void 0:p[0],s=(i==null?void 0:i.type)||"",r=(i==null?void 0:i.name)||"",c=(_=t==null?void 0:t.items)==null?void 0:_.reduce((h,o)=>h+(o==null?void 0:o.totalQuantity),0),u={...a,...t,totalQuantity:c,shipping:{amount:((y=a==null?void 0:a.totalShipping)==null?void 0:y.value)??0,currency:((f=a==null?void 0:a.totalShipping)==null?void 0:f.currency)||"",code:t.shippingMethod??""},payments:[{code:s,name:r}]};return B(u,(m=(l=(g=H.getConfig().models)==null?void 0:g.OrderModel)==null?void 0:l.transformer)==null?void 0:m.call(l,e))},ae=` - mutation placeOrder($cartId: String!) { - placeOrder(input: { cart_id: $cartId }) { - errors { - code - message - } - orderV2 { - ...ORDER_FRAGMENT - } - } - } - - ${X} -`,j={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},te={PLACE_ORDER:"place-order"};function U(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function D(e,n){const a=U();a.push({[e]:null}),a.push({[e]:n})}function ie(e,n){U().push(t=>{const i=t.getState?t.getState():{};t.push({event:e,eventInfo:{...i,...n}})})}function se(e){const n=K(e),a=V(e);D(j.SHOPPING_CART_CONTEXT,{...n}),D(j.ORDER_CONTEXT,{...a}),ie(te.PLACE_ORDER)}function ce(e){throw e.every(a=>{var t;return(t=a.extensions)==null?void 0:t.category})?new $(e):new Q(e[0].message)}function re(e){const n=e.map(a=>a==null?void 0:a.message).join(", ");throw new Q(`${n}`)}const ge=async()=>{var i,s;const e=P.cartId;if(!e)throw new F;const{data:n,errors:a}=await G(ae,{variables:{cartId:e}}).catch(k);a&&ce(a),(i=n.placeOrder)!=null&&i.errors&&n.placeOrder.errors.length>0&&re((s=n.placeOrder)==null?void 0:s.errors);const t=ne(n.placeOrder.orderV2);return se(t),S.emit("checkout/order",t),S.emit("cart/reset",void 0),t};export{ge as p}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/setBillingAddress.js b/scripts/__dropins__/storefront-checkout/chunks/setBillingAddress.js index c2ba9e565f..db54752e7a 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/setBillingAddress.js +++ b/scripts/__dropins__/storefront-checkout/chunks/setBillingAddress.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as o,M as d,f as l,d as p}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as u}from"../fragments.js";import{a as c,b as f}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as m}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const _=` +import{s as e,M as d,f as o,d as l}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as p}from"../fragments.js";import{a as u,b as c}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const f=` mutation setBillingAddress($input: SetBillingAddressOnCartInput!) { setBillingAddressOnCart(input: $input) { cart { @@ -9,5 +9,5 @@ import{s as o,M as d,f as l,d as p}from"./fetch-graphql.js";import{CHECKOUT_DATA } } - ${u} -`,b=async({address:a,customerAddressId:t,sameAsShipping:s=!1,useForShipping:e=!1})=>{const r=o.cartId;if(!r)throw new d;const i={cart_id:r,billing_address:{same_as_shipping:s,use_for_shipping:e}};if(!s&&t&&(i.billing_address.customer_address_id=t),!s&&!t){if(!a)throw new l;i.billing_address.address=c(a)}const n=await p({type:"mutation",query:_,options:{variables:{input:i}},path:"setBillingAddressOnCart.cart",signalType:"cart",transformer:f});return m.emit("checkout/updated",n||null),n};export{_ as a,b as s}; + ${p} +`,h=async({address:i,customerAddressId:t,sameAsShipping:s=!1,useForShipping:n=!1})=>{const r=e.cartId;if(!r)throw new d;const a={cart_id:r,billing_address:{same_as_shipping:s,use_for_shipping:n}};if(!s&&t&&(a.billing_address.customer_address_id=t),!s&&!t){if(!i)throw new o;a.billing_address.address=u(i)}return await l({options:{variables:{input:a}},path:"setBillingAddressOnCart.cart",query:f,queueName:"cartUpdate",signalType:"cart",transformer:c,type:"mutation"})};export{f as a,h as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/setGuestEmailOnCart.js b/scripts/__dropins__/storefront-checkout/chunks/setGuestEmailOnCart.js index 331282e5e6..c251eb674c 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/setGuestEmailOnCart.js +++ b/scripts/__dropins__/storefront-checkout/chunks/setGuestEmailOnCart.js @@ -1,6 +1,12 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as i,M as s,d as e}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as o}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as n}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const c=` +import{c as e,j as r,m as s,s as l,M as o,d as n}from"./fetch-graphql.js";import"./store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as m}from"../fragments.js";import{b as c}from"./synchronizeCheckout.js";const u=a=>!!(a!=null&&a.is_email_available),p=` + query isEmailAvailable($email: String!) { + isEmailAvailable(email: $email) { + is_email_available + } + } +`,E=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},_=async a=>{if(!a)throw new e;const{data:t,errors:i}=await r(p,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(s);return i&&E(i),u(t.isEmailAvailable)},h=` mutation setGuestEmail($cartId: String!, $email: String!) { setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) { cart { @@ -9,5 +15,5 @@ import{s as i,M as s,d as e}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGME } } - ${o} -`,A=async r=>{const t=i.cartId;if(!t)throw new s;const a=await e({type:"mutation",query:c,options:{variables:{cartId:t,email:r}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:m});return n.emit("checkout/updated",a||null),a};export{A as s}; + ${m} +`,g=async a=>{const t=l.cartId;if(!t)throw new o;return await n({options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",query:h,queueName:"cartUpdate",signalType:"cart",transformer:c,type:"mutation"})};export{_ as i,g as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js b/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js index 0fa5c83e46..6467bc1a1e 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js +++ b/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as o,M as r,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as i}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const p=` +import{s as e,M as r,e as o,d as n}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as s}from"../fragments.js";import{b as i}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const m=` mutation setPaymentMethod( $cartId: String! $paymentMethod: PaymentMethodInput! @@ -14,5 +14,5 @@ import{s as o,M as r,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA } } - ${i} -`,A=async t=>{const a=o.cartId;if(!a)throw new r;if(!t)throw new n;const e=await s({type:"mutation",query:p,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("checkout/updated",e||null),e};export{A as s}; + ${s} +`,f=async t=>{const a=e.cartId;if(!a)throw new r;if(!t)throw new o;return await n({options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",query:m,queueName:"cartUpdate",signalType:"cart",transformer:i,type:"mutation"})};export{f as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/setShippingMethods.js b/scripts/__dropins__/storefront-checkout/chunks/setShippingMethods.js index af1877c83e..6c876afc0e 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/setShippingMethods.js +++ b/scripts/__dropins__/storefront-checkout/chunks/setShippingMethods.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as a,M as p,d as r}from"./fetch-graphql.js";import"./store-config.js";import"./ServerErrorSignal.js";import{b as o}from"./synchronizeCheckout.js";import"@dropins/tools/lib.js";import{events as n}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as e}from"../fragments.js";const h=` +import{s as i,M as p,d as s}from"./fetch-graphql.js";import"./store-config.js";import"./ServerErrorSignal.js";import{b as r}from"./synchronizeCheckout.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as o}from"../fragments.js";const e=` mutation setShippingMethods( $cartId: String! $shippingMethods: [ShippingMethodInput]! @@ -14,5 +14,5 @@ import{s as a,M as p,d as r}from"./fetch-graphql.js";import"./store-config.js";i } } - ${e} -`,f=async s=>{const t=a.cartId;if(!t)throw new p;const i=await r({type:"mutation",query:h,options:{variables:{cartId:t,shippingMethods:s}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:o});return n.emit("checkout/updated",i||null),i};export{f as s}; + ${o} +`,C=async a=>{const t=i.cartId;if(!t)throw new p;return await s({type:"mutation",query:e,queueName:"cartUpdate",options:{variables:{cartId:t,shippingMethods:a}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:r})};export{C as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/store-config.js b/scripts/__dropins__/storefront-checkout/chunks/store-config.js index c9eeae5f9a..bafbd3c79a 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/store-config.js +++ b/scripts/__dropins__/storefront-checkout/chunks/store-config.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{signal as e,effect as i}from"@dropins/tools/signals.js";const n=e(!0),t=e({pending:!1,data:void 0});i(()=>{var a;(a=t.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=e({pending:!1,data:void 0}),l=e({pending:!1,data:void 0}),g=e(),c=e(void 0),N=e({data:void 0,pending:!1});var s=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(s||{});export{s as T,N as a,g as b,t as c,d,l as e,n as i,c as s}; +import{signal as e,effect as i}from"@dropins/tools/signals.js";const n=e(!0),t=e({pending:!1,data:void 0});i(()=>{var a;(a=t.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=e({pending:!1,data:void 0}),l=e({pending:!1,data:void 0}),g=e(),c=e(void 0),N=e({data:void 0,pending:!1});var s=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(s||{});export{s as T,g as a,d as b,t as c,N as d,l as e,n as i,c as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js b/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js index 0359575e51..00e65766d8 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js +++ b/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{d as x,a as b,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as u,Initializer as M}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as a,CUSTOMER_FRAGMENT as T}from"../fragments.js";const S=async(e=!1)=>{i.authenticated=e,e?await K():x.value={pending:!1,data:null}},I=e=>e==null,N=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||I(e.amount.value)||!e.amount.currency),f=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),E=e=>{if(m(e))return f(e)},k=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(N)},w=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!w(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},R=e=>{const{code:t,label:r}=e;return{value:t,label:r}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),p=e=>{const t=e.street.filter(Boolean);return{id:(e==null?void 0:e.id)||void 0,city:e.city,company:e.company||void 0,country:R(e.country),customAttributes:G(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:z(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0,prefix:e.prefix||void 0,suffix:e.suffix||void 0,middleName:e.middlename||void 0,fax:e.fax||void 0}},O=e=>{if(e)return p(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...v}=t;return{...p(v),availableShippingMethods:k(r),selectedShippingMethod:E(n),sameAsBilling:o}}),ee=e=>({city:e.city,company:e.company,country_code:e.countryCode,custom_attributes:e.customAttributes.map(t=>({attribute_code:t.code,value:t.value})),firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook??!0,street:e.street,telephone:e.telephone,vat_id:e.vatId,prefix:e.prefix,suffix:e.suffix,middlename:e.middleName,fax:e.fax}),$=e=>{if(e)return{code:e.code,title:e.title}},B=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,o;if(!e)return;const t={availablePaymentMethods:B(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:$(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),isGuest:!i.authenticated};return u(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},F=e=>{var r,n,o;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return u(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},U=` +import{s as i,M as C,d as l,l as A,n as x}from"./fetch-graphql.js";import{b,d as M,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as o}from"@dropins/tools/event-bus.js";import{merge as u,Initializer as T}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as a,CUSTOMER_FRAGMENT as S}from"../fragments.js";const I=async(e=!1)=>{i.authenticated=e,e?await K():b.value={pending:!1,data:null}},N=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||N(e.amount.value)||!e.amount.currency),f=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),k=e=>{if(m(e))return f(e)},w=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(E)},z=e=>e?!!e.code&&!!e.label:!1,R=e=>{if(!z(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},q=e=>{const{code:t,label:r}=e;return{value:t,label:r}},P=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(P).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),d=e=>{const t=e.street.filter(Boolean);return{id:(e==null?void 0:e.id)||void 0,city:e.city,company:e.company||void 0,country:q(e.country),customAttributes:G(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:R(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0,prefix:e.prefix||void 0,suffix:e.suffix||void 0,middleName:e.middlename||void 0,fax:e.fax||void 0}},O=e=>{if(e)return d(e)},$=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:s,...v}=t;return{...d(v),availableShippingMethods:w(r),selectedShippingMethod:k(n),sameAsBilling:s}}),te=e=>({city:e.city,company:e.company,country_code:e.countryCode,custom_attributes:e.customAttributes.map(t=>({attribute_code:t.code,value:t.value})),firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook??!0,street:e.street,telephone:e.telephone,vat_id:e.vatId,prefix:e.prefix,suffix:e.suffix,middlename:e.middleName,fax:e.fax}),U=e=>{if(e)return{code:e.code,title:e.title}},B=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,s;if(!e)return;const t={availablePaymentMethods:B(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:U(e.selected_payment_method),shippingAddresses:$(e.shipping_addresses),isGuest:!i.authenticated};return u(t,(s=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:s.call(n,e))},F=e=>{var r,n,s;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return u(t,(s=(n=(r=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:s.call(n,e))},H=` query getCart($cartId: String!) { cart(cart_id: $cartId) { ...CHECKOUT_DATA_FRAGMENT @@ -8,7 +8,7 @@ import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{d as x,a as b } ${a} -`,V=` +`,Q=` query getCustomerCart { cart: customerCart { ...CHECKOUT_DATA_FRAGMENT @@ -16,12 +16,12 @@ import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{d as x,a as b } ${a} -`,d=async()=>{const e=i.cartId,t=i.authenticated===!1,r=t?U:V,n=t?{cartId:e}:{};if(t&&!e)throw new C;return await l({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",signalType:"cart",transformer:D})},H=` +`,p=async()=>{const e=i.cartId,t=i.authenticated===!1,r=t?H:Q,n=t?{cartId:e}:{};if(t&&!e)throw new C;return await l({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",signalType:"cart",transformer:D})},V=` query getCustomer { customer { ...CUSTOMER_FRAGMENT } } - ${T} -`,K=async()=>{if(i.authenticated)return await l({type:"query",query:H,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:F})},Q=()=>[s.on("authenticated",S,{eager:!0}),s.on("cart/initialized",h,{eager:!0}),s.on("cart/reset",L),s.on("cart/updated",y)],g=new M({init:async e=>{const t=e||{};g.config.setConfig(t),b.value.data||await A()},listeners:Q}),_=g.config,h=async e=>{if(i.initialized)return y(e);const t=e?e.id:null;i.cartId=t;const r=t?await d():null;c.value={pending:!1,data:r},i.initialized=!0,s.emit("checkout/initialized",r||null)},L=()=>{i.cartId=null,c.value={pending:!1,data:null},s.emit("checkout/updated",null)},y=async e=>{if(!i.initialized)return h(e);const t=e?e.id:null;i.cartId=t;const r=t?await d():null;c.value={pending:!1,data:r},s.emit("checkout/updated",r||null)};export{ee as a,D as b,_ as c,S as d,K as e,h as f,d as g,g as i,L as r,y as s,k as t}; + ${S} +`,K=async()=>{if(i.authenticated)return await l({type:"query",query:V,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:F})},L=()=>[o.on("authenticated",I,{eager:!0}),o.on("cart/initialized",h,{eager:!0}),o.on("cart/reset",j),o.on("cart/updated",y)],g=new T({init:async e=>{const t=e||{};g.config.setConfig(t);const{data:r,pending:n}=M.value;!r&&!n&&await A()},listeners:L}),_=g.config;x("cartUpdate",()=>{o.emit("checkout/updated",c.value.data)});const h=async e=>{if(i.initialized)return y(e);const t=e?e.id:null;i.cartId=t;const r=t?await p():null;c.value={pending:!1,data:r},i.initialized=!0,o.emit("checkout/initialized",r||null)},j=()=>{i.cartId=null,c.value={pending:!1,data:null},o.emit("checkout/updated",null)},y=async e=>{if(!i.initialized)return h(e);const t=e?e.id:null;i.cartId=t;const r=t?await p():null;c.value={pending:!1,data:r},o.emit("checkout/updated",r||null)};export{te as a,D as b,_ as c,I as d,K as e,h as f,p as g,g as i,j as r,y as s,w as t}; diff --git a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeader.d.ts b/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeader.d.ts deleted file mode 100644 index cc5572d864..0000000000 --- a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeader.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FunctionComponent } from 'preact'; - -export interface OrderConfirmationHeaderProps { - customerName?: string; - isLoading: boolean; - onSignUpClick?: () => void; - orderNumber?: string; -} -export declare const OrderConfirmationHeader: FunctionComponent; -//# sourceMappingURL=OrderConfirmationHeader.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeaderSkeleton.d.ts b/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeaderSkeleton.d.ts deleted file mode 100644 index 2af0811b57..0000000000 --- a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/OrderConfirmationHeaderSkeleton.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { FunctionComponent } from 'preact'; - -export declare const OrderConfirmationHeaderSkeleton: FunctionComponent; -//# sourceMappingURL=OrderConfirmationHeaderSkeleton.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/index.d.ts b/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/index.d.ts deleted file mode 100644 index ecd4b216d9..0000000000 --- a/scripts/__dropins__/storefront-checkout/components/OrderConfirmationHeader/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './OrderConfirmationHeader'; -export * from './OrderConfirmationHeaderSkeleton'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/components/index.d.ts b/scripts/__dropins__/storefront-checkout/components/index.d.ts index 1d47efa409..fd81759e16 100644 --- a/scripts/__dropins__/storefront-checkout/components/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/components/index.d.ts @@ -17,7 +17,6 @@ export * from './BillToShippingAddress'; export * from './EstimateShipping'; export * from './LoginForm'; -export * from './OrderConfirmationHeader'; export * from './OutOfStock'; export * from './PaymentMethods'; export * from './PlaceOrder'; diff --git a/scripts/__dropins__/storefront-checkout/containers/EstimateShipping.js b/scripts/__dropins__/storefront-checkout/containers/EstimateShipping.js index a81765621c..b708c2a9e5 100644 --- a/scripts/__dropins__/storefront-checkout/containers/EstimateShipping.js +++ b/scripts/__dropins__/storefront-checkout/containers/EstimateShipping.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsxs as k,Fragment as M,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as A,SkeletonRow as L,Price as g}from"@dropins/tools/components.js";/* empty css */import{VComponent as w,classes as I}from"@dropins/tools/lib.js";import{Text as l,useText as z}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{a as B,T as C}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as x}from"@dropins/tools/event-bus.js";import{useState as G,useEffect as f}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";const P=({estimated:e=!1,price:o,priceExclTax:d,taxExcluded:p=!1,taxIncluded:a=!1})=>k(M,{children:[t("span",{className:"checkout-estimate-shipping__label",children:e?t(l,{id:"Checkout.EstimateShipping.estimated"}):t(l,{id:"Checkout.EstimateShipping.label"})}),t(w,{node:o,className:"checkout-estimate-shipping__price"}),a&&t("span",{"data-testid":"shipping-tax-included",className:I(["checkout-estimate-shipping__caption"]),children:t(l,{id:"Checkout.EstimateShipping.withTaxes"})}),p&&k("span",{"data-testid":"shipping-tax-included-excluded",className:I(["checkout-estimate-shipping__caption"]),children:[d," ",t(l,{id:"Checkout.EstimateShipping.withoutTaxes"})]})]}),U=()=>t(A,{"data-testid":"estimate-shipping-skeleton",children:t(L,{size:"xsmall"})}),Z=()=>{const[e,o]=G(),d=e!==void 0,p=(e==null?void 0:e.amount.value)===0,{data:a,pending:_}=B.value,D=_||a===void 0,T=a==null?void 0:a.shoppingCartDisplaySetting.shipping,N=T===C.INCLUDING_EXCLUDING_TAX,E=T===C.INCLUDING_TAX,S=z({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined"});f(()=>{const i=x.on("shipping/estimate",n=>{const s=n.shippingMethod,{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!0,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=x.on("checkout/initialized",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=x.on("checkout/updated",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]);const v=()=>p?t("span",{"data-testId":"free-shipping",children:S.freeShipping}):E&&(e!=null&&e.amountInclTax)?t(g,{"data-testid":"shipping",amount:e.amountInclTax.value,currency:e.amountInclTax.currency}):t(g,{"data-testid":"shipping",amount:e==null?void 0:e.amount.value,currency:e==null?void 0:e.amount.currency}),y=()=>e!=null&&e.amountExclTax?t(g,{"data-testid":"shipping-excluding-tax",amount:e.amountExclTax.value,currency:e.amountExclTax.currency}):t("span",{children:S.taxToBeDetermined});return t("div",{"data-testid":"estimate-shipping",className:"checkout-estimate-shipping",children:!d||D?t(U,{}):t(P,{estimated:e.estimated,price:v(),taxExcluded:N&&!p,taxIncluded:E&&!p,priceExclTax:y()})})};export{Z as EstimateShipping,Z as default}; +import{jsxs as k,Fragment as M,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as A,SkeletonRow as L,Price as g}from"@dropins/tools/components.js";/* empty css */import{VComponent as w,classes as I}from"@dropins/tools/lib.js";import{Text as l,useText as z}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{d as B,T as C}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as x}from"@dropins/tools/event-bus.js";import{useState as G,useEffect as f}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";const P=({estimated:e=!1,price:a,priceExclTax:d,taxExcluded:p=!1,taxIncluded:o=!1})=>k(M,{children:[t("span",{className:"checkout-estimate-shipping__label",children:e?t(l,{id:"Checkout.EstimateShipping.estimated"}):t(l,{id:"Checkout.EstimateShipping.label"})}),t(w,{node:a,className:"checkout-estimate-shipping__price"}),o&&t("span",{"data-testid":"shipping-tax-included",className:I(["checkout-estimate-shipping__caption"]),children:t(l,{id:"Checkout.EstimateShipping.withTaxes"})}),p&&k("span",{"data-testid":"shipping-tax-included-excluded",className:I(["checkout-estimate-shipping__caption"]),children:[d," ",t(l,{id:"Checkout.EstimateShipping.withoutTaxes"})]})]}),U=()=>t(A,{"data-testid":"estimate-shipping-skeleton",children:t(L,{size:"xsmall"})}),Z=()=>{const[e,a]=G(),d=e!==void 0,p=(e==null?void 0:e.amount.value)===0,{data:o,pending:_}=B.value,D=_||o===void 0,T=o==null?void 0:o.shoppingCartDisplaySetting.shipping,N=T===C.INCLUDING_EXCLUDING_TAX,E=T===C.INCLUDING_TAX,S=z({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined"});f(()=>{const i=x.on("shipping/estimate",n=>{const s=n.shippingMethod,{amount:c,amountExclTax:r,amountInclTax:m}=s;a({estimated:!0,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=x.on("checkout/initialized",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;a({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=x.on("checkout/updated",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;a({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]);const v=()=>p?t("span",{"data-testId":"free-shipping",children:S.freeShipping}):E&&(e!=null&&e.amountInclTax)?t(g,{"data-testid":"shipping",amount:e.amountInclTax.value,currency:e.amountInclTax.currency}):t(g,{"data-testid":"shipping",amount:e==null?void 0:e.amount.value,currency:e==null?void 0:e.amount.currency}),y=()=>e!=null&&e.amountExclTax?t(g,{"data-testid":"shipping-excluding-tax",amount:e.amountExclTax.value,currency:e.amountExclTax.currency}):t("span",{children:S.taxToBeDetermined});return t("div",{"data-testid":"estimate-shipping",className:"checkout-estimate-shipping",children:!d||D?t(U,{}):t(P,{estimated:e.estimated,price:v(),taxExcluded:N&&!p,taxIncluded:E&&!p,priceExclTax:y()})})};export{Z as EstimateShipping,Z as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/LoginForm.js b/scripts/__dropins__/storefront-checkout/containers/LoginForm.js index f8c22680e4..504f37c6b7 100644 --- a/scripts/__dropins__/storefront-checkout/containers/LoginForm.js +++ b/scripts/__dropins__/storefront-checkout/containers/LoginForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,d as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as j}from"@dropins/tools/lib.js";import{i as q}from"../chunks/isEmailAvailable.js";import{s as D}from"../chunks/setGuestEmailOnCart.js";import{Field as W,Input as G,Skeleton as U,SkeletonRow as x}from"@dropins/tools/components.js";/* empty css *//* empty css */import{useText as b,Text as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{w as J}from"../chunks/withConditionalRendering.js";import{useState as v,useRef as K,useEffect as C}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const O=({value:t,error:i,hint:g,onChange:h,onBlur:o,onInvalid:u})=>{const m=b({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(W,{size:"medium",error:i,hint:g,children:r(G,{"aria-label":m.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:m.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",onBlur:o,onChange:h,onInvalid:u,placeholder:m.LoginFormPlaceholder,required:!0,type:"email",value:t})})},Q=({onClick:t})=>s("div",{className:"checkout-login-form__sign-in",children:[r(_,{id:"Checkout.LoginForm.account"}),r("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signIn"})})]}),X=({className:t,customerDetails:i,email:g,error:h,hint:o,loading:u=!1,name:m,onEmailBlur:f,onEmailChange:k,onEmailInvalid:E,onSignInClick:a,onSignOutClick:F,...L})=>{const l=b({Title:"Checkout.LoginForm.title"});return u?r(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[r("h2",{className:"checkout-login-form__title",children:l.Title}),i?r(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):r(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:i.email})]}):r("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[r("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),r(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[r(x,{variant:"heading",fullWidth:!0}),r(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[r(_,{id:"Checkout.LoginForm.switch"}),r("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signOut"})})]}),S={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},N=t=>S.EMAIL.test(t),rr=1e3,y=({onSignInClick:t,onSignOutClick:i,initialData:g,...h})=>{const[o,u]=v(""),[m,f]=v(""),[k,E]=v(!0),[a,F]=v(!0),L=K(""),l=R.value.data,d=(l==null?void 0:l.email)||"",p=V.value.data,c=b({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),A=e=>e.valid?"":e.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=e=>N(e)?"":e===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=e=>{const n=e.target;u(n.value),f(""),E(!0)},T=e=>{const n=e.target;f(B(n.value))},z=e=>{const n=e.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const e=setTimeout(()=>{!N(o)||o===L.current||(L.current=o,q(o).then(n=>{E(n),d!==o&&D(o).catch(console.error)}).catch(n=>{console.error(n),E(!0)}))},rr);return()=>{e&&clearTimeout(e)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",r("a",{href:"#",onClick:e=>{e.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=e=>{t==null||t(N(e)?e:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return r(X,{...h,customerDetails:P,email:o,error:m,hint:I,loading:a,onEmailBlur:T,onEmailChange:M,onEmailInvalid:z,onSignInClick:$,onSignOutClick:i})};y.displayName="LoginFormContainer";const kr=J(y);export{kr as LoginForm,kr as default}; +import{jsx as e,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,b as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as j}from"@dropins/tools/lib.js";import{i as q,s as D}from"../chunks/setGuestEmailOnCart.js";import{Field as W,Input as G,Skeleton as U,SkeletonRow as x}from"@dropins/tools/components.js";/* empty css *//* empty css */import{useText as b,Text as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{w as J}from"../chunks/withConditionalRendering.js";import{useState as v,useRef as K,useEffect as C}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const O=({value:t,error:i,hint:g,onChange:h,onBlur:o,onInvalid:u})=>{const m=b({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return e(W,{size:"medium",error:i,hint:g,children:e(G,{"aria-label":m.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:m.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",onBlur:o,onChange:h,onInvalid:u,placeholder:m.LoginFormPlaceholder,required:!0,type:"email",value:t})})},Q=({onClick:t})=>s("div",{className:"checkout-login-form__sign-in",children:[e(_,{id:"Checkout.LoginForm.account"}),e("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:e(_,{id:"Checkout.LoginForm.signIn"})})]}),X=({className:t,customerDetails:i,email:g,error:h,hint:o,loading:u=!1,name:m,onEmailBlur:f,onEmailChange:k,onEmailInvalid:E,onSignInClick:a,onSignOutClick:F,...L})=>{const l=b({Title:"Checkout.LoginForm.title"});return u?e(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[e("h2",{className:"checkout-login-form__title",children:l.Title}),i?e(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):e(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[e("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),e("div",{className:"checkout-login-form__customer-email",children:i.email})]}):e("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[e("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),e(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[e(x,{variant:"heading",fullWidth:!0}),e(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[e(_,{id:"Checkout.LoginForm.switch"}),e("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:e(_,{id:"Checkout.LoginForm.signOut"})})]}),S={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},N=t=>S.EMAIL.test(t),ee=1e3,y=({onSignInClick:t,onSignOutClick:i,initialData:g,...h})=>{const[o,u]=v(""),[m,f]=v(""),[k,E]=v(!0),[a,F]=v(!0),L=K(""),l=R.value.data,d=(l==null?void 0:l.email)||"",p=V.value.data,c=b({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),A=r=>r.valid?"":r.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=r=>N(r)?"":r===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=r=>{const n=r.target;u(n.value),f(""),E(!0)},T=r=>{const n=r.target;f(B(n.value))},z=r=>{const n=r.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const r=setTimeout(()=>{!N(o)||o===L.current||(L.current=o,q(o).then(n=>{E(n),d!==o&&D(o).catch(console.error)}).catch(n=>{console.error(n),E(!0)}))},ee);return()=>{r&&clearTimeout(r)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",e("a",{href:"#",onClick:r=>{r.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=r=>{t==null||t(N(r)?r:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return e(X,{...h,customerDetails:P,email:o,error:m,hint:I,loading:a,onEmailBlur:T,onEmailChange:M,onEmailInvalid:z,onSignInClick:$,onSignOutClick:i})};y.displayName="LoginFormContainer";const _e=J(y);export{_e as LoginForm,_e as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.d.ts b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.d.ts deleted file mode 100644 index 0db3082320..0000000000 --- a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './OrderConfirmationHeader/index' -import _default from './OrderConfirmationHeader/index' -export default _default diff --git a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js deleted file mode 100644 index 382cb09e48..0000000000 --- a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{jsx as e,jsxs as h}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Icon as A,Header as E,Button as y,Skeleton as N,SkeletonRow as r}from"@dropins/tools/components.js";/* empty css */import"@dropins/tools/lib.js";/* empty css *//* empty css *//* empty css */import*as o from"@dropins/tools/preact-compat.js";import{useState as s,useEffect as x}from"@dropins/tools/preact-compat.js";import{useText as b,Text as v}from"@dropins/tools/i18n.js";import{s as f}from"../chunks/fetch-graphql.js";import"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{i as z}from"../chunks/isEmailAvailable.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";function p(t){var c;return{region:{region_id:t!=null&&t.regionId?Number(t==null?void 0:t.regionId):null,region:t==null?void 0:t.region},city:t==null?void 0:t.city,company:t==null?void 0:t.company,country_code:t==null?void 0:t.country,firstname:t==null?void 0:t.firstName,lastname:t==null?void 0:t.lastName,middlename:t==null?void 0:t.middleName,postcode:t==null?void 0:t.postCode,street:t==null?void 0:t.street,telephone:t==null?void 0:t.telephone,custom_attributesV2:((c=t==null?void 0:t.customAttributes)==null?void 0:c.map(l=>({attribute_code:l.code,value:l.value})))||[],prefix:t==null?void 0:t.prefix,suffix:t==null?void 0:t.suffix,fax:t==null?void 0:t.fax}}const H=t=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},o.createElement("g",{clipPath:"url(#clip0_4797_15077)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.63001L10.15 3.20001L18.8 6.63001L10.15 10L1.5 6.63001Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M15.71 17.26C15.71 15.38 17.23 13.86 19.11 13.86C20.99 13.86 22.51 15.38 22.51 17.26C22.51 19.14 20.99 20.66 19.11 20.66C17.23 20.66 15.71 19.14 15.71 17.26Z",stroke:"currentColor"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M17.4805 17.49L18.5605 18.41L20.7205 16.33",stroke:"currentColor",strokeLinecap:"square",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_4797_15077"},o.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"})))),V=({customerName:t,isLoading:c,orderNumber:l,onSignUpClick:m})=>{const i=b({title:e(v,{id:"Checkout.OrderConfirmationHeader.title",fields:{name:t}}),defaultTitle:"Checkout.OrderConfirmationHeader.defaultTitle",order:e(v,{id:"Checkout.OrderConfirmationHeader.order",fields:{order:l}}),createAccountMessage:"Checkout.OrderConfirmationHeader.CreateAccount.message",createAccountButton:"Checkout.OrderConfirmationHeader.CreateAccount.button"});return c?e(w,{}):h("div",{className:"order-confirmation-header order-confirmation__card",children:[e(A,{source:H,size:"64",className:"order-confirmation-header__icon"}),e(E,{className:"order-confirmation-header__title",title:i.title,size:"large",divider:!1,children:t?i.title:i.defaultTitle}),l&&e("p",{className:"order-confirmation-header__order",children:i.order}),m&&h("div",{className:"order-confirmation-create-account",children:[e("p",{className:"order-confirmation-create-account__message",children:i.createAccountMessage}),e(y,{"data-testid":"create-account-button",className:"order-confirmation-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:m,children:i.createAccountButton})]})]})},w=()=>h(N,{"data-testid":"order-confirmation-header-skeleton",className:"order-confirmation-header",children:[e(r,{variant:"empty",size:"xlarge",fullWidth:!0}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"small",fullWidth:!0}),e(r,{variant:"heading",size:"xsmall",fullWidth:!0})]}),X=({orderData:t,onSignUpClick:c})=>{var k;const[l,m]=s(!f.authenticated),[i,g]=s();x(()=>{f.authenticated||z(t.email).then(a=>g(!a)).catch(()=>g(!0)).finally(()=>m(!1))},[t.email]);const _=c&&!f.authenticated&&i===!1?()=>{const a=t.shippingAddress,n=t.billingAddress,L=[{code:"firstname",defaultValue:(n==null?void 0:n.firstName)||""},{code:"lastname",defaultValue:(n==null?void 0:n.lastName)||""},{code:"email",defaultValue:t.email||""}];let u;if(a){const C={...p(a),default_shipping:!0};u=[{...p(n),default_billing:!0},C]}else u=[{...p(n),default_billing:!0,default_shipping:!0}];c({inputsDefaultValueSet:L,addressesData:u})}:void 0;return e("div",{children:e(V,{customerName:(k=t.billingAddress)==null?void 0:k.firstName,isLoading:l,onSignUpClick:_,orderNumber:t.number})})};export{X as OrderConfirmationHeader,X as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/OrderConfirmationHeader.d.ts b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/OrderConfirmationHeader.d.ts deleted file mode 100644 index 93751661b6..0000000000 --- a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/OrderConfirmationHeader.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { FunctionComponent } from 'preact'; -import { OrderDataModel } from '../../data/models'; -import { CustomerAddressInput } from '../../__generated__/types'; - -type SignUpInputsDefaultValueSetProps = { - code: string; - defaultValue: string; -}; -export type OrderConfirmationHeaderProps = { - onSignUpClick?: ({ inputsDefaultValueSet, addressesData, }: { - inputsDefaultValueSet: SignUpInputsDefaultValueSetProps[]; - addressesData: CustomerAddressInput[]; - }) => void; - orderData: OrderDataModel; -}; -export declare const OrderConfirmationHeader: FunctionComponent; -export {}; -//# sourceMappingURL=OrderConfirmationHeader.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/index.d.ts b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/index.d.ts deleted file mode 100644 index cf34192cb4..0000000000 --- a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './OrderConfirmationHeader'; -export { OrderConfirmationHeader as default } from './OrderConfirmationHeader'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js index be65f4442e..c0e4068009 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js +++ b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/fetch-graphql.js";import{c as H,b as y}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as S,Slot as T}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as U,Icon as Z,ProgressSpinner as F,ToggleButton as q,Skeleton as G,SkeletonRow as g}from"@dropins/tools/components.js";import*as k from"@dropins/tools/preact-compat.js";import{useState as w,useCallback as N,useEffect as b}from"@dropins/tools/preact-compat.js";import{useText as J}from"@dropins/tools/i18n.js";import{w as K}from"../chunks/withConditionalRendering.js";import{useRef as Q}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const X=e=>k.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},k.createElement("path",{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"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Y=({code:e,loading:r,selected:o,onChange:d,title:h})=>n(q,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:o,onChange:d,busy:r}),ee=({className:e,paymentMethodContent:r,loading:o=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:M})=>{const a=J({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(te,{}):v("div",{className:S(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:a.Title}),!o&&c.length===0&&n(U,{icon:n(Z,{source:X}),message:n("p",{children:a.EmptyState})}),v("div",{className:S(["checkout-payment-methods__wrapper"]),children:[o&&n(F,{className:"checkout-payment-methods__spinner"}),n("div",{className:S(["checkout-payment-methods__methods",["checkout-payment-methods--loading",o],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(Y,{code:i.code,onChange:h,selected:i.code===M,title:i.title},i.code))}),r&&n("div",{className:"checkout-payment-methods__content",children:r})]})]})},te=()=>v(G,{"data-testid":"payment-methods-skeleton",children:[n(g,{variant:"heading",size:"medium"}),n(g,{variant:"empty",size:"medium"}),n(g,{size:"xlarge",fullWidth:!0}),n(g,{size:"xlarge",fullWidth:!0})]}),V={free:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)},checkmo:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)}},ne=(e,r)=>{const o=Q(e);return r(o.current,e)||(o.current=e),o.current},W=({slots:e,setOnChange:r={}})=>{var _,L;const[o]=w(r),[d,h]=w(V),[c,M]=w(!0),a=H.value.data,i=!!H.value.data,O=H.value.pending,j=(a==null?void 0:a.isVirtual)??!1,z=(_=a==null?void 0:a.shippingAddresses)==null?void 0:_[0],A=(a==null?void 0:a.availablePaymentMethods)||[],m=(L=a==null?void 0:a.selectedPaymentMethod)==null?void 0:L.code,E=j?!0:!!z,l=ne(A,(t,s)=>t.length!==s.length?!1:t.every((p,C)=>p.code===s[C].code)),u=N(t=>{y.value=t,!(!t||!E)&&t!==m&&o[t]!==!1&&B({code:t}).catch(console.error)},[E,m,o]);b(()=>{if(!i)return;if(!!!(l!=null&&l.length)){u(void 0);return}const s=l[0].code;if(!m){u(s);return}const p=l.some(C=>C.code===m);u(p?m:s)},[l,i,m,u]);const I=t=>{u(t)},x=N((t,s)=>{if(!t){console.warn("Payment method handler is ignored because it has no code");return}if(!s){console.warn("Payment method handler is ignored because it is empty");return}h(p=>({...p,[t]:s}))},[]);b(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{x(t,s)})},[x,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(T,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),M(!1)}}}):null,P=y.value?d[y.value]:null,R=P?n(T,{name:"PaymentMethodContent",slot:P,context:{cartId:$.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return b(()=>{!c&&d!=V&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),v(D,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(ee,{initializing:i===!1,loading:i&&O,onChange:I,options:l,paymentMethodContent:R,selection:y.value})]})};W.displayName="PaymentMethodsContainer";const Me=K(W);export{Me as PaymentMethods,Me as default}; +import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/fetch-graphql.js";import{c as H,a as y}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as S,Slot as T}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as U,Icon as Z,ProgressSpinner as F,ToggleButton as q,Skeleton as G,SkeletonRow as g}from"@dropins/tools/components.js";import*as k from"@dropins/tools/preact-compat.js";import{useState as w,useCallback as N,useEffect as E}from"@dropins/tools/preact-compat.js";import{useText as J}from"@dropins/tools/i18n.js";import{w as K}from"../chunks/withConditionalRendering.js";import{useRef as Q}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const X=e=>k.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},k.createElement("path",{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"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Y=({code:e,loading:r,selected:o,onChange:d,title:h})=>n(q,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:o,onChange:d,busy:r}),ee=({className:e,paymentMethodContent:r,loading:o=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:M})=>{const a=J({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(te,{}):v("div",{className:S(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:a.Title}),!o&&c.length===0&&n(U,{icon:n(Z,{source:X}),message:n("p",{children:a.EmptyState})}),v("div",{className:S(["checkout-payment-methods__wrapper"]),children:[o&&n(F,{className:"checkout-payment-methods__spinner"}),n("div",{className:S(["checkout-payment-methods__methods",["checkout-payment-methods--loading",o],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(Y,{code:i.code,onChange:h,selected:i.code===M,title:i.title},i.code))}),r&&n("div",{className:"checkout-payment-methods__content",children:r})]})]})},te=()=>v(G,{"data-testid":"payment-methods-skeleton",children:[n(g,{variant:"heading",size:"medium"}),n(g,{variant:"empty",size:"medium"}),n(g,{size:"xlarge",fullWidth:!0}),n(g,{size:"xlarge",fullWidth:!0})]}),V={free:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)},checkmo:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)}},ne=(e,r)=>{const o=Q(e);return r(o.current,e)||(o.current=e),o.current},W=({slots:e,setOnChange:r={}})=>{var _,L;const[o]=w(r),[d,h]=w(V),[c,M]=w(!0),a=H.value.data,i=!!H.value.data,O=H.value.pending,j=(a==null?void 0:a.isVirtual)??!1,z=(_=a==null?void 0:a.shippingAddresses)==null?void 0:_[0],A=(a==null?void 0:a.availablePaymentMethods)||[],m=(L=a==null?void 0:a.selectedPaymentMethod)==null?void 0:L.code,b=j?!0:!!z,l=ne(A,(t,s)=>t.length!==s.length?!1:t.every((p,C)=>p.code===s[C].code)),u=N(t=>{y.value=t,!(!t||!b)&&t!==m&&o[t]!==!1&&B({code:t}).catch(console.error)},[b,m,o]);E(()=>{if(!i)return;if(!!!(l!=null&&l.length)){u(void 0);return}const s=l[0].code;if(!m){u(s);return}const p=l.some(C=>C.code===m);u(p?m:s)},[l,i,m,u]);const I=t=>{u(t)},x=N((t,s)=>{if(!t){console.warn("Payment method handler is ignored because it has no code");return}if(!s){console.warn("Payment method handler is ignored because it is empty");return}h(p=>({...p,[t]:s}))},[]);E(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{x(t,s)})},[x,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(T,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),M(!1)}}}):null,P=y.value?d[y.value]:null,R=P?n(T,{name:"PaymentMethodContent",slot:P,context:{cartId:$.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return E(()=>{!c&&d!=V&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),v(D,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(ee,{initializing:i===!1,loading:i&&O,onChange:I,options:l,paymentMethodContent:R,selection:y.value})]})};W.displayName="PaymentMethodsContainer";const Me=K(W);export{Me as PaymentMethods,Me as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js index 449034d296..151f12a449 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js +++ b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{U as x}from"../chunks/fetch-graphql.js";import{c as E,b as g}from"../chunks/store-config.js";import{s as v}from"../chunks/ServerErrorSignal.js";import{events as y}from"@dropins/tools/event-bus.js";import{classes as S}from"@dropins/tools/lib.js";import{p as b}from"../chunks/placeOrder2.js";/* empty css */import{Button as P}from"@dropins/tools/components.js";import{Text as U,useText as w}from"@dropins/tools/i18n.js";import{w as N}from"../chunks/withConditionalRendering.js";import{useState as T,useCallback as m,useEffect as z}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const D=r=>r instanceof TypeError||r instanceof x,H=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:S(["checkout-place-order",r]),children:a(P,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(U,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,onPlaceOrder:o,...p})=>{const[u,d]=T(!1),{data:f,pending:O}=E.value,h=!!f,c=w({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{v.value=D(e)?c.CheckoutUnexpectedError:e.message},[c]),k=m(async()=>{try{if(!(t?t():!0))return;o?await o({code:g.value||""}):await b()}catch(e){n(e)}},[t,o,n]);return z(()=>{const e=y.on("cart/initialized",s=>{const C=(s==null?void 0:s.items)||[];d(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(H,{...p,onClick:k,disabled:r||!h||O||u})};l.displayName="PlaceOrderContainer";const X=N(l);export{X as PlaceOrder,X as default}; +import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Button as x}from"@dropins/tools/components.js";import{classes as E}from"@dropins/tools/lib.js";import{Text as g,useText as v}from"@dropins/tools/i18n.js";import{w as y}from"../chunks/withConditionalRendering.js";import{U as P,s as S}from"../chunks/fetch-graphql.js";import{c as b,a as U}from"../chunks/store-config.js";import{s as I}from"../chunks/ServerErrorSignal.js";import{events as w}from"@dropins/tools/event-bus.js";import{useState as N,useCallback as m,useEffect as T}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";const z=r=>r instanceof TypeError||r instanceof P,D=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:E(["checkout-place-order",r]),children:a(x,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(g,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,handlePlaceOrder:o,...u})=>{const[d,p]=N(!1),{data:f,pending:O}=b.value,k=!!f,s=v({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{I.value=z(e)?s.CheckoutUnexpectedError:e.message},[s]),h=m(async()=>{try{if(!(t?t():!0))return;await o({cartId:S.cartId||"",code:U.value||""})}catch(e){n(e)}},[t,o,n]);return T(()=>{const e=w.on("cart/initialized",c=>{const C=(c==null?void 0:c.items)||[];p(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(D,{...u,onClick:h,disabled:r||!k||O||d})};l.displayName="PlaceOrderContainer";const J=y(l);export{J as PlaceOrder,J as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder/PlaceOrder.d.ts b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder/PlaceOrder.d.ts index 37d16c1ddd..49f8b9dde4 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder/PlaceOrder.d.ts +++ b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder/PlaceOrder.d.ts @@ -3,10 +3,11 @@ import { HTMLAttributes } from 'preact/compat'; export interface PlaceOrderProps extends HTMLAttributes { disabled?: boolean; handleValidation?: () => boolean; - onPlaceOrder?: (ctx: PlaceOrderContext) => Promise; + handlePlaceOrder: (ctx: PlaceOrderContext) => Promise; } export interface PlaceOrderContext { code: string; + cartId: string; } export declare const PlaceOrder: { ({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & PlaceOrderProps): import("preact/compat").JSX.Element; diff --git a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js index 976cddc010..0fd3a34d9d 100644 --- a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js +++ b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as o,jsxs as E,Fragment as I}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as k,e as M,c as x,a as B}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as N}from"@dropins/tools/event-bus.js";import{classes as j,Slot as V}from"@dropins/tools/lib.js";import{s as O}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as P,Icon as Z,ProgressSpinner as $,RadioButton as q,Price as F,Skeleton as G,SkeletonRow as S}from"@dropins/tools/components.js";import*as d from"@dropins/tools/preact-compat.js";import{useRef as J,useEffect as R,useCallback as K,useMemo as Q}from"@dropins/tools/preact-compat.js";import{useText as X}from"@dropins/tools/i18n.js";import{useState as T,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as Y}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const D=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),U=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ee=e=>d.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),te=({className:e,isLoading:t=!1,onSelectionChange:c=()=>{},options:i,selection:r,...a})=>{const s=X({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return i===void 0?o(ne,{}):E("div",{...a,className:j(["checkout-shipping-methods",e]),children:[o("h3",{className:"checkout-shipping-methods__title",children:s.Title}),!t&&i.length===0&&o(P,{icon:o(Z,{source:ee}),message:o("p",{children:s.EmptyState})}),E("div",{className:j(["checkout-shipping-methods__content"]),children:[t&&o($,{className:"checkout-shipping-methods__spinner"}),o("div",{className:j(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:i.map(n=>o(q,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:n.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:E(I,{children:[o(F,{amount:n.amount.value,currency:n.amount.currency})," ",o("span",{children:n.carrier.title})]}),description:n.title,value:n.value,checked:(r==null?void 0:r.value)===n.value,onChange:()=>c(n)},n.value))})]})]})},ne=()=>E(G,{"data-testid":"shipping-methods-skeleton",children:[o(S,{variant:"heading",size:"small"}),o(S,{variant:"empty",size:"small"}),o(S,{size:"medium",fullWidth:!0}),o(S,{size:"medium",fullWidth:!0})]});function oe(){var L;const[e,t]=T(),[c,i]=T();_(()=>{N.on("checkout/estimate-shipping-address",({address:f,isValid:p})=>{t({address:f,isValid:p})})},[]),_(()=>{i(k.value)},[k.value]),_(()=>{M.value.pending?i(void 0):i(k.value)},[M.value.pending]);const{country_id:r,region_id:a,region:s,postcode:n}=(e==null?void 0:e.address)||{},l=!!e,h=x.value.data,u=!!((L=h==null?void 0:h.shippingAddresses)!=null&&L[0]),v=e==null?void 0:e.isValid;_(()=>{u||v||!c||!l||N.emit("shipping/estimate",{address:D({country_id:r,region_id:a,region:s,postcode:n}),shippingMethod:U(c)})},[c,r,a,s,n,l,u,v])}const W=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code,ie=e=>{var i,r,a,s;const t=(s=(a=(r=(i=x.value.data)==null?void 0:i.shippingAddresses)==null?void 0:r[0])==null?void 0:a.selectedShippingMethod)==null?void 0:s.carrier.code,c=J();R(()=>{t!==c.current&&(c.current=t,t&&(e==null||e()))},[t,e])};function re({preSelectedMethod:e,onShippingMethodSelect:t}){const i=!B.value.data,r=x.value.data,a=x.value.pending,s=M.value.data,n=M.value.pending,l=k.value,h=r==null?void 0:r.shippingAddresses,u=h==null?void 0:h[0],v=!!u,L=u==null?void 0:u.availableShippingMethods,f=u==null?void 0:u.selectedShippingMethod,p=L||s,b=K(g=>{if(!v)return;const C={method_code:g.code,carrier_code:g.carrier.code};O([C]).catch(w=>{console.error("Setting shipping methods on cart failed:",w)})},[v]),A=g=>{k.value=g,t==null||t(g)},m=Q(()=>{if(!(p!=null&&p.length))return;const g=p[0],C=l||f;return C?p.some(y=>W(y,C))?C:g:p.find(H=>H.carrier.code===(e==null?void 0:e.carrierCode)&&H.code===(e==null?void 0:e.methodCode))||g},[l,f,p,e]);return R(()=>{m&&((!l||!W(m,l))&&(k.value=m,t==null||t(m)),(!f||!W(m,f))&&b(m))},[m,l,f,b,t]),{isLoading:a||i||n,options:p,selection:m,onSelectionChange:A}}const z=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:c,onShippingMethodSelect:i,initialData:r,...a})=>{const{isLoading:s,options:n,selection:l,onSelectionChange:h}=re({preSelectedMethod:e,onCheckoutDataUpdate:t,onShippingMethodSelect:i});return oe(),ie(t),E(I,{children:[o(te,{...a,isLoading:s,onSelectionChange:h,options:n,selection:l}),!s&&c&&o(V,{name:"ShippingMethods",slot:c})]})};z.displayName="ShippingMethodsContainer";const _e=Y(z);export{_e as ShippingMethods,_e as default}; +import{jsx as n,jsxs as v,Fragment as T}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as k,e as S,c as W}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as H}from"@dropins/tools/event-bus.js";import{classes as x,Slot as z}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as R,Icon as V,ProgressSpinner as A,RadioButton as O,Price as P,Skeleton as D,SkeletonRow as L}from"@dropins/tools/components.js";import*as u from"@dropins/tools/preact-compat.js";import{useCallback as Z,useMemo as $,useEffect as q}from"@dropins/tools/preact-compat.js";import{useText as F}from"@dropins/tools/i18n.js";import{useState as N,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as G}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const J=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),K=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),Q=e=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),u.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),U=({className:e,isLoading:t=!1,onSelectionChange:s=()=>{},options:c,selection:l,...p})=>{const i=F({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return c===void 0?n(X,{}):v("div",{...p,className:x(["checkout-shipping-methods",e]),children:[n("h3",{className:"checkout-shipping-methods__title",children:i.Title}),!t&&c.length===0&&n(R,{icon:n(V,{source:Q}),message:n("p",{children:i.EmptyState})}),v("div",{className:x(["checkout-shipping-methods__content"]),children:[t&&n(A,{className:"checkout-shipping-methods__spinner"}),n("div",{className:x(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:c.map(o=>n(O,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:o.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:v(T,{children:[n(P,{amount:o.amount.value,currency:o.amount.currency})," ",n("span",{children:o.carrier.title})]}),description:o.title,value:o.value,checked:(l==null?void 0:l.value)===o.value,onChange:()=>s(o)},o.value))})]})]})},X=()=>v(D,{"data-testid":"shipping-methods-skeleton",children:[n(L,{variant:"heading",size:"small"}),n(L,{variant:"empty",size:"small"}),n(L,{size:"medium",fullWidth:!0}),n(L,{size:"medium",fullWidth:!0})]});function Y(){var a;const[e,t]=N(),[s,c]=N();_(()=>{H.on("checkout/estimate-shipping-address",({address:E,isValid:M})=>{t({address:E,isValid:M})})},[]),_(()=>{c(k.value)},[k.value]),_(()=>{S.value.pending?c(void 0):c(k.value)},[S.value.pending]);const{country_id:l,region_id:p,region:i,postcode:o}=(e==null?void 0:e.address)||{},r=!!e,g=W.value.data,C=!!((a=g==null?void 0:g.shippingAddresses)!=null&&a[0]),d=e==null?void 0:e.isValid;_(()=>{C||d||!s||!r||H.emit("shipping/estimate",{address:J({country_id:l,region_id:p,region:i,postcode:o}),shippingMethod:K(s)})},[s,l,p,i,o,r,C,d])}const j=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function ee({preSelectedMethod:e,onShippingMethodSelect:t}){const s=W.value.data,c=W.value.pending,l=S.value.data,p=S.value.pending,i=k.value,o=s==null?void 0:s.shippingAddresses,r=o==null?void 0:o[0],g=!!r,C=r==null?void 0:r.availableShippingMethods,d=r==null?void 0:r.selectedShippingMethod,a=C||l,E=Z(m=>{if(!g)return;const f={method_code:m.code,carrier_code:m.carrier.code};B([f]).catch(b=>{console.error("Setting shipping methods on cart failed:",b)})},[g]),M=m=>{k.value=m,t==null||t(m)},h=$(()=>{if(!(a!=null&&a.length))return;const m=a[0],f=i||d;return f?a.some(w=>j(w,f))?f:m:a.find(y=>y.carrier.code===(e==null?void 0:e.carrierCode)&&y.code===(e==null?void 0:e.methodCode))||m},[i,d,a,e]);return q(()=>{h&&((!i||!j(h,i))&&(k.value=h,t==null||t(h)),(!d||!j(h,d))&&E(h))},[h,i,d,E,t]),{isLoading:c||p,options:a,selection:h,onSelectionChange:M}}const I=({preSelectedMethod:e,shippingMethodsSlot:t,onShippingMethodSelect:s,initialData:c,...l})=>{const{isLoading:p,options:i,selection:o,onSelectionChange:r}=ee({preSelectedMethod:e,onShippingMethodSelect:s});return Y(),v(T,{children:[n(U,{...l,isLoading:p,onSelectionChange:r,options:i,selection:o}),!p&&t&&n(z,{name:"ShippingMethods",slot:t})]})};I.displayName="ShippingMethodsContainer";const ve=G(I);export{ve as ShippingMethods,ve as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods/ShippingMethods.d.ts b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods/ShippingMethods.d.ts index 3754424403..8d009155a2 100644 --- a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods/ShippingMethods.d.ts +++ b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods/ShippingMethods.d.ts @@ -3,7 +3,6 @@ import { SlotProps } from '@dropins/tools/types/elsie/src/lib'; import { HTMLAttributes } from 'preact/compat'; export interface ShippingMethodsProps extends HTMLAttributes { - onCheckoutDataUpdate?: () => Promise; onShippingMethodSelect?: (method: ShippingMethod) => void; preSelectedMethod?: { carrierCode: string; diff --git a/scripts/__dropins__/storefront-checkout/containers/index.d.ts b/scripts/__dropins__/storefront-checkout/containers/index.d.ts index f80cfe6d5b..b708a0bb91 100644 --- a/scripts/__dropins__/storefront-checkout/containers/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/containers/index.d.ts @@ -24,5 +24,4 @@ export * from './PaymentMethods'; export * from './PlaceOrder'; export * from './ServerError'; export * from './ShippingMethods'; -export * from './OrderConfirmationHeader'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/models/acdl.d.ts b/scripts/__dropins__/storefront-checkout/data/models/acdl.d.ts deleted file mode 100644 index badb138175..0000000000 --- a/scripts/__dropins__/storefront-checkout/data/models/acdl.d.ts +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -/** - * This module contains the schema type definitions to build the ShoppingCart - * and Order contexts, which are required to trigger the "place-order" event. - * - * The following schema types have been extracted from the Adobe Commerce - * Events SDK package. - * - * ShoppingCart schema type @see https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/shoppingCart.ts - * Order schema type @see https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/order.ts - */ -type ShoppingCartItem = { - canApplyMsrp: boolean; - formattedPrice: string; - id: string; - prices: { - price: Price; - }; - product: Product; - configurableOptions?: Array; - quantity: number; -}; -type Price = { - value: number; - currency?: string; - regularPrice?: number; -}; -type Product = { - productId: number; - name: string; - sku: string; - topLevelSku?: string | null; - specialToDate?: string | null; - specialFromDate?: string | null; - newToDate?: string | null; - newFromDate?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - manufacturer?: string | null; - countryOfManufacture?: string | null; - categories?: string[] | null; - productType?: string | null; - pricing?: { - regularPrice: number; - minimalPrice?: number; - maximalPrice?: number; - specialPrice?: number; - tierPricing?: { - customerGroupId?: number | null; - qty: number; - value: number; - }[]; - currencyCode: string | null; - }; - canonicalUrl?: string | null; - mainImageUrl?: string | null; -}; -type ConfigurableOption = { - id?: number; - optionLabel: string; - valueId?: number; - valueLabel: string; -}; -type Payment = { - paymentMethodCode: string; - paymentMethodName: string; - total: number; -}; -type Shipping = { - shippingMethod?: string; - shippingAmount?: number; -}; -export type ShoppingCartContext = { - id: string | null; - items?: Array; - prices?: { - subtotalExcludingTax?: Price; - subtotalIncludingTax?: Price; - }; - totalQuantity: number; - possibleOnepageCheckout?: boolean; - giftMessageSelected?: boolean; - giftWrappingSelected?: boolean; - source?: string; -}; -export type OrderContext = { - appliedCouponCode: string; - email: string; - grandTotal: number; - orderId: string; - orderType?: 'checkout' | 'instant_purchase'; - otherTax: number; - payments?: Payment[]; - salesTax: number; - shipping?: Shipping; - subtotalExcludingTax: number; - subtotalIncludingTax: number; -}; -export {}; -//# sourceMappingURL=acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/models/index.d.ts b/scripts/__dropins__/storefront-checkout/data/models/index.d.ts index 5987f678ab..4fc4b05c46 100644 --- a/scripts/__dropins__/storefront-checkout/data/models/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/models/index.d.ts @@ -14,7 +14,6 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export * from './acdl'; export * from './address'; export * from './api'; export * from './cart'; @@ -22,7 +21,6 @@ export * from './country'; export * from './custom-attribute'; export * from './customer'; export * from './email-availability'; -export * from './order'; export * from './payment-method'; export * from './price'; export * from './region'; diff --git a/scripts/__dropins__/storefront-checkout/data/models/order.d.ts b/scripts/__dropins__/storefront-checkout/data/models/order.d.ts deleted file mode 100644 index 039fbc60e1..0000000000 --- a/scripts/__dropins__/storefront-checkout/data/models/order.d.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { Price } from './price'; - -export type OrderAddressModel = { - city: string; - company: string; - country: string; - firstName: string; - middleName: string; - lastName: string; - postCode: string; - region: string; - regionId: string; - street: string[]; - telephone: string; - customAttributes: { - code: string; - value: string; - }[]; - prefix: string; - suffix: string; - fax: string; -} | null; -export type OrderItemProductModel = { - stockStatus?: string; - canonicalUrl?: string; - id: string; - image?: string; - imageAlt?: string; - name: string; - productType: string; - sku: string; - thumbnail: { - url: string; - label: string; - }; -}; -export type OrderItemModel = { - type?: string; - discounted?: boolean; - id: string; - productName?: string; - regularPrice?: Price; - price?: Price; - product?: OrderItemProductModel; - selectedOptions?: Array<{ - label: string; - value: any; - }>; - totalQuantity?: number; - thumbnail?: { - label: string; - url: string; - }; - downloadableLinks: { - count: number; - result: string; - } | null; - itemPrices: { - priceIncludingTax: Price; - originalPrice: Price; - originalPriceIncludingTax: Price; - price: Price; - }; - bundleOptions: Record | null; - totalInclTax: Price; - priceInclTax: Price; - total: Price; - configurableOptions: Record | undefined; - giftCard?: { - senderName: string; - senderEmail: string; - recipientEmail: string; - recipientName: string; - message: string; - }; - quantityCanceled: number; - quantityInvoiced: number; - quantityOrdered: number; - quantityRefunded: number; - quantityReturned: number; - quantityShipped: number; -}; -export type ShipmentItemsModel = { - id: string; - productSku: string; - productName: string; - orderItem: OrderItemModel; -}; -export type ShipmentsTracingModel = { - carrier: string; - number: string; - title: string; -}; -export type ShipmentsModel = { - id: string; - number: string; - tracking: ShipmentsTracingModel[]; - comments: { - message: string; - timestamp: string; - }[]; - items: ShipmentItemsModel[]; -}; -export type OrderDataModel = { - id: string; - orderStatusChangeDate?: string; - number: string; - email?: string; - token?: string; - status: string; - isVirtual: boolean; - totalQuantity: number; - shippingMethod?: string; - carrier?: string; - discounts: { - amount: Price; - label: string; - }[]; - coupons: { - code: string; - }[]; - payments: { - code: string; - name: string; - }[]; - shipping?: { - code: string; - amount: number; - currency: string; - }; - shipments: ShipmentsModel[]; - items: OrderItemModel[]; - totalGiftcard: Price; - grandTotal: Price; - totalShipping?: Price; - subtotal: Price; - totalTax: Price; - shippingAddress: OrderAddressModel; - billingAddress: OrderAddressModel; - availableActions: AvailableActionsProps[]; - taxes: { - amount: Price; - rate: number; - title: string; - }[]; -}; -declare enum AvailableActionsProps { - CANCEL = "CANCEL", - RETURN = "RETURN", - REORDER = "REORDER" -} -export {}; -//# sourceMappingURL=order.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/transforms/index.d.ts b/scripts/__dropins__/storefront-checkout/data/transforms/index.d.ts index d7208b8967..7d7258d6cc 100644 --- a/scripts/__dropins__/storefront-checkout/data/transforms/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/transforms/index.d.ts @@ -14,14 +14,11 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export * from './transform-acdl'; export * from './transform-address'; export * from './transform-cart'; export * from './transform-customer'; export * from './transform-email-availability'; -export * from './transform-order'; export * from './transform-shipping-estimate'; export * from './transform-shipping-methods'; export * from './transform-store-config'; -export * from './transform-customer-address-input'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/transforms/transform-acdl.d.ts b/scripts/__dropins__/storefront-checkout/data/transforms/transform-acdl.d.ts deleted file mode 100644 index 6d4f613ce2..0000000000 --- a/scripts/__dropins__/storefront-checkout/data/transforms/transform-acdl.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { OrderContext, ShoppingCartContext } from '../models/acdl'; - -export declare const transformShoppingCartContext: (order: Order) => ShoppingCartContext; -export declare const transformOrderContext: (order: Order) => OrderContext; -//# sourceMappingURL=transform-acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/transforms/transform-customer-address-input.d.ts b/scripts/__dropins__/storefront-checkout/data/transforms/transform-customer-address-input.d.ts deleted file mode 100644 index 519f32db7a..0000000000 --- a/scripts/__dropins__/storefront-checkout/data/transforms/transform-customer-address-input.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { CustomerAddressInput } from '../../__generated__/types'; -import { OrderAddressModel } from '../models'; - -export declare function transformCustomerAddressInput(address: OrderAddressModel): CustomerAddressInput; -//# sourceMappingURL=transform-customer-address-input.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/transforms/transform-order.d.ts b/scripts/__dropins__/storefront-checkout/data/transforms/transform-order.d.ts deleted file mode 100644 index afde7494b3..0000000000 --- a/scripts/__dropins__/storefront-checkout/data/transforms/transform-order.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { OrderItemModel } from '../models/order'; -import { PlaceOrderMutation } from '../../__generated__/types'; - -type OrderProps = NonNullable['orderV2']>; -type OrderItems = OrderProps['items']; -type OrderItemProps = NonNullable[number]; -export declare const transformConfigurableOptions: (item: OrderItemProps) => Record | undefined; -export declare const transformBundleOptions: (data: any) => { - [key: string]: any; -} | null; -export declare const transformLinks: (links: { - title: string; -}[]) => { - count: number; - result: string; -} | null; -export declare const transformOrderItems: (items: OrderItemProps[]) => OrderItemModel[]; -export declare const transformOrder: (orderData: OrderProps) => any; -export {}; -//# sourceMappingURL=transform-order.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/fragments.js b/scripts/__dropins__/storefront-checkout/fragments.js index 3c03a79432..6e3d257e6d 100644 --- a/scripts/__dropins__/storefront-checkout/fragments.js +++ b/scripts/__dropins__/storefront-checkout/fragments.js @@ -101,7 +101,7 @@ const e=` middlename fax } -`,d=` +`,a=` fragment CHECKOUT_DATA_FRAGMENT on Cart { id is_virtual @@ -125,257 +125,10 @@ const e=` ${e} ${t} -`,l=` +`,i=` fragment CUSTOMER_FRAGMENT on Customer { firstname lastname email } -`,r=` - fragment ORDER_ADDRESS_FRAGMENT on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id - custom_attributesV2 { - code - ... on AttributeValue { - value - } - } - } -`,a=` - fragment PRODUCT_FRAGMENT on ProductInterface { - __typename - canonical_url - uid - name - sku - only_x_left_in_stock - stock_status - image { - url - } - thumbnail { - label - url - } - price_range { - maximum_price { - regular_price { - currency - value - } - } - } - } -`,_=` - fragment PRICE_FRAGMENT on OrderItemInterface { - prices { - price_including_tax { - value - currency - } - original_price { - value - currency - } - original_price_including_tax { - value - currency - } - price { - value - currency - } - } - } -`,n=` - fragment GIFT_CARD_FRAGMENT on GiftCardOrderItem { - ...PRICE_FRAGMENT - gift_message { - message - } - gift_card { - recipient_name - recipient_email - sender_name - sender_email - message - } - } -`,i=` - fragment ORDER_ITEM_FRAGMENT on OrderItemInterface { - __typename - status - product_name - id - quantity_ordered - quantity_shipped - quantity_canceled - quantity_invoiced - quantity_refunded - quantity_returned - product_sale_price { - value - currency - } - selected_options { - label - value - } - product { - ...PRODUCT_FRAGMENT - } - ...PRICE_FRAGMENT - } -`,c=` - fragment BUNDLE_ORDER_ITEM_FRAGMENT on BundleOrderItem { - ...PRICE_FRAGMENT - bundle_options { - uid - label - values { - uid - product_name - } - } - } -`,o=` - fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { - grand_total { - value - currency - } - total_giftcard { - currency - value - } - subtotal { - currency - value - } - taxes { - title - amount { - currency - value - } - rate - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { - currency - value - } - label - } - } -`,u=` - fragment ORDER_FRAGMENT on CustomerOrder { - email - id - number - order_date - order_status_change_date - status - token - carrier - shipping_method - printed_card_included - gift_receipt_included - available_actions - is_virtual - payment_methods { - name - type - } - applied_coupons { - code - } - shipments { - id - tracking { - title - number - carrier - } - comments { - message - timestamp - } - items { - id - product_sku - product_name - order_item { - ...ORDER_ITEM_FRAGMENT - ... on GiftCardOrderItem { - ...GIFT_CARD_FRAGMENT - product { - ...PRODUCT_FRAGMENT - } - } - } - } - } - payment_methods { - name - type - } - shipping_address { - ...ORDER_ADDRESS_FRAGMENT - } - billing_address { - ...ORDER_ADDRESS_FRAGMENT - } - items { - ...ORDER_ITEM_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_FRAGMENT - product { - ...PRODUCT_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } - total { - ...ORDER_SUMMARY_FRAGMENT - } - } - ${c} - ${n} - ${r} - ${i} - ${o} - ${_} - ${a} -`;export{d as CHECKOUT_DATA_FRAGMENT,l as CUSTOMER_FRAGMENT,u as ORDER_FRAGMENT,i as ORDER_ITEM_FRAGMENT}; +`;export{a as CHECKOUT_DATA_FRAGMENT,i as CUSTOMER_FRAGMENT}; diff --git a/scripts/__dropins__/storefront-checkout/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-checkout/i18n/en_US.json.d.ts index 614cc536db..0026bed482 100644 --- a/scripts/__dropins__/storefront-checkout/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-checkout/i18n/en_US.json.d.ts @@ -71,15 +71,6 @@ declare const _default: { "taxToBeDetermined": "TBD", "withTaxes": "Including taxes", "withoutTaxes": "Excluding taxes" - }, - "OrderConfirmationHeader": { - "title": "{{name}}, thank you for your order!", - "defaultTitle": "Thank you for your order!", - "order": "ORDER #{{order}}", - "CreateAccount": { - "message": "Save your information for faster checkout next time.", - "button": "Create an account" - } } } } diff --git a/scripts/__dropins__/storefront-checkout/lib/acdl.d.ts b/scripts/__dropins__/storefront-checkout/lib/acdl.d.ts deleted file mode 100644 index 8fbdfa5a42..0000000000 --- a/scripts/__dropins__/storefront-checkout/lib/acdl.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Order } from '../data/models/order'; - -/** - * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/contexts.ts - */ -export declare const contexts: { - SHOPPING_CART_CONTEXT: string; - ORDER_CONTEXT: string; -}; -/** - * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/events.ts - */ -export declare const events: { - PLACE_ORDER: string; -}; -export declare function getAdobeDataLayer(): any; -export declare function publishPlaceOrderEvent(order: Order): void; -//# sourceMappingURL=acdl.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/lib/index.d.ts b/scripts/__dropins__/storefront-checkout/lib/index.d.ts index 84a72f08ea..8535e2ba8a 100644 --- a/scripts/__dropins__/storefront-checkout/lib/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/lib/index.d.ts @@ -14,7 +14,6 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export * from './acdl'; export * from './fetch-error'; export * from './network-error'; export * from './state'; diff --git a/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/index.d.ts b/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/index.d.ts index 484646b34b..4d8ab50bed 100644 --- a/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/index.d.ts @@ -14,11 +14,10 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export * from './set-shipping-address'; +export * from './estimate-shipping-methods'; export * from './set-billing-address'; -export * from './set-shipping-methods'; -export * from './set-payment-method'; export * from './set-guest-email'; -export * from './place-order'; -export * from './estimate-shipping-methods'; +export * from './set-payment-method'; +export * from './set-shipping-address'; +export * from './set-shipping-methods'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/place-order.d.ts b/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/place-order.d.ts deleted file mode 100644 index f6d113748b..0000000000 --- a/scripts/__dropins__/storefront-checkout/msw/fixtures/mutations/place-order.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { PlaceOrderMutation } from '../../../__generated__/types'; - -export declare const placeOrderFixture: PlaceOrderMutation; -//# sourceMappingURL=place-order.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/render.js b/scripts/__dropins__/storefront-checkout/render.js index d4f75807c5..c4982a36fe 100644 --- a/scripts/__dropins__/storefront-checkout/render.js +++ b/scripts/__dropins__/storefront-checkout/render.js @@ -1,9 +1,9 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -(function(r,o){try{if(typeof document<"u"){const t=document.createElement("style"),n=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",n),t.appendChild(document.createTextNode(r));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout__banner{margin-bottom:var(--spacing-xlarge)} -.checkout-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.checkout-estimate-shipping__label,.checkout-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-estimate-shipping__price{text-align:right}.checkout-estimate-shipping__label--bold,.checkout-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.checkout-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__shipping .dropin-skeleton{grid-template-columns:1fr}.checkout-login-form__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__content .dropin-field__hint a{font-weight:400}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title{grid-column-start:1;color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end;margin-top:var(--spacing-xxsmall)}a.checkout-login-form__link{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:repeat(1,1fr [col-start]);grid-template-rows:1fr}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:0;margin-bottom:var(--spacing-medium)}}.order-confirmation-header{text-align:center;padding:var(--spacing-xxbig)}.order-confirmation-header__icon{margin-bottom:var(--spacing-small)}.order-confirmation-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-confirmation-header__title:first-letter{text-transform:uppercase}.order-confirmation-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-confirmation-header .success-icon{color:var(--color-positive-500)}.order-confirmation-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-confirmation-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-confirmation-create-account__button{display:flex;margin:0 auto;text-align:center}.checkout-out-of-stock.dropin-card{border-color:var(--color-warning-500)}.checkout-out-of-stock .dropin-card__content{gap:var(--spacing-small);padding:var(--spacing-small)}.checkout-out-of-stock__title{color:var(--color-neutral-900);font:var(--type-body-2-strong-font);margin:0;display:flex;gap:var(--spacing-xxsmall);align-items:center;justify-content:left;text-align:center}.checkout-out-of-stock__message{color:var(--color-neutral-800);font:var(--type-body-2-default-font);margin:0}.checkout-out-of-stock__items{display:grid;grid-template-columns:repeat(5,100px);grid-gap:var(--spacing-small);list-style:none;padding:0;margin:0}.checkout-out-of-stock__item img{width:100%;height:auto}.checkout-out-of-stock__actions{display:flex;gap:var(--spacing-small);justify-content:flex-end}a.checkout-out-of-stock__action{font:var(--type-details-caption-1-font)}.checkout-out-of-stock__action{background:none;border:none;padding:0;cursor:pointer}.checkout-out-of-stock__action:hover{--textColor: var(--color-brand-700);text-decoration:solid underline var(--textColor);text-underline-offset:6px}.checkout-server-error{position:relative;text-align:center}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)} +(function(n,o){try{if(typeof document<"u"){const t=document.createElement("style"),r=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",r),t.appendChild(document.createTextNode(n));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout__banner{margin-bottom:var(--spacing-xlarge)} +.checkout-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.checkout-estimate-shipping__label,.checkout-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-estimate-shipping__price{text-align:right}.checkout-estimate-shipping__label--bold,.checkout-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.checkout-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__shipping .dropin-skeleton{grid-template-columns:1fr}.checkout-login-form__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__content .dropin-field__hint a{font-weight:400}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title{grid-column-start:1;color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end;margin-top:var(--spacing-xxsmall)}a.checkout-login-form__link{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:repeat(1,1fr [col-start]);grid-template-rows:1fr}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:0;margin-bottom:var(--spacing-medium)}}.checkout-out-of-stock.dropin-card{border-color:var(--color-warning-500)}.checkout-out-of-stock .dropin-card__content{gap:var(--spacing-small);padding:var(--spacing-small)}.checkout-out-of-stock__title{color:var(--color-neutral-900);font:var(--type-body-2-strong-font);margin:0;display:flex;gap:var(--spacing-xxsmall);align-items:center;justify-content:left;text-align:center}.checkout-out-of-stock__message{color:var(--color-neutral-800);font:var(--type-body-2-default-font);margin:0}.checkout-out-of-stock__items{display:grid;grid-template-columns:repeat(5,100px);grid-gap:var(--spacing-small);list-style:none;padding:0;margin:0}.checkout-out-of-stock__item img{width:100%;height:auto}.checkout-out-of-stock__actions{display:flex;gap:var(--spacing-small);justify-content:flex-end}a.checkout-out-of-stock__action{font:var(--type-details-caption-1-font)}.checkout-out-of-stock__action{background:none;border:none;padding:0;cursor:pointer}.checkout-out-of-stock__action:hover{--textColor: var(--color-brand-700);text-decoration:solid underline var(--textColor);text-underline-offset:6px}.checkout-server-error{position:relative;text-align:center}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)} .checkout-shipping-methods__title{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--loading{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0} .checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width:320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}} .checkout-payment-methods__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content>div[data-slot=PaymentMethodSlot]:not(:empty){margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods--loading{opacity:.4;pointer-events:none}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}} .checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}`,{styleId:"checkout"}); -import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/fetch-graphql.js";import"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import{events as p}from"@dropins/tools/event-bus.js";import{c as y}from"./chunks/synchronizeCheckout.js";import{UIProvider as g}from"@dropins/tools/components.js";import{useState as b,useEffect as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"./fragments.js";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=function(r){return E(r)&&!v(r)};function E(e){return!!e&&typeof e=="object"}function v(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||M(e)}var w=typeof Symbol=="function"&&Symbol.for,j=w?Symbol.for("react.element"):60103;function M(e){return e.$$typeof===j}function A(e){return Array.isArray(e)?[]:{}}function i(e,r){return r.clone!==!1&&r.isMergeableObject(e)?a(A(e),e,r):e}function P(e,r,t){return e.concat(r).map(function(o){return i(o,t)})}function T(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function C(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(C(e))}function m(e,r){try{return r in e}catch{return!1}}function I(e,r){return m(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function x(e,r,t){var o={};return t.isMergeableObject(e)&&l(e).forEach(function(n){o[n]=i(e[n],t)}),l(r).forEach(function(n){I(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?o[n]=T(n,t)(e[n],r[n],t):o[n]=i(r[n],t))}),o}function a(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||P,t.isMergeableObject=t.isMergeableObject||S,t.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):x(e,r,t):i(r,t)}a.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return a(o,n,t)},{})};var D=a,k=D;const R=O(k),B={title:"Checkout",LoginForm:{title:"Contact details",account:"Already have an account?",ariaLabel:"Email",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",signInButton:"Sign in",forFasterCheckout:"for a faster checkout."},floatingLabel:"Email *",placeholder:"Enter your email address",signIn:"Sign In",switch:"Do you want to switch account?",signOut:"Sign Out"},ShippingMethods:{title:"Shipping options",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct."},BillToShippingAddress:{title:"Bill to shipping address"},PaymentMethods:{title:"Payment",emptyState:"No payment methods available"},OutOfStock:{title:"Your cart contains items that are out of stock",message:"The following items are out of stock:",actions:{reviewCart:"Review cart",removeOutOfStock:"Remove out of stock items"},lowInventory:{one:"Last item!",many:"Only {{count}} left!"},alert:"Out of stock!"},PlaceOrder:{button:"Place Order"},ServerError:{title:"We were unable to process your order",contactSupport:"If you continue to have issues, please contact support.",unexpected:"An unexpected error occurred while processing your order. Please try again later.",button:"Try again"},EmptyCart:{title:"Your cart is empty",button:"Start shopping"},ErrorBanner:{genericMessage:"Server error detected. Please check your connection and try again."},MergedCartBanner:{items:{one:"1 item from a previous session was added to your cart. Please review your new subtotal.",many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal."}},EstimateShipping:{estimated:"Estimated Shipping",freeShipping:"Free",label:"Shipping",taxToBeDetermined:"TBD",withTaxes:"Including taxes",withoutTaxes:"Excluding taxes"},OrderConfirmationHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},L={Checkout:B},_={default:L},U=({children:e})=>{var c;const[r,t]=b(),o=(c=y.getConfig())==null?void 0:c.langDefinitions;h(()=>{const s=p.on("locale",u=>{u!==r&&t(u)},{eager:!0});return()=>{s==null||s.off()}},[r]);const n=R(_,o??{});return f(g,{lang:r,langDefinitions:n,children:e})},Q=new d(f(U,{}));export{U as Provider,Q as render}; +import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/fetch-graphql.js";import"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import{events as p}from"@dropins/tools/event-bus.js";import{c as g}from"./chunks/synchronizeCheckout.js";import{UIProvider as y}from"@dropins/tools/components.js";import{useState as b,useEffect as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"./fragments.js";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=function(r){return E(r)&&!w(r)};function E(e){return!!e&&typeof e=="object"}function w(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||M(e)}var v=typeof Symbol=="function"&&Symbol.for,j=v?Symbol.for("react.element"):60103;function M(e){return e.$$typeof===j}function A(e){return Array.isArray(e)?[]:{}}function i(e,r){return r.clone!==!1&&r.isMergeableObject(e)?a(A(e),e,r):e}function P(e,r,t){return e.concat(r).map(function(o){return i(o,t)})}function I(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function T(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(T(e))}function m(e,r){try{return r in e}catch{return!1}}function C(e,r){return m(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function x(e,r,t){var o={};return t.isMergeableObject(e)&&l(e).forEach(function(n){o[n]=i(e[n],t)}),l(r).forEach(function(n){C(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?o[n]=I(n,t)(e[n],r[n],t):o[n]=i(r[n],t))}),o}function a(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||P,t.isMergeableObject=t.isMergeableObject||S,t.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):x(e,r,t):i(r,t)}a.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return a(o,n,t)},{})};var D=a,B=D;const L=O(B),_={title:"Checkout",LoginForm:{title:"Contact details",account:"Already have an account?",ariaLabel:"Email",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",signInButton:"Sign in",forFasterCheckout:"for a faster checkout."},floatingLabel:"Email *",placeholder:"Enter your email address",signIn:"Sign In",switch:"Do you want to switch account?",signOut:"Sign Out"},ShippingMethods:{title:"Shipping options",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct."},BillToShippingAddress:{title:"Bill to shipping address"},PaymentMethods:{title:"Payment",emptyState:"No payment methods available"},OutOfStock:{title:"Your cart contains items that are out of stock",message:"The following items are out of stock:",actions:{reviewCart:"Review cart",removeOutOfStock:"Remove out of stock items"},lowInventory:{one:"Last item!",many:"Only {{count}} left!"},alert:"Out of stock!"},PlaceOrder:{button:"Place Order"},ServerError:{title:"We were unable to process your order",contactSupport:"If you continue to have issues, please contact support.",unexpected:"An unexpected error occurred while processing your order. Please try again later.",button:"Try again"},EmptyCart:{title:"Your cart is empty",button:"Start shopping"},ErrorBanner:{genericMessage:"Server error detected. Please check your connection and try again."},MergedCartBanner:{items:{one:"1 item from a previous session was added to your cart. Please review your new subtotal.",many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal."}},EstimateShipping:{estimated:"Estimated Shipping",freeShipping:"Free",label:"Shipping",taxToBeDetermined:"TBD",withTaxes:"Including taxes",withoutTaxes:"Excluding taxes"}},R={Checkout:_},U={default:R},k=({children:e})=>{var c;const[r,t]=b(),o=(c=g.getConfig())==null?void 0:c.langDefinitions;h(()=>{const s=p.on("locale",u=>{u!==r&&t(u)},{eager:!0});return()=>{s==null||s.off()}},[r]);const n=L(U,o??{});return f(y,{lang:r,langDefinitions:n,children:e})},Q=new d(f(k,{}));export{k as Provider,Q as render}; diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 955e04c737..1a5db4d12a 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as ce,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as Ee}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` +import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as m,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as pe,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as me}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,c;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((c=e.selectedOptions)==null?void 0:c.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotalExclTax.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=E();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){E().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -12,6 +12,7 @@ import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as E,h a available_actions status number + token id order_date carrier @@ -89,4 +90,4 @@ import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as E,h a ${h} ${f} ${C} -`,k=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,ce as config,Te as confirmCancelOrder,Re as confirmGuestReturn,E as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,Ee as getStoreConfig,de as guestOrderByToken,le as initialize,k as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; +`,$=async t=>{if(!t)throw new Error("No cart ID found");return m(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,pe as config,Te as confirmCancelOrder,Re as confirmGuestReturn,m as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,me as getStoreConfig,de as guestOrderByToken,le as initialize,$ as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts index ba35296ddc..866bcf6d7e 100644 --- a/scripts/__dropins__/storefront-order/configs/mock.config.d.ts +++ b/scripts/__dropins__/storefront-order/configs/mock.config.d.ts @@ -166,6 +166,7 @@ export declare const transformMockOrderInput: { available_actions: string[]; status: string; number: string; + token: string; id: string; order_date: string; carrier: string;