@evenicanpm/storefront-core 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/get-product-by-id.ts +0 -1
- package/__mocks__/query-client.ts +1 -1
- package/package.json +3 -3
- package/src/api-manager/datasources/d365/d365-address.datasource.ts +2 -2
- package/src/api-manager/datasources/d365/d365-cart.datasource.ts +4 -5
- package/src/api-manager/datasources/d365/d365-categories.datasource.ts +1 -1
- package/src/api-manager/datasources/d365/d365-product.datasource.ts +21 -7
- package/src/api-manager/datasources/d365/d365-session.datasource.ts +5 -7
- package/src/api-manager/datasources/d365/d365-user.datasource.ts +12 -23
- package/src/api-manager/datasources/d365/d365.datasource.ts +0 -2
- package/src/api-manager/datasources/d365/index.ts +2 -4
- package/src/api-manager/datasources/d365/utils/decode-jwt.ts +1 -2
- package/src/api-manager/datasources/d365/utils/parse-object.ts +1 -1
- package/src/api-manager/datasources/e4/address/e4-address.remaps.ts +2 -2
- package/src/api-manager/datasources/e4/address/e4-address.translator.ts +1 -1
- package/src/api-manager/datasources/e4/cart/e4-cart.datasource.ts +28 -27
- package/src/api-manager/datasources/e4/cart/e4-cart.remaps.ts +1 -1
- package/src/api-manager/datasources/e4/cart/e4-cart.translator.ts +1 -1
- package/src/api-manager/datasources/e4/categories/e4-categories.translator.ts +20 -20
- package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +471 -7
- package/src/api-manager/datasources/e4/order/e4-order.remaps.ts +2 -2
- package/src/api-manager/datasources/e4/organization/e4-organization.datasource.ts +2 -8
- package/src/api-manager/datasources/e4/product/e4-product.remaps.ts +3 -3
- package/src/api-manager/datasources/e4/product/e4-product.translator.ts +13 -29
- package/src/api-manager/datasources/e4/session/e4-session.datasource.ts +1 -3
- package/src/api-manager/datasources/e4/user/e4-user.remaps.ts +2 -4
- package/src/api-manager/datasources/e4/utils/unwrap-e4-variants.ts +4 -4
- package/src/api-manager/index.ts +1 -1
- package/src/api-manager/lib/category-helpers.ts +3 -2
- package/src/api-manager/lib/get-graphql-client.ts +1 -2
- package/src/api-manager/services/cart/mutations/add-discount-code.ts +2 -2
- package/src/api-manager/services/cart/mutations/add-to-cart.ts +2 -2
- package/src/api-manager/services/product/server/product.server.ts +1 -1
- package/src/api-manager/types/Datasource.ts +4 -9
- package/src/auth/auth-options.test.ts +2 -58
- package/src/auth/auth-options.ts +1 -2
- package/src/auth/next-auth-cookie-manager.ts +0 -2
- package/src/auth/refresh-token.ts +3 -8
- package/src/auth/signout.ts +1 -1
- package/src/cms/blocks/block-manager.tsx +3 -3
- package/src/cms/blocks/components/category-card.tsx +1 -1
- package/src/cms/blocks/components/category-carousel/index.tsx +3 -1
- package/src/cms/blocks/components/footer/index.tsx +2 -2
- package/src/cms/blocks/components/footer/sections/footer-links.tsx +2 -2
- package/src/cms/blocks/components/footer/sections/footer-logo.tsx +1 -1
- package/src/cms/blocks/components/footer/sections/footer-social-links.tsx +10 -2
- package/src/cms/blocks/components/hero-carousel/index.tsx +29 -25
- package/src/cms/blocks/components/media-card.tsx +1 -1
- package/src/cms/blocks/components/product-carousel/index.tsx +1 -1
- package/src/cms/blocks/components/product-section-fullwidth/index.tsx +2 -2
- package/src/cms/blocks/components/seo/index.tsx +5 -1
- package/src/cms/blocks/components/services/index.tsx +1 -1
- package/src/cms/blocks/components/services/service-card.tsx +1 -1
- package/src/cms/blocks/components/shared/featured-product-card.tsx +4 -1
- package/src/cms/blocks/components/shared/product-category-item.tsx +1 -1
- package/src/cms/blocks/components/shared/product-grid.tsx +4 -1
- package/src/cms/blocks/components/shared/top-categories-card.tsx +5 -1
- package/src/cms/blocks/components/shared/top-rating-product-card.tsx +1 -1
- package/src/components-v2/BazaarImage.tsx +1 -1
- package/src/components-v2/BazaarMenu.tsx +2 -2
- package/src/components-v2/BazaarTextField.tsx +3 -3
- package/src/components-v2/BorderShadowCard.stories.tsx +1 -1
- package/src/components-v2/DropZone.tsx +1 -2
- package/src/components-v2/Typography.tsx +12 -12
- package/src/components-v2/accordion/accordion-header.tsx +1 -1
- package/src/components-v2/categories/category-list/styles.ts +0 -7
- package/src/components-v2/categories/category-list-item/category-menu-item.tsx +1 -1
- package/src/components-v2/categories/category-menu.tsx +16 -13
- package/src/components-v2/categories/mega-menu/mega-menu-1.tsx +1 -1
- package/src/components-v2/categories/mega-menu/mega-menu-2.tsx +2 -2
- package/src/components-v2/header/components/user.tsx +5 -5
- package/src/components-v2/mini-cart/__tests__/cart-item.test.tsx +13 -13
- package/src/components-v2/mini-cart/components/bottom-actions.tsx +1 -1
- package/src/components-v2/mini-cart/components/cart-item.tsx +3 -3
- package/src/components-v2/mini-cart/components/top-header.tsx +2 -2
- package/src/components-v2/mobile-navigation/mobile-navigation-bar.tsx +1 -1
- package/src/components-v2/nav-link/nav-link-2.tsx +1 -1
- package/src/components-v2/nav-link/nav-link-3.tsx +1 -1
- package/src/components-v2/nav-link/nav-link.tsx +1 -1
- package/src/components-v2/navbar/categories.tsx +3 -1
- package/src/components-v2/navbar/category-based-menu/category-based-menu.tsx +2 -2
- package/src/components-v2/navbar/mobile-menu/mobile-menu.tsx +11 -3
- package/src/components-v2/navbar/nav-list/nav-item-child.tsx +1 -1
- package/src/components-v2/navbar/nav-list/nav-list.tsx +118 -80
- package/src/components-v2/navbar/navbar.tsx +1 -1
- package/src/components-v2/no-records.tsx +1 -1
- package/src/components-v2/product-cards/favorite-button.tsx +1 -1
- package/src/components-v2/product-cards/product-card/product-card.tsx +5 -7
- package/src/components-v2/product-cards/product-card-plp/product-card.tsx +7 -6
- package/src/components-v2/product-cards/product-card-plp-list/components/tags.tsx +1 -1
- package/src/components-v2/product-cards/product-card-plp-list/product-card.tsx +7 -4
- package/src/components-v2/product-cards/product-card-search/product-card.tsx +4 -2
- package/src/components-v2/product-cards/product-price.tsx +1 -1
- package/src/components-v2/product-cards/product-rating.tsx +1 -1
- package/src/components-v2/product-cards/product-title.tsx +1 -1
- package/src/components-v2/product-cards/quantity-buttons.tsx +1 -1
- package/src/components-v2/product-dialog/compound/product-dialog.tsx +2 -2
- package/src/components-v2/product-dialog/index.tsx +1 -1
- package/src/components-v2/product-dimensions/compound/dimensions-group-list.tsx +6 -1
- package/src/components-v2/product-dimensions/index.tsx +3 -3
- package/src/components-v2/product-quantity-buttons/compound/quantity-buttons-root.tsx +1 -1
- package/src/components-v2/product-quantity-variants/index.tsx +1 -2
- package/src/components-v2/products-view/ProductsList.stories.tsx +0 -2
- package/src/components-v2/products-view/compound/products-grid-view.tsx +2 -2
- package/src/components-v2/products-view/compound/products-list-view.tsx +3 -3
- package/src/components-v2/products-view/index.tsx +2 -2
- package/src/components-v2/progress/progress.tsx +1 -1
- package/src/components-v2/scrollbar/scrollbar.tsx +1 -1
- package/src/components-v2/search-bar/compound/results-suspense.tsx +1 -2
- package/src/components-v2/search-bar/compound/results.tsx +6 -3
- package/src/components-v2/search-bar/compound/search-bar-root.tsx +4 -2
- package/src/components-v2/search-bar/compound/textfield-adornment-category.tsx +25 -27
- package/src/components-v2/search-bar/compound/textfield.tsx +0 -1
- package/src/components-v2/search-bar/hooks/use-search.ts +1 -1
- package/src/components-v2/section/Section.stories.tsx +1 -1
- package/src/components-v2/side-nav/side-nav.tsx +1 -1
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-dialog.tsx +1 -1
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-list.tsx +2 -2
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/hooks/use-add-to-wishlist.ts +2 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/index.tsx +11 -13
- package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-dialog.tsx +2 -1
- package/src/hooks/use-variants.ts +25 -27
- package/src/lib/build-detail-url.ts +1 -1
- package/src/lib/category-helpers.ts +3 -3
- package/src/lib/get-palette-color.ts +35 -15
- package/src/lib/hexToLuma.ts +2 -2
- package/src/lib/store-hours-helper.ts +5 -5
- package/src/pages-v2/account/addresses/address-form.tsx +10 -8
- package/src/pages-v2/account/addresses/address-item.tsx +1 -1
- package/src/pages-v2/account/orders/order-progress.tsx +1 -1
- package/src/pages-v2/account/orders/ordered-products.tsx +1 -1
- package/src/pages-v2/account/profile/user-info.tsx +1 -2
- package/src/pages-v2/account/wishlist/create-new-list.tsx +1 -0
- package/src/pages-v2/account/wishlist/wishlist-item.tsx +2 -1
- package/src/pages-v2/blog/blog-card.tsx +1 -1
- package/src/pages-v2/cart/__tests__/cart-item.test.tsx +0 -1
- package/src/pages-v2/cart/__tests__/checkout-form.test.tsx +0 -8
- package/src/pages-v2/cart/cart-item.tsx +86 -77
- package/src/pages-v2/cart/checkout-form.tsx +4 -4
- package/src/pages-v2/cart/coupon-entry.tsx +3 -3
- package/src/pages-v2/cart/estimate-shipping.tsx +6 -6
- package/src/pages-v2/checkout/checkout-alt-form/checkout-form.tsx +2 -2
- package/src/pages-v2/checkout/checkout-alt-form/checkout-step.tsx +2 -2
- package/src/pages-v2/checkout/checkout-alt-form/step-heading.tsx +1 -1
- package/src/pages-v2/checkout/checkout-alt-form/steps/address/delivery-address.tsx +12 -10
- package/src/pages-v2/checkout/checkout-alt-form/steps/address/new-address-form.tsx +5 -6
- package/src/pages-v2/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx +8 -9
- package/src/pages-v2/checkout/checkout-alt-form/steps/payment/payment-details.tsx +17 -20
- package/src/pages-v2/checkout/checkout-alt-form/steps/shipping/delivery-date.tsx +1 -1
- package/src/pages-v2/checkout/checkout-alt-form/steps/shipping/delivery-options.tsx +14 -15
- package/src/pages-v2/confirmation/confirmation-summary.tsx +8 -7
- package/src/pages-v2/confirmation/ordered-products.tsx +3 -3
- package/src/pages-v2/product-details/bopis/pickup-option-select.tsx +1 -1
- package/src/pages-v2/product-details/bopis/store-card/shop-card.tsx +1 -1
- package/src/pages-v2/product-details/checkbox-label.tsx +1 -1
- package/src/pages-v2/product-details/frequently-bought.tsx +1 -1
- package/src/pages-v2/product-details/frequently-product-card.tsx +1 -1
- package/src/pages-v2/product-details/product-comment.tsx +1 -1
- package/src/pages-v2/product-details/product-description.tsx +2 -2
- package/src/pages-v2/product-details/product-filter-card.tsx +4 -1
- package/src/pages-v2/product-details/product-intro/compound/product-intro-images.tsx +36 -31
- package/src/pages-v2/product-details/product-intro/compound/product-intro.tsx +1 -1
- package/src/pages-v2/product-details/product-intro/compound/thumbnail-with-skeleton.tsx +1 -1
- package/src/pages-v2/product-details/product-intro/utils.ts +2 -4
- package/src/pages-v2/product-details/product-review.tsx +1 -1
- package/src/pages-v2/product-details/product-tabs.tsx +5 -2
- package/src/pages-v2/product-details/related-products.tsx +7 -4
- package/src/pages-v2/product-list/breadcrumbs.tsx +1 -1
- package/src/pages-v2/product-list/checkbox-label.tsx +1 -1
- package/src/pages-v2/product-list/facet-group.tsx +1 -1
- package/src/pages-v2/product-list/list-filter.tsx +2 -2
- package/src/pages-v2/product-list/product-list-context.tsx +5 -1
- package/src/pages-v2/product-list/product-list-view.tsx +4 -1
- package/src/pages-v2/product-list/product-rating.tsx +4 -1
- package/src/pages-v2/product-list/quick-view-dialog-content.tsx +2 -4
- package/src/pages-v2/product-list/quick-view-dialog.tsx +5 -1
- package/src/pages-v2/product-list/range-filter.tsx +0 -1
- package/src/pages-v2/product-list/scrollbar.tsx +1 -1
- package/src/pages-v2/product-list/side-nav.tsx +1 -1
- package/src/pages-v2/product-list/swatch.tsx +12 -7
- package/src/pages-v2/product-list/utils/getCategoryFilterFromSlug.ts +33 -68
- package/src/pages-v2/product-list/utils/product-list-helper.ts +1 -1
- package/src/pages-v2/product-list/utils/search-for-category.ts +2 -2
- package/src/pages-v2/quickorder/order-upload.tsx +90 -76
- package/src/pages-v2/quickorder/provider.tsx +6 -4
- package/src/pages-v2/quickorder/quick-order-row.tsx +1 -1
- package/src/pages-v2/quickorder/quick-order.tsx +28 -21
- package/src/providers/notifications/notification-context.tsx +0 -1
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
import Card from "@mui/material/Card";
|
|
12
12
|
import type { Theme } from "@mui/material/styles";
|
|
13
13
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
14
|
-
import _ from "lodash";
|
|
15
14
|
import { useTranslations } from "next-intl";
|
|
16
15
|
import { createContext, type PropsWithChildren, useContext } from "react";
|
|
17
16
|
|
|
@@ -62,9 +61,9 @@ interface ItemProps {
|
|
|
62
61
|
|
|
63
62
|
UserInfo.Item = ({ title, field, value, transform }: ItemProps) => {
|
|
64
63
|
const ctx = useContext(UserInfoContext);
|
|
64
|
+
const t = useTranslations("Account.Profile");
|
|
65
65
|
if (!ctx) return null;
|
|
66
66
|
const { user } = ctx;
|
|
67
|
-
const t = useTranslations("Account.Profile");
|
|
68
67
|
|
|
69
68
|
let displayValue = value;
|
|
70
69
|
|
|
@@ -61,6 +61,7 @@ const CreateNewList = ({
|
|
|
61
61
|
setNotification({ message: t("wishlistSuccess"), severity: "success" });
|
|
62
62
|
} catch (error) {
|
|
63
63
|
setNotification({ message: t("wishlistFailed"), severity: "error" });
|
|
64
|
+
console.log(error);
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
validate: withZodSchema(FormSchema),
|
|
@@ -50,6 +50,7 @@ const WishlistItem = ({ wishlist, children, sx }: RootProps) => {
|
|
|
50
50
|
message: t("deleteWishlistFailed"),
|
|
51
51
|
severity: "error",
|
|
52
52
|
});
|
|
53
|
+
console.log(error);
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
|
|
@@ -101,9 +102,9 @@ WishlistItem.Date = () => {
|
|
|
101
102
|
|
|
102
103
|
WishlistItem.ProductCount = () => {
|
|
103
104
|
const ctx = useContext(WishlistItemContext);
|
|
105
|
+
const t = useTranslations("Account.Wishlists");
|
|
104
106
|
if (!ctx) return null;
|
|
105
107
|
const { wishlist } = ctx;
|
|
106
|
-
const t = useTranslations("Account.Wishlists");
|
|
107
108
|
return (
|
|
108
109
|
<Paragraph ellipsis>
|
|
109
110
|
{`${wishlist?.ProductListLines?.length ?? 0} ${t("products")}`}
|
|
@@ -8,7 +8,6 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
|
|
8
8
|
import _ from "lodash";
|
|
9
9
|
import { NextIntlClientProvider } from "next-intl";
|
|
10
10
|
import type React from "react";
|
|
11
|
-
//import fr from "../../../../../../messages/fr.json";
|
|
12
11
|
import { vi } from "vitest";
|
|
13
12
|
|
|
14
13
|
vi.mock("next-auth/react", () => ({
|
|
@@ -28,13 +27,6 @@ const Wrapper = ({ children }: React.PropsWithChildren) => (
|
|
|
28
27
|
</NextIntlClientProvider>
|
|
29
28
|
);
|
|
30
29
|
|
|
31
|
-
// Commenting out until used
|
|
32
|
-
/* const Wrapper2 = ({ children }: React.PropsWithChildren) => (
|
|
33
|
-
<NextIntlClientProvider locale={"fr"} messages={fr}>
|
|
34
|
-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
35
|
-
</NextIntlClientProvider>
|
|
36
|
-
); */
|
|
37
|
-
|
|
38
30
|
describe.skip("Checkout Form", () => {
|
|
39
31
|
it("Has Total amount displayed", () => {
|
|
40
32
|
render(
|
|
@@ -72,7 +72,7 @@ function CartItemRoot({
|
|
|
72
72
|
cartId,
|
|
73
73
|
cartVersion,
|
|
74
74
|
children,
|
|
75
|
-
}: CartItemProps) {
|
|
75
|
+
}: Readonly<CartItemProps>) {
|
|
76
76
|
const [isWritingComment, setIsWritingComment] = useState(false);
|
|
77
77
|
const [comment, setComment] = useState(cartLine.Comment || "");
|
|
78
78
|
|
|
@@ -193,9 +193,9 @@ CartItemRoot.Image = () => {
|
|
|
193
193
|
|
|
194
194
|
CartItemRoot.RemoveButton = () => {
|
|
195
195
|
const ctx = useContext(CartItemContext);
|
|
196
|
+
const t = useTranslations("Cart.CartLine");
|
|
196
197
|
if (!ctx) return null;
|
|
197
198
|
const { remove } = ctx;
|
|
198
|
-
const t = useTranslations("Cart.CartLine");
|
|
199
199
|
return (
|
|
200
200
|
<IconButton
|
|
201
201
|
size="small"
|
|
@@ -233,9 +233,9 @@ CartItemRoot.Dimensions = () => {
|
|
|
233
233
|
return (
|
|
234
234
|
<Span ellipsis fontWeight="200" fontSize={14}>
|
|
235
235
|
{dims.map((d, i) => (
|
|
236
|
-
<span key={i}>
|
|
236
|
+
<span key={`dim-${i + 1}`}>
|
|
237
237
|
{`${ProductDimensionType[d.DimensionTypeValue]}: ${d?.DimensionValue?.Value}${
|
|
238
|
-
i + 1
|
|
238
|
+
i + 1 === dims.length ? "" : " | "
|
|
239
239
|
} `}
|
|
240
240
|
</span>
|
|
241
241
|
))}
|
|
@@ -245,9 +245,11 @@ CartItemRoot.Dimensions = () => {
|
|
|
245
245
|
|
|
246
246
|
CartItemRoot.Price = () => {
|
|
247
247
|
const ctx = useContext(CartItemContext);
|
|
248
|
+
const { formatCurrency } = useCurrencyFormatter();
|
|
249
|
+
|
|
248
250
|
if (!ctx) return null;
|
|
251
|
+
|
|
249
252
|
const { cartLine } = ctx;
|
|
250
|
-
const { formatCurrency } = useCurrencyFormatter();
|
|
251
253
|
|
|
252
254
|
const hasDiscount = (cartLine.DiscountLines?.length ?? 0) > 0;
|
|
253
255
|
const qty = cartLine.Quantity ?? 1;
|
|
@@ -281,7 +283,7 @@ CartItemRoot.Price = () => {
|
|
|
281
283
|
{!!cartLine.DiscountLines?.length && (
|
|
282
284
|
<FlexBox gap={1} flexWrap="wrap" alignItems="center">
|
|
283
285
|
{cartLine.DiscountLines?.map((d, i) => (
|
|
284
|
-
<Span key={i} color="error.main">
|
|
286
|
+
<Span key={`dim-${i + 1}`} color="error.main">
|
|
285
287
|
{d.DiscountCode} - {d.OfferName}
|
|
286
288
|
</Span>
|
|
287
289
|
))}
|
|
@@ -293,9 +295,9 @@ CartItemRoot.Price = () => {
|
|
|
293
295
|
|
|
294
296
|
CartItemRoot.Quantity = () => {
|
|
295
297
|
const ctx = useContext(CartItemContext);
|
|
298
|
+
const t = useTranslations("Cart.CartLine");
|
|
296
299
|
if (!ctx) return null;
|
|
297
300
|
const { qty, increase, decrease, isLoading } = ctx;
|
|
298
|
-
const t = useTranslations("Cart.CartLine");
|
|
299
301
|
|
|
300
302
|
if (isLoading) return <CircularProgress size={30} />;
|
|
301
303
|
|
|
@@ -333,7 +335,9 @@ CartItemRoot.Quantity = () => {
|
|
|
333
335
|
|
|
334
336
|
CartItemRoot.Comment = () => {
|
|
335
337
|
const ctx = useContext(CartItemContext);
|
|
338
|
+
const t = useTranslations("Cart.CartLine");
|
|
336
339
|
if (!ctx) return null;
|
|
340
|
+
|
|
337
341
|
const {
|
|
338
342
|
isWritingComment,
|
|
339
343
|
setIsWritingComment,
|
|
@@ -344,83 +348,88 @@ CartItemRoot.Comment = () => {
|
|
|
344
348
|
isLoading,
|
|
345
349
|
cartLine,
|
|
346
350
|
} = ctx;
|
|
347
|
-
const t = useTranslations("Cart.CartLine");
|
|
348
351
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<FlexBox
|
|
365
|
-
flexDirection="row"
|
|
366
|
-
sx={{ marginTop: "auto", marginLeft: "auto" }}
|
|
367
|
-
>
|
|
368
|
-
<Button
|
|
369
|
-
color="primary"
|
|
370
|
-
variant="outlined"
|
|
371
|
-
sx={{ width: 100 }}
|
|
372
|
-
onClick={cancelComment}
|
|
373
|
-
>
|
|
374
|
-
{t("cancelComment")}
|
|
375
|
-
</Button>
|
|
376
|
-
<Button
|
|
377
|
-
color="primary"
|
|
378
|
-
variant="contained"
|
|
379
|
-
sx={{ width: 150, ml: 1 }}
|
|
380
|
-
onClick={saveComment}
|
|
381
|
-
>
|
|
382
|
-
{t("saveComment")}
|
|
383
|
-
</Button>
|
|
384
|
-
</FlexBox>
|
|
385
|
-
</>
|
|
386
|
-
) : isLoading ? (
|
|
387
|
-
<CircularProgress
|
|
388
|
-
size={30}
|
|
389
|
-
sx={{ marginTop: "auto", marginLeft: "auto" }}
|
|
352
|
+
let content: React.ReactNode;
|
|
353
|
+
|
|
354
|
+
if (isWritingComment) {
|
|
355
|
+
content = (
|
|
356
|
+
<>
|
|
357
|
+
<TextField
|
|
358
|
+
label={t("addComment")}
|
|
359
|
+
variant="outlined"
|
|
360
|
+
multiline
|
|
361
|
+
minRows={2}
|
|
362
|
+
maxRows={2}
|
|
363
|
+
fullWidth
|
|
364
|
+
value={comment}
|
|
365
|
+
onChange={(e) => setComment(e.target.value)}
|
|
366
|
+
sx={{ marginBottom: 1 }}
|
|
390
367
|
/>
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
sx={{
|
|
396
|
-
mb: 1,
|
|
397
|
-
mt: "auto",
|
|
398
|
-
maxWidth: { xs: "250px", lg: "350px" },
|
|
399
|
-
whiteSpace: "nowrap",
|
|
400
|
-
overflow: "hidden",
|
|
401
|
-
textOverflow: "ellipsis",
|
|
402
|
-
}}
|
|
403
|
-
title={cartLine.Comment || ""}
|
|
404
|
-
>
|
|
405
|
-
{cartLine.Comment ? (
|
|
406
|
-
<>
|
|
407
|
-
<H6 sx={{ display: "inline" }}>{t("commentLabel")}: </H6>
|
|
408
|
-
{cartLine.Comment}
|
|
409
|
-
</>
|
|
410
|
-
) : null}
|
|
411
|
-
</Typography>
|
|
368
|
+
<FlexBox
|
|
369
|
+
flexDirection="row"
|
|
370
|
+
sx={{ marginTop: "auto", marginLeft: "auto" }}
|
|
371
|
+
>
|
|
412
372
|
<Button
|
|
413
373
|
color="primary"
|
|
414
374
|
variant="outlined"
|
|
415
|
-
sx={{ width:
|
|
416
|
-
onClick={
|
|
375
|
+
sx={{ width: 100 }}
|
|
376
|
+
onClick={cancelComment}
|
|
417
377
|
>
|
|
418
|
-
{t("
|
|
378
|
+
{t("cancelComment")}
|
|
419
379
|
</Button>
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
380
|
+
<Button
|
|
381
|
+
color="primary"
|
|
382
|
+
variant="contained"
|
|
383
|
+
sx={{ width: 150, ml: 1 }}
|
|
384
|
+
onClick={saveComment}
|
|
385
|
+
>
|
|
386
|
+
{t("saveComment")}
|
|
387
|
+
</Button>
|
|
388
|
+
</FlexBox>
|
|
389
|
+
</>
|
|
390
|
+
);
|
|
391
|
+
} else if (isLoading) {
|
|
392
|
+
content = (
|
|
393
|
+
<CircularProgress
|
|
394
|
+
size={30}
|
|
395
|
+
sx={{ marginTop: "auto", marginLeft: "auto" }}
|
|
396
|
+
/>
|
|
397
|
+
);
|
|
398
|
+
} else {
|
|
399
|
+
content = (
|
|
400
|
+
<>
|
|
401
|
+
<Typography
|
|
402
|
+
component="div"
|
|
403
|
+
sx={{
|
|
404
|
+
mb: 1,
|
|
405
|
+
mt: "auto",
|
|
406
|
+
maxWidth: { xs: "250px", lg: "350px" },
|
|
407
|
+
whiteSpace: "nowrap",
|
|
408
|
+
overflow: "hidden",
|
|
409
|
+
textOverflow: "ellipsis",
|
|
410
|
+
}}
|
|
411
|
+
title={cartLine.Comment || ""}
|
|
412
|
+
>
|
|
413
|
+
{cartLine.Comment ? (
|
|
414
|
+
<>
|
|
415
|
+
<H6 sx={{ display: "inline" }}>{t("commentLabel")}: </H6>
|
|
416
|
+
{cartLine.Comment}
|
|
417
|
+
</>
|
|
418
|
+
) : null}
|
|
419
|
+
</Typography>
|
|
420
|
+
<Button
|
|
421
|
+
color="primary"
|
|
422
|
+
variant="outlined"
|
|
423
|
+
sx={{ width: 150, mt: "auto", ml: "auto" }}
|
|
424
|
+
onClick={() => setIsWritingComment(true)}
|
|
425
|
+
>
|
|
426
|
+
{t("addComment")}
|
|
427
|
+
</Button>
|
|
428
|
+
</>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return <CartItemRoot.Right>{content}</CartItemRoot.Right>;
|
|
424
433
|
};
|
|
425
434
|
|
|
426
435
|
const CartItem = Object.assign(CartItemRoot, {
|
|
@@ -100,10 +100,10 @@ const CheckoutForm = ({
|
|
|
100
100
|
|
|
101
101
|
CheckoutForm.Total = () => {
|
|
102
102
|
const ctx = useContext(CheckoutFormContext);
|
|
103
|
-
if (!ctx) return null;
|
|
104
|
-
const { cartTotal } = ctx;
|
|
105
103
|
const { number } = useFormatter();
|
|
106
104
|
const t = useTranslations("Cart.Sidebar");
|
|
105
|
+
if (!ctx) return null;
|
|
106
|
+
const { cartTotal } = ctx;
|
|
107
107
|
|
|
108
108
|
return (
|
|
109
109
|
<>
|
|
@@ -120,9 +120,9 @@ CheckoutForm.Total = () => {
|
|
|
120
120
|
|
|
121
121
|
CheckoutForm.Notes = () => {
|
|
122
122
|
const ctx = useContext(CheckoutFormContext);
|
|
123
|
+
const t = useTranslations("Cart.Sidebar");
|
|
123
124
|
if (!ctx) return null;
|
|
124
125
|
const { updateCartComment, textRef } = ctx;
|
|
125
|
-
const t = useTranslations("Cart.Sidebar");
|
|
126
126
|
const debounceCommentUpdate = debounce(
|
|
127
127
|
(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
128
128
|
updateCartComment(e.target.value),
|
|
@@ -192,9 +192,9 @@ CheckoutForm.EstimateShipping = () => {
|
|
|
192
192
|
|
|
193
193
|
CheckoutForm.CheckoutButton = () => {
|
|
194
194
|
const ctx = useContext(CheckoutFormContext);
|
|
195
|
+
const t = useTranslations("Cart.Sidebar");
|
|
195
196
|
if (!ctx) return null;
|
|
196
197
|
const { checkoutDisabled } = ctx;
|
|
197
|
-
const t = useTranslations("Cart.Sidebar");
|
|
198
198
|
|
|
199
199
|
return (
|
|
200
200
|
<Button
|
|
@@ -72,9 +72,9 @@ const CouponEntry = ({
|
|
|
72
72
|
|
|
73
73
|
CouponEntry.Input = () => {
|
|
74
74
|
const ctx = useContext(CouponContext);
|
|
75
|
+
const t = useTranslations("Cart.Coupons");
|
|
75
76
|
if (!ctx) return null;
|
|
76
77
|
const { textValue, setTextValue } = ctx;
|
|
77
|
-
const t = useTranslations("Cart.Coupons");
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
80
|
<TextField
|
|
@@ -91,9 +91,9 @@ CouponEntry.Input = () => {
|
|
|
91
91
|
|
|
92
92
|
CouponEntry.ApplyButton = () => {
|
|
93
93
|
const ctx = useContext(CouponContext);
|
|
94
|
+
const t = useTranslations("Cart.Coupons");
|
|
94
95
|
if (!ctx) return null;
|
|
95
96
|
const { handleApplyCoupon } = ctx;
|
|
96
|
-
const t = useTranslations("Cart.Coupons");
|
|
97
97
|
|
|
98
98
|
return (
|
|
99
99
|
<Button
|
|
@@ -110,9 +110,9 @@ CouponEntry.ApplyButton = () => {
|
|
|
110
110
|
|
|
111
111
|
CouponEntry.AppliedList = () => {
|
|
112
112
|
const ctx = useContext(CouponContext);
|
|
113
|
+
const t = useTranslations("Cart.Coupons");
|
|
113
114
|
if (!ctx) return null;
|
|
114
115
|
const { appliedCoupons } = ctx;
|
|
115
|
-
const t = useTranslations("Cart.Coupons");
|
|
116
116
|
|
|
117
117
|
if (!appliedCoupons.length) return null;
|
|
118
118
|
|
|
@@ -132,9 +132,9 @@ const EstimateShipping = ({
|
|
|
132
132
|
// Subcomponents
|
|
133
133
|
EstimateShipping.Country = () => {
|
|
134
134
|
const ctx = useContext(EstimateShippingContext);
|
|
135
|
+
const t = useTranslations("Cart.Sidebar");
|
|
135
136
|
if (!ctx) return null;
|
|
136
137
|
const { selectedCountry, setSelectedCountry, countries } = ctx;
|
|
137
|
-
const t = useTranslations("Cart.Sidebar");
|
|
138
138
|
return (
|
|
139
139
|
<Box sx={{ mb: 2 }}>
|
|
140
140
|
<CountryInput
|
|
@@ -149,9 +149,9 @@ EstimateShipping.Country = () => {
|
|
|
149
149
|
|
|
150
150
|
EstimateShipping.State = () => {
|
|
151
151
|
const ctx = useContext(EstimateShippingContext);
|
|
152
|
+
const t = useTranslations("Cart.Sidebar");
|
|
152
153
|
if (!ctx) return null;
|
|
153
154
|
const { selectedState, setSelectedState, states } = ctx;
|
|
154
|
-
const t = useTranslations("Cart.Sidebar");
|
|
155
155
|
return (
|
|
156
156
|
<TextField
|
|
157
157
|
select
|
|
@@ -173,9 +173,9 @@ EstimateShipping.State = () => {
|
|
|
173
173
|
|
|
174
174
|
EstimateShipping.ZipCode = () => {
|
|
175
175
|
const ctx = useContext(EstimateShippingContext);
|
|
176
|
+
const t = useTranslations("Cart.Sidebar");
|
|
176
177
|
if (!ctx) return null;
|
|
177
178
|
const { zipCode, setZipCode } = ctx;
|
|
178
|
-
const t = useTranslations("Cart.Sidebar");
|
|
179
179
|
return (
|
|
180
180
|
<TextField
|
|
181
181
|
fullWidth
|
|
@@ -190,9 +190,9 @@ EstimateShipping.ZipCode = () => {
|
|
|
190
190
|
|
|
191
191
|
EstimateShipping.Submit = () => {
|
|
192
192
|
const ctx = useContext(EstimateShippingContext);
|
|
193
|
+
const t = useTranslations("Cart.Sidebar");
|
|
193
194
|
if (!ctx) return null;
|
|
194
195
|
const { doDeliveryMethodLookup } = ctx;
|
|
195
|
-
const t = useTranslations("Cart.Sidebar");
|
|
196
196
|
return (
|
|
197
197
|
<Button
|
|
198
198
|
variant="outlined"
|
|
@@ -208,10 +208,10 @@ EstimateShipping.Submit = () => {
|
|
|
208
208
|
|
|
209
209
|
EstimateShipping.Options = () => {
|
|
210
210
|
const ctx = useContext(EstimateShippingContext);
|
|
211
|
-
if (!ctx) return null;
|
|
212
|
-
const { deliveryOptions, noOptionsFound } = ctx;
|
|
213
211
|
const { formatCurrency } = useCurrencyFormatter();
|
|
214
212
|
const t = useTranslations("Cart.Sidebar");
|
|
213
|
+
if (!ctx) return null;
|
|
214
|
+
const { deliveryOptions, noOptionsFound } = ctx;
|
|
215
215
|
|
|
216
216
|
if (noOptionsFound) {
|
|
217
217
|
return <Span color="error.main">{t("noDeliveryOptionsFound")}</Span>;
|
|
@@ -163,9 +163,9 @@ CheckoutForm.Step = <T extends object>({
|
|
|
163
163
|
componentProps,
|
|
164
164
|
}: StepProps<T>) => {
|
|
165
165
|
const ctx = useContext(CheckoutContext);
|
|
166
|
+
const t = useTranslations("Checkout");
|
|
166
167
|
if (!ctx) return null;
|
|
167
168
|
const { activeStep, setActiveStep, cart } = ctx;
|
|
168
|
-
const t = useTranslations("Checkout");
|
|
169
169
|
return (
|
|
170
170
|
<CheckoutStep
|
|
171
171
|
title={t(title)}
|
|
@@ -186,9 +186,9 @@ CheckoutForm.Step = <T extends object>({
|
|
|
186
186
|
|
|
187
187
|
CheckoutForm.Footer = () => {
|
|
188
188
|
const ctx = useContext(CheckoutContext);
|
|
189
|
+
const t = useTranslations("Checkout");
|
|
189
190
|
if (!ctx) return null;
|
|
190
191
|
const { placeOrder, isSubmitting, activeStep, totalSteps } = ctx;
|
|
191
|
-
const t = useTranslations("Checkout");
|
|
192
192
|
|
|
193
193
|
const isFormComplete = () => activeStep > totalSteps;
|
|
194
194
|
|
|
@@ -92,9 +92,9 @@ const CheckoutStep = ({
|
|
|
92
92
|
|
|
93
93
|
CheckoutStep.Header = () => {
|
|
94
94
|
const ctx = useContext(StepContext);
|
|
95
|
+
const t = useTranslations("Checkout.Steps");
|
|
95
96
|
if (!ctx) return null;
|
|
96
97
|
const { title, stepNumber, stepViewState, hasCompleted, setActiveStep } = ctx;
|
|
97
|
-
const t = useTranslations("Checkout.Steps");
|
|
98
98
|
|
|
99
99
|
return (
|
|
100
100
|
<FlexBox justifyContent="space-between">
|
|
@@ -149,9 +149,9 @@ CheckoutStep.Body = <P extends object = {}>({
|
|
|
149
149
|
|
|
150
150
|
CheckoutStep.Actions = () => {
|
|
151
151
|
const ctx = useContext(StepContext);
|
|
152
|
+
const t = useTranslations("Checkout.Steps");
|
|
152
153
|
if (!ctx) return null;
|
|
153
154
|
const { stepViewState, setStepSubmissionState } = ctx;
|
|
154
|
-
const t = useTranslations("Checkout.Steps");
|
|
155
155
|
|
|
156
156
|
if (stepViewState !== "active") return null;
|
|
157
157
|
|
|
@@ -249,11 +249,15 @@ const DeliveryAddress: DeliveryAddressCompound = ({
|
|
|
249
249
|
);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
let visibleAddresses = addressList;
|
|
253
|
+
|
|
254
|
+
if (useDropDown) {
|
|
255
|
+
if (!isGuest) {
|
|
256
|
+
visibleAddresses = addressList.filter(
|
|
257
|
+
(a) => a.RecordId === selectedAddressID,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
257
261
|
|
|
258
262
|
// modal helpers
|
|
259
263
|
const openNew = () => {
|
|
@@ -358,9 +362,9 @@ DeliveryAddress.Dropdown = () => {
|
|
|
358
362
|
</AddressDropDownHandler>
|
|
359
363
|
)}
|
|
360
364
|
options={(onClose: () => void) =>
|
|
361
|
-
addressList.map((value
|
|
365
|
+
addressList.map((value) => (
|
|
362
366
|
<MenuItem
|
|
363
|
-
key={
|
|
367
|
+
key={value.RecordId}
|
|
364
368
|
onClick={async () => {
|
|
365
369
|
pickAddress(value.RecordId as number);
|
|
366
370
|
onClose();
|
|
@@ -406,9 +410,7 @@ DeliveryAddress.Card = ({ address, children }: ItemProps) => {
|
|
|
406
410
|
|
|
407
411
|
return (
|
|
408
412
|
<Grid size={{ md: 4, sm: 6, xs: 12 }}>
|
|
409
|
-
{children
|
|
410
|
-
children
|
|
411
|
-
) : (
|
|
413
|
+
{children || (
|
|
412
414
|
<AddressCard
|
|
413
415
|
address={address}
|
|
414
416
|
isCartAddress={cartShippingAddressId === address.Id}
|
|
@@ -312,12 +312,11 @@ NewAddressForm.StateSelect = () => {
|
|
|
312
312
|
render={({ field }) => (
|
|
313
313
|
<Select labelId="state-label" {...field}>
|
|
314
314
|
<MenuItem value="0">Select a state</MenuItem>
|
|
315
|
-
{states
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
))}
|
|
315
|
+
{states?.map(({ StateName, StateId }) => (
|
|
316
|
+
<MenuItem key={StateId} value={StateId}>
|
|
317
|
+
{StateName}
|
|
318
|
+
</MenuItem>
|
|
319
|
+
))}
|
|
321
320
|
</Select>
|
|
322
321
|
)}
|
|
323
322
|
/>
|
package/src/pages-v2/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx
CHANGED
|
@@ -107,22 +107,21 @@ const CustomerInformation = (
|
|
|
107
107
|
|
|
108
108
|
return (
|
|
109
109
|
<CustomerContext.Provider value={ctx}>
|
|
110
|
-
{children
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)}
|
|
110
|
+
{children ||
|
|
111
|
+
(stepViewState === "preview" ? (
|
|
112
|
+
<CustomerInformation.Preview />
|
|
113
|
+
) : (
|
|
114
|
+
<CustomerInformation.Form />
|
|
115
|
+
))}
|
|
117
116
|
</CustomerContext.Provider>
|
|
118
117
|
);
|
|
119
118
|
};
|
|
120
119
|
|
|
121
120
|
CustomerInformation.Preview = () => {
|
|
122
121
|
const ctx = useContext(CustomerContext);
|
|
122
|
+
const t = useTranslations("Checkout.CustomerInformation");
|
|
123
123
|
if (!ctx) return null;
|
|
124
124
|
const { email } = ctx;
|
|
125
|
-
const t = useTranslations("Checkout.CustomerInformation");
|
|
126
125
|
return (
|
|
127
126
|
<Box ml={2}>
|
|
128
127
|
<Paragraph>
|
|
@@ -134,10 +133,10 @@ CustomerInformation.Preview = () => {
|
|
|
134
133
|
|
|
135
134
|
CustomerInformation.Form = () => {
|
|
136
135
|
const ctx = useContext(CustomerContext);
|
|
136
|
+
const t = useTranslations("Checkout.CustomerInformation");
|
|
137
137
|
if (!ctx) return null;
|
|
138
138
|
const { form, handleSave } = ctx;
|
|
139
139
|
const { register, handleSubmit, formState } = form;
|
|
140
|
-
const t = useTranslations("Checkout.CustomerInformation");
|
|
141
140
|
|
|
142
141
|
return (
|
|
143
142
|
<form onSubmit={handleSubmit(handleSave)}>
|
|
@@ -64,16 +64,14 @@ const PaymentDetails: PaymentDetailsCompound = (props) => {
|
|
|
64
64
|
const { data: paymentAcceptPointData } = getPaymentAcceptPoint.useData({
|
|
65
65
|
cartId: cart.Id,
|
|
66
66
|
totalAmount: cart.TotalAmount ?? 0,
|
|
67
|
-
origin:
|
|
68
|
-
|
|
69
|
-
isClient: typeof window !== "undefined",
|
|
67
|
+
origin: globalThis.window?.location?.origin,
|
|
68
|
+
isClient: !!globalThis.window,
|
|
70
69
|
});
|
|
71
70
|
|
|
72
71
|
const { mutateAsync: retrievePaymentAcceptResult } = usePaymentAcceptResult();
|
|
73
72
|
const iframeReference = React.useRef<HTMLIFrameElement>(null);
|
|
74
73
|
const [iframeHeight, setIFrameHeight] = React.useState<number>(1);
|
|
75
74
|
const [errorState, setErrorState] = React.useState<PaymentError[]>([]);
|
|
76
|
-
// const [showOverlay, setShowOverlay] = React.useState(false);
|
|
77
75
|
|
|
78
76
|
const paymentConnectorMessage = (
|
|
79
77
|
data: string,
|
|
@@ -90,7 +88,7 @@ const PaymentDetails: PaymentDetailsCompound = (props) => {
|
|
|
90
88
|
resultAccessCode: accessCode,
|
|
91
89
|
settings: {
|
|
92
90
|
PaymentConnectorId: paymentAcceptPointData?.PaymentConnectorId,
|
|
93
|
-
ReturnUrl: window
|
|
91
|
+
ReturnUrl: globalThis.window?.location?.href ?? "",
|
|
94
92
|
},
|
|
95
93
|
};
|
|
96
94
|
const paymentAcceptResultData = await retrievePaymentAcceptResult(input);
|
|
@@ -182,15 +180,15 @@ const PaymentDetails: PaymentDetailsCompound = (props) => {
|
|
|
182
180
|
|
|
183
181
|
const onEvent = React.useCallback(
|
|
184
182
|
(event: MessageEvent) => {
|
|
185
|
-
//
|
|
183
|
+
// Do Security check -> validate event.origin matches expected
|
|
186
184
|
onIFrameMessage(event);
|
|
187
185
|
},
|
|
188
186
|
[onIFrameMessage],
|
|
189
187
|
);
|
|
190
188
|
|
|
191
189
|
React.useEffect(() => {
|
|
192
|
-
|
|
193
|
-
return () =>
|
|
190
|
+
globalThis.addEventListener("message", onEvent);
|
|
191
|
+
return () => globalThis.removeEventListener("message", onEvent);
|
|
194
192
|
}, [onEvent]);
|
|
195
193
|
|
|
196
194
|
const postSubmitMessage = React.useCallback(() => {
|
|
@@ -226,18 +224,17 @@ const PaymentDetails: PaymentDetailsCompound = (props) => {
|
|
|
226
224
|
|
|
227
225
|
return (
|
|
228
226
|
<>
|
|
229
|
-
{children
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
)}
|
|
227
|
+
{children ||
|
|
228
|
+
(stepViewState === "preview" ? (
|
|
229
|
+
<PaymentDetails.Preview paymentAcceptResult={paymentAcceptResult} />
|
|
230
|
+
) : (
|
|
231
|
+
<PaymentDetails.Form
|
|
232
|
+
iframeReference={iframeReference}
|
|
233
|
+
iframeHeight={iframeHeight}
|
|
234
|
+
errorState={errorState}
|
|
235
|
+
paymentAcceptPointData={paymentAcceptPointData}
|
|
236
|
+
/>
|
|
237
|
+
))}
|
|
241
238
|
</>
|
|
242
239
|
);
|
|
243
240
|
};
|