@evenicanpm/storefront-core 2.4.2 → 2.5.1
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/CHANGELOG.md +14 -0
- package/package.json +90 -90
- package/src/api-manager/datasources/d365/d365-cart.datasource.ts +4 -3
- package/src/api-manager/datasources/d365/d365-user.datasource.ts +3 -3
- package/src/api-manager/datasources/d365/utils/get-context-cookie.ts +1 -0
- package/src/api-manager/datasources/e4/address/e4-address.datasource.ts +5 -14
- package/src/api-manager/datasources/e4/address/e4-address.translator.ts +4 -3
- package/src/api-manager/datasources/e4/categories/e4-categories.translator.ts +1 -1
- package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +29 -3
- package/src/api-manager/datasources/e4/product/e4-product.translator.ts +1 -1
- package/src/api-manager/index.ts +1 -1
- package/src/api-manager/lib/get-graphql-client.ts +1 -1
- package/src/api-manager/services/cart/mutations/add-discount-code.ts +0 -11
- package/src/api-manager/services/create-query.ts +13 -7
- package/src/api-manager/services/user/mutations/add-to-wishlist.ts +1 -1
- package/src/api-manager/services/user/mutations/remove-from-wishlist.ts +1 -1
- package/src/auth/AUTH GUIDE.md +880 -0
- package/src/cms/blocks/components/featured-categories.tsx +18 -15
- package/src/cms/blocks/components/featured-products.tsx +3 -2
- package/src/cms/blocks/components/footer/data/index.ts +0 -0
- package/src/cms/blocks/components/footer/index.tsx +0 -0
- package/src/cms/blocks/components/footer/sections/footer-app-store.tsx +0 -0
- package/src/cms/blocks/components/footer/sections/footer-contact.tsx +0 -2
- package/src/cms/blocks/components/footer/sections/footer-links.tsx +0 -0
- package/src/cms/blocks/components/footer/sections/footer-logo.tsx +2 -1
- package/src/cms/blocks/components/footer/sections/footer-social-links.tsx +0 -0
- package/src/cms/blocks/components/footer/styles/index.ts +0 -0
- package/src/cms/blocks/components/hero-carousel/index.tsx +0 -0
- package/src/cms/blocks/components/product-carousel/index.tsx +0 -0
- package/src/cms/blocks/components/shared/featured-product-card.tsx +0 -0
- package/src/cms/blocks/components/shared/product-category-item.tsx +0 -0
- package/src/cms/blocks/components/shared/product-grid.tsx +0 -0
- package/src/cms/blocks/components/shared/top-categories-card.tsx +0 -0
- package/src/cms/blocks/components/shared/top-rating-product-card.tsx +0 -0
- package/src/cms/blocks/icons/components/category.tsx +0 -0
- package/src/cms/blocks/icons/components/dotted-star.tsx +0 -0
- package/src/cms/blocks/icons/components/gift-box.tsx +0 -0
- package/src/cms/blocks/icons/components/light.tsx +0 -0
- package/src/cms/blocks/icons/components/new-arrival.tsx +0 -0
- package/src/cms/blocks/icons/components/rank-badge.tsx +0 -0
- package/src/components/SearchInput.stories.tsx +12 -10
- package/src/components/base-layout.tsx +42 -0
- package/src/components/categories/category-list/category-list.tsx +32 -12
- package/src/components/header/__tests__/header.test.tsx +0 -24
- package/src/components/header/components/mobile-header.tsx +16 -8
- package/src/components/header/header.tsx +6 -3
- package/src/components/mini-cart/components/bottom-actions.tsx +7 -2
- package/src/components/mini-cart/components/cart-item.tsx +16 -13
- package/src/components/mini-cart/components/empty-view.tsx +12 -6
- package/src/components/mini-cart/components/top-header.tsx +9 -8
- package/src/components/mini-cart/mini-cart-trigger.tsx +11 -5
- package/src/components/mini-cart/mini-cart.tsx +30 -15
- package/src/components/mobile-navigation/mobile-navigation-bar.tsx +6 -2
- package/src/components/navbar/categories.tsx +8 -2
- package/src/components/navbar/category-based-menu/category-based-menu.tsx +6 -2
- package/src/components/navbar/mega-menu/mega-menu.tsx +22 -14
- package/src/components/navbar/mobile-menu/mobile-menu.test.tsx +8 -11
- package/src/components/navbar/mobile-menu/mobile-menu.tsx +13 -11
- package/src/components/navbar/nav-list/nav-list.tsx +3 -2
- package/src/components/navbar/navbar.tsx +4 -2
- package/src/components/product-cards/product-card/product-card.tsx +50 -26
- package/src/components/product-cards/product-card-plp/product-card.tsx +37 -16
- package/src/components/product-cards/product-card-plp-list/product-card.tsx +38 -16
- package/src/components/product-cards/product-card-search/product-card.tsx +34 -13
- package/src/components/product-dialog/ProductDialog.stories.tsx +20 -18
- package/src/components/product-dialog/compound/product-dialog.tsx +7 -4
- package/src/components/product-dimensions/compound/dimensions-group.tsx +4 -2
- package/src/components/product-dimensions/compound/dimensions.tsx +15 -6
- package/src/components/product-quantity-buttons/compound/quantity-buttons-root.tsx +21 -13
- package/src/components/products-view/compound/products-grid-view.tsx +11 -4
- package/src/components/products-view/compound/products-list-view.tsx +11 -4
- package/src/components/search-bar/compound/search-bar-root.tsx +6 -4
- package/src/components/search-bar/compound/textfield-adornment-category.tsx +25 -8
- package/src/components/search-bar/hooks/use-click-outside.ts +7 -1
- package/src/components/search-bar/hooks/use-search.ts +3 -3
- package/src/components/user/index.ts +3 -0
- package/src/components/user/use-user-auth.ts +163 -0
- package/src/components/user/user.tsx +215 -0
- package/src/components/wishlist-dialogs/add-to-wishlist/AddToWishlist.stories.tsx +20 -15
- package/src/components/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-dialog.tsx +11 -8
- package/src/components/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-list.tsx +18 -3
- package/src/components/wishlist-dialogs/add-to-wishlist/index.tsx +0 -1
- package/src/components/wishlist-dialogs/create-wishlist/compound/create-wishlist-dialog.tsx +6 -2
- package/src/hooks/use-overflow-detect.ts +4 -4
- package/src/lib/graphqlRequestSdk.ts +0 -0
- package/src/lib/page-slugs.ts +16 -0
- package/src/pages/account/account-navigation.tsx +7 -14
- package/src/pages/account/account-routes.ts +4 -9
- package/src/pages/account/addresses/address-form.tsx +38 -16
- package/src/pages/account/addresses/address-item.tsx +18 -8
- package/src/pages/account/dashboard-header.tsx +20 -13
- package/src/pages/account/orders/order-history-filters-panel.tsx +21 -20
- package/src/pages/account/orders/order-history-header.tsx +14 -4
- package/src/pages/account/orders/order-history-root.tsx +3 -1
- package/src/pages/account/orders/order-history-row.tsx +12 -4
- package/src/pages/account/orders/order-history-search-and-filter.tsx +88 -59
- package/src/pages/account/orders/order-history-search-dropdown.tsx +26 -9
- package/src/pages/account/orders/order-history-sort.tsx +3 -1
- package/src/pages/account/orders/order-history-table.tsx +27 -5
- package/src/pages/account/orders/order-progress.tsx +12 -6
- package/src/pages/account/orders/order-row.tsx +18 -6
- package/src/pages/account/orders/order-summary.tsx +24 -8
- package/src/pages/account/orders/ordered-products.tsx +15 -5
- package/src/pages/account/profile/user-info.tsx +11 -3
- package/src/pages/account/table-row-skeleton.tsx +1 -1
- package/src/pages/account/wishlist/create-new-list.tsx +33 -9
- package/src/pages/account/wishlist/wishlist-item.tsx +18 -6
- package/src/pages/cart/cart-item.tsx +21 -7
- package/src/pages/cart/checkout-form.tsx +55 -22
- package/src/pages/cart/coupon-entry.tsx +143 -36
- package/src/pages/cart/estimate-shipping.tsx +45 -21
- package/src/pages/checkout/checkout-alt-form/checkout-form.tsx +22 -14
- package/src/pages/checkout/checkout-alt-form/checkout-step.tsx +37 -16
- package/src/pages/checkout/checkout-alt-form/steps/address/address-card.tsx +9 -3
- package/src/pages/checkout/checkout-alt-form/steps/address/delivery-address.tsx +84 -51
- package/src/pages/checkout/checkout-alt-form/steps/address/new-address-form.tsx +41 -19
- package/src/pages/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx +17 -10
- package/src/pages/checkout/checkout-alt-form/steps/payment/payment-details.tsx +15 -6
- package/src/pages/checkout/checkout-alt-form/steps/shipping/delivery-options.tsx +6 -2
- package/src/pages/checkout/checkout-alt-summary/cart-item.tsx +12 -4
- package/src/pages/checkout/checkout-alt-summary/checkout-alt-summary.tsx +12 -5
- package/src/pages/checkout/checkout-alt-summary/list-item.tsx +17 -10
- package/src/pages/confirmation/address.tsx +6 -2
- package/src/pages/confirmation/confirmation-summary.tsx +12 -4
- package/src/pages/confirmation/ordered-products.tsx +12 -4
- package/src/pages/product-details/bopis/store-card/shop-card.tsx +2 -2
- package/src/pages/product-details/bopis/store-card/utils/getDaysResources.ts +1 -1
- package/src/pages/product-details/product-intro/compound/product-info.tsx +41 -18
- package/src/pages/product-details/product-intro/compound/product-intro-images.tsx +18 -12
- package/src/pages/product-details/product-intro/compound/product-intro.tsx +20 -10
- package/src/pages/product-details/product-intro/compound/thumbnail-with-skeleton.tsx +1 -1
- package/src/pages/product-details/product-tabs.tsx +20 -12
- package/src/pages/product-list/product-list-view.tsx +4 -2
- package/src/pages/product-list/search-bar.tsx +7 -7
- package/src/pages/product-list/side-nav.tsx +5 -3
- package/src/pages/quickorder/order-upload.tsx +1 -1
- package/src/pages/quickorder/provider.tsx +26 -14
- package/src/pages/quickorder/quick-order.tsx +49 -22
- package/src/providers/nav-provider/index.tsx +16 -11
- package/tsconfig.json +0 -5
- package/src/components/header/components/user.tsx +0 -322
- /package/src/components/{header → user}/__tests__/user.test.tsx +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @evenicanpm/storefront-core
|
|
2
2
|
|
|
3
|
+
## 2.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @evenicanpm/cms@2.5.1
|
|
8
|
+
- @evenicanpm/ui@2.5.1
|
|
9
|
+
|
|
10
|
+
## 2.5.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @evenicanpm/cms@2.5.0
|
|
15
|
+
- @evenicanpm/ui@2.5.0
|
|
16
|
+
|
|
3
17
|
## 2.4.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
2
|
+
"name": "@evenicanpm/storefront-core",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Core module for D365/e4 Headless Storefront",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"docs": "typedoc",
|
|
9
|
+
"storybook": "storybook dev -p 6006",
|
|
10
|
+
"build-storybook": "storybook build"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./index.js",
|
|
14
|
+
"./*": "./*"
|
|
15
|
+
},
|
|
16
|
+
"author": "Evenica",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@evenicanpm/cms": "workspace:*",
|
|
20
|
+
"@evenicanpm/ui": "workspace:*",
|
|
21
|
+
"react-dropzone": "^14.3.8",
|
|
22
|
+
"react-slick": "^0.30.1",
|
|
23
|
+
"slick-carousel": "^1.8.1",
|
|
24
|
+
"strapi-sdk-js": "^3.0.0",
|
|
25
|
+
"clsx": "^2.1.1",
|
|
26
|
+
"react-icons": "^5.4.0",
|
|
27
|
+
"simplebar-react": "^3.3.0",
|
|
28
|
+
"formik": "^2.4.6",
|
|
29
|
+
"formik-validator-zod": "^2.0.1",
|
|
30
|
+
"currency.js": "^2.0.4",
|
|
31
|
+
"@hookform/resolvers": "^3.9.0",
|
|
32
|
+
"react-hook-form": "^7.53.0",
|
|
33
|
+
"yup": "^1.3.3",
|
|
34
|
+
"nuqs": "^2.8.9"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@emotion/react": "catalog:",
|
|
38
|
+
"@emotion/styled": "catalog:",
|
|
39
|
+
"@mui/icons-material": "catalog:",
|
|
40
|
+
"@mui/material": "catalog:",
|
|
41
|
+
"@mui/types": "catalog:",
|
|
42
|
+
"@mui/system": "catalog:",
|
|
43
|
+
"@storybook/addon-docs": "^9.1.6",
|
|
44
|
+
"@storybook/addon-webpack5-compiler-swc": "^4.0.1",
|
|
45
|
+
"@storybook/nextjs": "^9.1.6",
|
|
46
|
+
"@storybook/react": "^9.1.6",
|
|
47
|
+
"@storybook/react-webpack5": "^9.1.6",
|
|
48
|
+
"@types/jsonwebtoken": "^9.0.9",
|
|
49
|
+
"@types/lodash": "^4.17.17",
|
|
50
|
+
"@types/node": "^22.15.20",
|
|
51
|
+
"@types/object-mapper": "^6.2.2",
|
|
52
|
+
"@types/react": "catalog:",
|
|
53
|
+
"@types/react-dom": "catalog:",
|
|
54
|
+
"react": "catalog:",
|
|
55
|
+
"react-dom": "catalog:",
|
|
56
|
+
"storybook": "^9.1.6"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@emotion/react": "catalog:",
|
|
60
|
+
"@emotion/styled": "catalog:",
|
|
61
|
+
"@msdyn365-commerce/retail-proxy": "9.50",
|
|
62
|
+
"@mui/icons-material": "catalog:",
|
|
63
|
+
"@mui/material": "catalog:",
|
|
64
|
+
"@mui/system": "catalog:",
|
|
65
|
+
"@opentelemetry/api": "^1.9.1",
|
|
66
|
+
"@strapi/blocks-react-renderer": "^1.0.1",
|
|
67
|
+
"@tanstack/react-query": "catalog:",
|
|
68
|
+
"@tanstack/query-core": "catalog:",
|
|
69
|
+
"better-auth": "catalog:",
|
|
70
|
+
"graphql": "^16.11.0",
|
|
71
|
+
"graphql-request": "^7.1.2",
|
|
72
|
+
"jsonwebtoken": "^9.0.2",
|
|
73
|
+
"lodash": "^4.17.21",
|
|
74
|
+
"next": "catalog:",
|
|
75
|
+
"next-intl": "catalog:",
|
|
76
|
+
"object-mapper": "^6.2.0",
|
|
77
|
+
"pg": "^8.8.0",
|
|
78
|
+
"react": "catalog:",
|
|
79
|
+
"react-dom": "catalog:",
|
|
80
|
+
"set-cookie-parser": "^2.7.1",
|
|
81
|
+
"typedoc": "^0.28.9",
|
|
82
|
+
"typedoc-plugin-merge-modules": "^7.0.0",
|
|
83
|
+
"typescript": "^5.8.3",
|
|
84
|
+
"zod": "^3.25.25"
|
|
85
|
+
},
|
|
86
|
+
"overrides": {
|
|
87
|
+
"@storybook/builder-manager": {
|
|
88
|
+
"esbuild": "0.19.11"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -21,15 +21,16 @@ function serializeError(error: unknown): string {
|
|
|
21
21
|
for (const key of allKeys) {
|
|
22
22
|
if (key !== "constructor") {
|
|
23
23
|
try {
|
|
24
|
-
|
|
25
|
-
result[key] = (value as any)[key];
|
|
24
|
+
result[key] = value[key];
|
|
26
25
|
} catch {}
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
return Object.keys(result).length ? result : value;
|
|
30
29
|
});
|
|
31
30
|
} catch {
|
|
32
|
-
|
|
31
|
+
if (error instanceof Error) return error.message;
|
|
32
|
+
if (typeof error === "string") return error;
|
|
33
|
+
return "Unable to serialize error";
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -67,10 +67,10 @@ function extractEmailFromClaims(token: IdTokenClaims): string | undefined {
|
|
|
67
67
|
|
|
68
68
|
function decodeIdTokenClaims(token: string): IdTokenClaims {
|
|
69
69
|
const decoded = jwt.decode(token);
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
70
|
+
if (decoded && typeof decoded === "object") {
|
|
71
|
+
return decoded;
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return {};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const tracer = trace.getTracer("d365-user-datasource");
|
|
@@ -74,6 +74,7 @@ export async function getContextFromCookie(): Promise<ICallerContext> {
|
|
|
74
74
|
token: accessToken,
|
|
75
75
|
};
|
|
76
76
|
context.requestContext.locale = locale;
|
|
77
|
+
context.requestContext.apiSettings.catalogId = 0;
|
|
77
78
|
return context;
|
|
78
79
|
}
|
|
79
80
|
throw new Error("D365Context cookie not found");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { addressMap } from "@evenicanpm/storefront-core/src/api-manager/datasources/e4/address/e4-address.remaps";
|
|
2
2
|
import * as addressTranslator from "@evenicanpm/storefront-core/src/api-manager/datasources/e4/address/e4-address.translator";
|
|
3
|
-
import type { Shipping } from "@evenicanpm/storefront-core/src/api-manager/datasources/e4/graphqlRequestSdk";
|
|
4
3
|
import getGraphqlClient from "@evenicanpm/storefront-core/src/api-manager/lib/get-graphql-client";
|
|
5
4
|
import type {
|
|
6
5
|
Address,
|
|
@@ -57,7 +56,9 @@ const address = {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
return addressTranslator.deliveryOptionsTransformValidate(
|
|
60
|
-
(data?.shippingbyCarrier
|
|
59
|
+
(data?.shippingbyCarrier ?? []).filter(
|
|
60
|
+
(s): s is NonNullable<typeof s> => s !== null,
|
|
61
|
+
),
|
|
61
62
|
) as DeliveryOption[];
|
|
62
63
|
},
|
|
63
64
|
async createAddress(address: Address): Promise<Address> {
|
|
@@ -70,12 +71,7 @@ const address = {
|
|
|
70
71
|
throw new Error("Error creating address");
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
return (
|
|
74
|
-
merge(
|
|
75
|
-
[data?.createAddress],
|
|
76
|
-
addressMap as unknown as Address[],
|
|
77
|
-
) as Address[]
|
|
78
|
-
)[0];
|
|
74
|
+
return (merge([data?.createAddress], addressMap) as Address[])[0];
|
|
79
75
|
},
|
|
80
76
|
async updateAddress(address: Address): Promise<Address> {
|
|
81
77
|
const e4Api = await getGraphqlClient(true);
|
|
@@ -87,12 +83,7 @@ const address = {
|
|
|
87
83
|
throw new Error("Error updating address");
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
return (
|
|
91
|
-
merge(
|
|
92
|
-
[data?.updateAddress],
|
|
93
|
-
addressMap as unknown as Address[],
|
|
94
|
-
) as Address[]
|
|
95
|
-
)[0];
|
|
86
|
+
return (merge([data?.updateAddress], addressMap) as Address[])[0];
|
|
96
87
|
},
|
|
97
88
|
async deleteAddress(addressId: string): Promise<string> {
|
|
98
89
|
const e4Api = await getGraphqlClient(true);
|
|
@@ -47,8 +47,9 @@ export const getCountryId = async (code: string) => {
|
|
|
47
47
|
} else {
|
|
48
48
|
const e4Api = await getGraphqlClient();
|
|
49
49
|
const { data } = await e4Api.e4CountryList();
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const fetchedCountries = data?.countries ?? [];
|
|
51
|
+
countriesCache.set(cacheKey, fetchedCountries);
|
|
52
|
+
countries = fetchedCountries;
|
|
52
53
|
}
|
|
53
54
|
const country = countries.find(
|
|
54
55
|
(c: { isoAlpha3Code: string }) => c?.isoAlpha3Code === code,
|
|
@@ -71,7 +72,7 @@ const getStateId = async (stateCode: string, countryId: string) => {
|
|
|
71
72
|
} else {
|
|
72
73
|
const e4Api = await getGraphqlClient();
|
|
73
74
|
const { data } = await e4Api.e4Country({ id: countryId });
|
|
74
|
-
country = data?.country
|
|
75
|
+
country = data?.country ?? country;
|
|
75
76
|
countryCache.set(cacheKey, country);
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -5430,7 +5430,9 @@ export type Process = {
|
|
|
5430
5430
|
};
|
|
5431
5431
|
|
|
5432
5432
|
export type ProcessConfigMerge = {
|
|
5433
|
-
|
|
5433
|
+
sourceConfig?: InputMaybe<ConfigMerge>;
|
|
5434
|
+
targetConfig?: InputMaybe<ConfigMerge>;
|
|
5435
|
+
targetSourcesConfig?: InputMaybe<ConfigMerge>;
|
|
5434
5436
|
};
|
|
5435
5437
|
|
|
5436
5438
|
export type ProcessConnection = {
|
|
@@ -5811,6 +5813,7 @@ export type ProcessTask = {
|
|
|
5811
5813
|
__typename?: 'ProcessTask';
|
|
5812
5814
|
code?: Maybe<Scalars['String']['output']>;
|
|
5813
5815
|
created: Scalars['DateTime']['output'];
|
|
5816
|
+
directionTypeId?: Maybe<Scalars['Int']['output']>;
|
|
5814
5817
|
endpoint?: Maybe<Endpoint>;
|
|
5815
5818
|
executionProcedure?: Maybe<Scalars['String']['output']>;
|
|
5816
5819
|
extendedFields?: Maybe<Scalars['JSON']['output']>;
|
|
@@ -5825,6 +5828,7 @@ export type ProcessTask = {
|
|
|
5825
5828
|
preExecutionProcedure?: Maybe<Scalars['String']['output']>;
|
|
5826
5829
|
process: Process;
|
|
5827
5830
|
processTaskType?: Maybe<ProcessTaskType>;
|
|
5831
|
+
processTemplateId?: Maybe<Scalars['ID']['output']>;
|
|
5828
5832
|
properties?: Maybe<Scalars['JSON']['output']>;
|
|
5829
5833
|
sort?: Maybe<Scalars['Int']['output']>;
|
|
5830
5834
|
};
|
|
@@ -5889,6 +5893,7 @@ export type ProcessTaskExecution = {
|
|
|
5889
5893
|
|
|
5890
5894
|
export type ProcessTaskExport = {
|
|
5891
5895
|
__typename?: 'ProcessTaskExport';
|
|
5896
|
+
DirectionTypeId?: Maybe<Scalars['Int']['output']>;
|
|
5892
5897
|
Endpoint?: Maybe<Scalars['String']['output']>;
|
|
5893
5898
|
Name?: Maybe<Scalars['String']['output']>;
|
|
5894
5899
|
OrchestrationType?: Maybe<Scalars['String']['output']>;
|
|
@@ -5899,10 +5904,12 @@ export type ProcessTaskExport = {
|
|
|
5899
5904
|
ProcessTask?: Maybe<Scalars['String']['output']>;
|
|
5900
5905
|
ProcessTaskId?: Maybe<Scalars['ID']['output']>;
|
|
5901
5906
|
ProcessTaskType?: Maybe<Scalars['String']['output']>;
|
|
5907
|
+
ProcessTemplateId?: Maybe<Scalars['Int']['output']>;
|
|
5902
5908
|
Sort?: Maybe<Scalars['Int']['output']>;
|
|
5903
5909
|
};
|
|
5904
5910
|
|
|
5905
5911
|
export type ProcessTaskImport = {
|
|
5912
|
+
DirectionTypeId?: InputMaybe<Scalars['Int']['input']>;
|
|
5906
5913
|
Endpoint?: InputMaybe<Scalars['String']['input']>;
|
|
5907
5914
|
Name?: InputMaybe<Scalars['String']['input']>;
|
|
5908
5915
|
OrchestrationType?: InputMaybe<Scalars['String']['input']>;
|
|
@@ -5913,6 +5920,7 @@ export type ProcessTaskImport = {
|
|
|
5913
5920
|
ProcessTask?: InputMaybe<Scalars['String']['input']>;
|
|
5914
5921
|
ProcessTaskId?: InputMaybe<Scalars['ID']['input']>;
|
|
5915
5922
|
ProcessTaskType?: InputMaybe<Scalars['String']['input']>;
|
|
5923
|
+
ProcessTemplateId?: InputMaybe<Scalars['ID']['input']>;
|
|
5916
5924
|
Properties?: InputMaybe<Scalars['JSON']['input']>;
|
|
5917
5925
|
Sort?: InputMaybe<Scalars['Int']['input']>;
|
|
5918
5926
|
};
|
|
@@ -6009,8 +6017,10 @@ export type ProcessTaskUpdate = {
|
|
|
6009
6017
|
export type ProcessTemplate = {
|
|
6010
6018
|
__typename?: 'ProcessTemplate';
|
|
6011
6019
|
created: Scalars['DateTime']['output'];
|
|
6020
|
+
directionTypeId?: Maybe<Scalars['Int']['output']>;
|
|
6012
6021
|
id: Scalars['ID']['output'];
|
|
6013
6022
|
isActive?: Maybe<Scalars['Boolean']['output']>;
|
|
6023
|
+
mappings?: Maybe<Array<Maybe<ProcessTemplateInputMapping>>>;
|
|
6014
6024
|
modified: Scalars['DateTime']['output'];
|
|
6015
6025
|
name?: Maybe<Scalars['String']['output']>;
|
|
6016
6026
|
pages?: Maybe<Array<Maybe<ProcessTemplatePage>>>;
|
|
@@ -6024,8 +6034,8 @@ export type ProcessTemplateConnection = {
|
|
|
6024
6034
|
};
|
|
6025
6035
|
|
|
6026
6036
|
export type ProcessTemplateFilter = {
|
|
6027
|
-
|
|
6028
|
-
|
|
6037
|
+
sourceTemplateId?: InputMaybe<Scalars['ID']['input']>;
|
|
6038
|
+
targetTemplateId?: InputMaybe<Scalars['ID']['input']>;
|
|
6029
6039
|
};
|
|
6030
6040
|
|
|
6031
6041
|
export type ProcessTemplateGroup = {
|
|
@@ -6063,6 +6073,15 @@ export type ProcessTemplateInput = {
|
|
|
6063
6073
|
validationRegex?: Maybe<Scalars['String']['output']>;
|
|
6064
6074
|
};
|
|
6065
6075
|
|
|
6076
|
+
export type ProcessTemplateInputMapping = {
|
|
6077
|
+
__typename?: 'ProcessTemplateInputMapping';
|
|
6078
|
+
fieldName?: Maybe<Scalars['String']['output']>;
|
|
6079
|
+
format?: Maybe<Scalars['String']['output']>;
|
|
6080
|
+
inputTypeCode?: Maybe<Scalars['String']['output']>;
|
|
6081
|
+
jsonPath?: Maybe<Scalars['String']['output']>;
|
|
6082
|
+
jsonValuePath?: Maybe<Scalars['String']['output']>;
|
|
6083
|
+
};
|
|
6084
|
+
|
|
6066
6085
|
export type ProcessTemplateInputSchema = {
|
|
6067
6086
|
__typename?: 'ProcessTemplateInputSchema';
|
|
6068
6087
|
defaultValue?: Maybe<Scalars['String']['output']>;
|
|
@@ -6629,6 +6648,7 @@ export type Query = {
|
|
|
6629
6648
|
processTasksByProcess?: Maybe<ProcessTaskConnection>;
|
|
6630
6649
|
processTemplate?: Maybe<Array<Maybe<ProcessTemplate>>>;
|
|
6631
6650
|
processTemplateGroups?: Maybe<ProcessTemplateGroupConnection>;
|
|
6651
|
+
processTemplateInputMappings?: Maybe<Array<Maybe<ProcessTemplateInputMapping>>>;
|
|
6632
6652
|
processTemplateRecords?: Maybe<ProcessTemplateRecordConnection>;
|
|
6633
6653
|
processTemplates?: Maybe<ProcessTemplateConnection>;
|
|
6634
6654
|
processes?: Maybe<ProcessConnection>;
|
|
@@ -7529,12 +7549,18 @@ export type QueryProcessTemplateGroupsArgs = {
|
|
|
7529
7549
|
};
|
|
7530
7550
|
|
|
7531
7551
|
|
|
7552
|
+
export type QueryProcessTemplateInputMappingsArgs = {
|
|
7553
|
+
processTemplateId?: InputMaybe<Scalars['Int']['input']>;
|
|
7554
|
+
};
|
|
7555
|
+
|
|
7556
|
+
|
|
7532
7557
|
export type QueryProcessTemplateRecordsArgs = {
|
|
7533
7558
|
input?: InputMaybe<FilterQueryInput>;
|
|
7534
7559
|
};
|
|
7535
7560
|
|
|
7536
7561
|
|
|
7537
7562
|
export type QueryProcessTemplatesArgs = {
|
|
7563
|
+
directionTypeId?: InputMaybe<Scalars['ID']['input']>;
|
|
7538
7564
|
input?: InputMaybe<FilterQueryInput>;
|
|
7539
7565
|
};
|
|
7540
7566
|
|
package/src/api-manager/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ async function createApiManager(): Promise<Datasource> {
|
|
|
60
60
|
|
|
61
61
|
if (datasource[entityName]) {
|
|
62
62
|
// Merge override methods into the existing entity
|
|
63
|
-
Object.assign(datasource[entityName]
|
|
63
|
+
Object.assign(datasource[entityName], entityOverrides);
|
|
64
64
|
} else {
|
|
65
65
|
// Non-core entity added entirely from overrides
|
|
66
66
|
// biome-ignore lint: api datasources should not be typed
|
|
@@ -36,7 +36,7 @@ const getGraphQLClient = async (withAuth = false) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const cookieStore = await cookies();
|
|
39
|
-
const sessionCookie = cookieStore.get("storefront"); // cookie is set in
|
|
39
|
+
const sessionCookie = cookieStore.get("storefront"); // cookie is set in proxy - setE4SessionCookies
|
|
40
40
|
// This session cookie solution only works when all api calls are through server actions.
|
|
41
41
|
// If not we need to route all e4 client api calls through an custom api route.
|
|
42
42
|
if (sessionCookie) {
|
|
@@ -5,27 +5,16 @@ import type {
|
|
|
5
5
|
import getCart from "@evenicanpm/storefront-core/src/api-manager/services/cart/queries/get-cart";
|
|
6
6
|
import { useCreateMutation } from "@evenicanpm/storefront-core/src/api-manager/services/create-mutation";
|
|
7
7
|
import { createApiPath } from "@evenicanpm/storefront-core/src/api-manager/services/create-query";
|
|
8
|
-
import { useNotification } from "@evenicanpm/storefront-core/src/providers/notifications/use-notification";
|
|
9
8
|
import { useQueryClient } from "@tanstack/react-query";
|
|
10
|
-
import { useTranslations } from "next-intl";
|
|
11
9
|
|
|
12
10
|
const apiPath = createApiPath("cart", "addDiscountCode");
|
|
13
11
|
|
|
14
12
|
const useAddDiscountCode = () => {
|
|
15
13
|
const queryClient = useQueryClient();
|
|
16
|
-
const { setNotification } = useNotification();
|
|
17
|
-
const t = useTranslations("Cart.Messages");
|
|
18
14
|
return useCreateMutation<ManageDiscountCodeInput, Cart>(apiPath, {
|
|
19
15
|
onSuccess: (result) => {
|
|
20
16
|
getCart.setQueryData(queryClient, result);
|
|
21
17
|
},
|
|
22
|
-
onError: () => {
|
|
23
|
-
setNotification({
|
|
24
|
-
message: t("couponError"),
|
|
25
|
-
severity: "error",
|
|
26
|
-
type: "cart",
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
18
|
});
|
|
30
19
|
};
|
|
31
20
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import createApiManager from "@evenicanpm/storefront-core/src/api-manager/index";
|
|
2
2
|
import type { DatasourceApis } from "@evenicanpm/storefront-core/src/api-manager/types/Datasource";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type DefaultError,
|
|
5
|
+
isServer,
|
|
6
|
+
type QueryClient,
|
|
7
|
+
} from "@tanstack/query-core";
|
|
4
8
|
import {
|
|
5
9
|
type UseQueryResult,
|
|
6
10
|
type UseSuspenseQueryResult,
|
|
@@ -104,12 +108,14 @@ export const createQuery = <TInput, TOutput>(
|
|
|
104
108
|
return {
|
|
105
109
|
useData: (
|
|
106
110
|
input?: TInput,
|
|
107
|
-
|
|
108
|
-
): UseQueryResult<TOutput> =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...
|
|
112
|
-
|
|
111
|
+
queryOptions?: { enabled?: boolean },
|
|
112
|
+
): UseQueryResult<NoInfer<TOutput>, DefaultError> => {
|
|
113
|
+
const baseOptions = getQueryOptions(input);
|
|
114
|
+
return useQuery({
|
|
115
|
+
...baseOptions,
|
|
116
|
+
enabled: baseOptions.enabled && (queryOptions?.enabled ?? true),
|
|
117
|
+
});
|
|
118
|
+
},
|
|
113
119
|
useSuspenseData: (input?: TInput): UseSuspenseQueryResult<TOutput> =>
|
|
114
120
|
useSuspenseQuery(getQueryOptions(input)),
|
|
115
121
|
fetchData: (queryClient: QueryClient, input?: TInput) =>
|
|
@@ -24,7 +24,7 @@ const useAddToWishlist = () => {
|
|
|
24
24
|
// Based on Tanstack Optimistic Update Pattern
|
|
25
25
|
// https://tanstack.com/query/latest/docs/reference/QueryClient
|
|
26
26
|
await queryClient.cancelQueries({ queryKey: [getWishlistsQueryKey] });
|
|
27
|
-
const previousWishlists =
|
|
27
|
+
const previousWishlists = getWishlists.getData(queryClient);
|
|
28
28
|
const optimisticData = previousWishlists?.map((list) => {
|
|
29
29
|
if (list.Id === input.Id) {
|
|
30
30
|
// Add the input product line to list
|
|
@@ -25,7 +25,7 @@ const useRemoveFromWishlist = () => {
|
|
|
25
25
|
// Based on Tanstack Optimistic Update Pattern
|
|
26
26
|
// https://tanstack.com/query/latest/docs/reference/QueryClient
|
|
27
27
|
await queryClient.cancelQueries({ queryKey: [getWishlistsQueryKey] });
|
|
28
|
-
const previousWishlists =
|
|
28
|
+
const previousWishlists = getWishlists.getData(queryClient);
|
|
29
29
|
const optimisticData = previousWishlists?.map((list) => {
|
|
30
30
|
if (list.Id === input.Id) {
|
|
31
31
|
// Remove the product line of our input id
|