@evenicanpm/storefront-core 2.3.1 → 2.4.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 +17 -0
- package/package.json +42 -9
- package/src/api-manager/datasources/d365/d365-address.datasource.ts +148 -61
- package/src/api-manager/datasources/d365/d365-cart.datasource.ts +23 -1
- package/src/api-manager/datasources/d365/d365-order.datasource.ts +6 -1
- package/src/api-manager/datasources/d365/d365-user.datasource.ts +109 -37
- package/src/api-manager/datasources/d365/utils/get-context-cookie.ts +44 -10
- package/src/api-manager/index.ts +2 -1
- package/src/api-manager/lib/get-graphql-client.ts +35 -7
- package/src/api-manager/schemas/product.schema.ts +1 -1
- package/src/api-manager/services/create-query.ts +36 -3
- package/src/api-manager/services/get-query-client.ts +10 -0
- package/src/auth/better-auth.ts +282 -15
- package/src/cms/blocks/block-manager.tsx +1 -1
- package/src/cms/blocks/components/product-section-fullwidth/index.tsx +3 -1
- package/src/cms/endpoints.ts +7 -2
- package/src/components/BazaarMenu.tsx +1 -1
- package/src/components/Typography.tsx +4 -2
- package/src/components/carousel-cards/carousel-card-1/CarouselCard1.stories.tsx +1 -1
- package/src/components/categories/category-list/category-list.tsx +9 -5
- package/src/components/categories/category-menu.tsx +1 -1
- package/src/components/countries-input.tsx +4 -0
- package/src/components/header/__tests__/user.test.tsx +5 -107
- package/src/components/header/components/user.tsx +72 -45
- package/src/components/header/sticky-header.tsx +0 -1
- package/src/components/navbar/mobile-menu/mobile-menu.test.tsx +1 -1
- package/src/components/navbar/utils/transform-nav.test.ts +1 -1
- package/src/components/navbar/utils/transform-nav.ts +1 -1
- package/src/components/product-cards/product-card/product-card.tsx +5 -2
- package/src/components/product-cards/product-card/styles/index.ts +1 -5
- package/src/components/products-view/compound/products-grid-view.tsx +5 -1
- package/src/components/products-view/compound/products-list-view.tsx +5 -1
- package/src/global.d.ts +3 -0
- package/src/hooks/use-nextauth-session.ts +0 -33
- package/src/lib/auth-client.ts +14 -0
- package/src/lib/auth.ts +4 -0
- package/src/lib/entra-native-auth.ts +138 -0
- package/src/lib/native-session.ts +434 -0
- package/src/pages/account/addresses/address-form.tsx +20 -2
- package/src/pages/account/profile/__tests__/profile-form.test.tsx +173 -0
- package/src/pages/account/profile/profile-form.tsx +285 -0
- package/src/pages/account/profile/profile-validation.ts +52 -0
- package/src/pages/account/wishlist/wishlist-item.tsx +1 -2
- package/src/pages/auth/auth-activate-page.tsx +509 -0
- package/src/pages/auth/auth-layout.tsx +73 -0
- package/src/pages/auth/auth-login-page.tsx +241 -0
- package/src/pages/auth/auth-reset-password-page.tsx +487 -0
- package/src/pages/auth/compound/auth-form.tsx +182 -0
- package/src/pages/auth/compound/auth-pages.tsx +21 -0
- package/src/pages/auth/lib/friendly-error.ts +70 -0
- package/src/pages/auth/lib/index.ts +2 -0
- package/src/pages/auth/lib/types.ts +5 -0
- package/src/pages/cart/cart-item.tsx +1 -7
- package/src/pages/checkout/checkout-alt-form/checkout-form.tsx +14 -3
- package/src/pages/checkout/checkout-alt-form/steps/address/address-card.tsx +5 -3
- package/src/pages/checkout/checkout-alt-form/steps/address/delivery-address.tsx +20 -6
- package/src/pages/checkout/checkout-alt-form/steps/address/new-address-form.tsx +1 -1
- package/src/pages/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx +1 -1
- package/src/pages/confirmation/ordered-products.tsx +3 -1
- package/src/pages/product-details/bopis/find-in-store-modal.tsx +4 -4
- package/src/pages/product-details/bopis/pickup-option-select.tsx +2 -2
- package/src/pages/product-details/bopis/search-header.tsx +2 -2
- package/src/pages/product-details/product-intro/compound/context.ts +8 -3
- package/src/pages/product-details/product-intro/compound/product-info.tsx +25 -19
- package/src/pages/product-list/product-list-view.tsx +2 -1
- package/src/providers/nav-provider/index.tsx +1 -1
- package/src/providers/nav-provider/utils/createLink.ts +1 -1
- package/tsconfig.json +20 -15
- package/__mocks__/countries.ts +0 -11
- package/__mocks__/create-mutation.ts +0 -68
- package/__mocks__/create-query.ts +0 -94
- package/__mocks__/data/categories.json +0 -795
- package/__mocks__/get-product-by-id.ts +0 -6
- package/__mocks__/next-auth-react.ts +0 -9
- package/__mocks__/next-font.js +0 -4
- package/__mocks__/next-headers.js +0 -13
- package/__mocks__/next-image.tsx +0 -18
- package/__mocks__/next-link.js +0 -19
- package/__mocks__/next-navigation.ts +0 -29
- package/__mocks__/product-dimensions.ts +0 -635
- package/__mocks__/products.ts +0 -533
- package/__mocks__/query-client.ts +0 -3
- package/__mocks__/wishlists.json +0 -408
- package/src/auth/msal.ts +0 -68
- package/src/cms/blog.ts +0 -229
- package/src/cms/interfaces/navigation.ts +0 -52
- package/src/cms/interfaces/product-data.ts +0 -83
- package/src/cms/pages.ts +0 -149
- package/src/pages/account/profile/profile-button.test.tsx +0 -59
- package/src/pages/account/profile/profile-button.tsx +0 -51
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import type { CmsNavItem } from "@evenicanpm/cms/src/content/navigation/types";
|
|
2
3
|
import type { CategoryHierarchy } from "@evenicanpm/storefront-core/src/lib/category-helpers";
|
|
3
4
|
import { createLink } from "@evenicanpm/storefront-core/src/providers/nav-provider/utils/createLink";
|
|
4
5
|
import { useTranslations } from "next-intl";
|
|
5
6
|
import { createContext, type PropsWithChildren, useState } from "react";
|
|
6
|
-
import type { CmsNavItem } from "@/cms/interfaces/navigation";
|
|
7
7
|
|
|
8
8
|
type NavContextType = {
|
|
9
9
|
cmsNav: CmsNavItem[];
|
package/tsconfig.json
CHANGED
|
@@ -7,26 +7,31 @@
|
|
|
7
7
|
"esModuleInterop": true,
|
|
8
8
|
"skipLibCheck": true,
|
|
9
9
|
"declaration": true,
|
|
10
|
-
"moduleResolution": "
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
11
|
"resolveJsonModule": true,
|
|
12
12
|
"outDir": "./dist",
|
|
13
|
+
"rootDir": "./src",
|
|
13
14
|
"jsx": "preserve",
|
|
14
|
-
"typeRoots": ["../../../../storefront/node_modules/@types"],
|
|
15
15
|
"paths": {
|
|
16
|
-
"
|
|
16
|
+
"@evenicanpm/cms/src/*": ["../cms/src/*"],
|
|
17
17
|
"@evenicanpm/storefront-core/src/*": ["./src/*"],
|
|
18
|
-
"@evenicanpm/storefront-core/src/lib/*": ["src/lib/*"],
|
|
19
|
-
"@evenicanpm/storefront-core/src/api-manager/*": ["src/api-manager/*"],
|
|
20
|
-
"@evenicanpm/storefront-core/src/components/*": ["src/components/*"],
|
|
21
|
-
"@/auth/*": ["src/auth/*"],
|
|
22
|
-
"@/_components/*": ["src/components/_components/*"],
|
|
23
|
-
"@/components/*": ["src/components/*"],
|
|
24
|
-
"@/cms/*": ["src/cms/*"],
|
|
25
|
-
"@/schemas/*": ["src/api-manager/schemas/*"],
|
|
26
|
-
"@/services/*": ["src/api-manager/services/*"],
|
|
27
|
-
"@evenicanpm/storefront-core/src/hooks/*": ["src/hooks/*"],
|
|
28
|
-
"@config": ["src/config"],
|
|
29
|
-
"@messages/*": ["../../../../storefront/messages/*"]
|
|
18
|
+
"@evenicanpm/storefront-core/src/lib/*": ["./src/lib/*"],
|
|
19
|
+
"@evenicanpm/storefront-core/src/api-manager/*": ["./src/api-manager/*"],
|
|
20
|
+
"@evenicanpm/storefront-core/src/components/*": ["./src/components/*"],
|
|
21
|
+
"@/auth/*": ["./src/auth/*"],
|
|
22
|
+
"@/_components/*": ["./src/components/_components/*"],
|
|
23
|
+
"@/components/*": ["./src/components/*"],
|
|
24
|
+
"@/cms/*": ["./src/cms/*"],
|
|
25
|
+
"@/schemas/*": ["./src/api-manager/schemas/*"],
|
|
26
|
+
"@/services/*": ["./src/api-manager/services/*"],
|
|
27
|
+
"@evenicanpm/storefront-core/src/hooks/*": ["./src/hooks/*"],
|
|
28
|
+
"@config": ["./src/config"],
|
|
29
|
+
"@messages/*": ["../../../../storefront/messages/*"],
|
|
30
|
+
"*": [
|
|
31
|
+
"../../node_modules/.pnpm/node_modules/*",
|
|
32
|
+
"./node_modules/*",
|
|
33
|
+
"../../apps/storefront/node_modules/*"
|
|
34
|
+
]
|
|
30
35
|
}
|
|
31
36
|
},
|
|
32
37
|
"include": ["src"]
|
package/__mocks__/countries.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CountryRegionInfo } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
-
|
|
3
|
-
export const countries: CountryRegionInfo[] = [
|
|
4
|
-
{ ShortName: "Canada", CountryRegionId: "CA", ISOCode: "CA" },
|
|
5
|
-
{
|
|
6
|
-
ShortName: "United States",
|
|
7
|
-
CountryRegionId: "US",
|
|
8
|
-
ISOCode: "US",
|
|
9
|
-
},
|
|
10
|
-
{ ShortName: "Mexico", CountryRegionId: "MX", ISOCode: "MX" },
|
|
11
|
-
];
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { queryClient } from "./query-client";
|
|
2
|
-
|
|
3
|
-
type MutationInput = {
|
|
4
|
-
cartLine?: Array<{ Quantity?: number }>;
|
|
5
|
-
} & Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
type CartMockData = {
|
|
8
|
-
CartLines: Array<Record<string, unknown>>;
|
|
9
|
-
} & Record<string, unknown>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* Mocking up at the react-query level because our components
|
|
14
|
-
* rely on react-query for triggering re-renders and state subscriptions.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export const useCreateMutation = (apiManagerPath: readonly unknown[]) => {
|
|
18
|
-
switch (apiManagerPath[1]) {
|
|
19
|
-
case "updateCartLines":
|
|
20
|
-
return {
|
|
21
|
-
mutate: (input: MutationInput) => {
|
|
22
|
-
console.log(input);
|
|
23
|
-
queryClient.setQueryData(["cart"], (oldData: CartMockData) => ({
|
|
24
|
-
...oldData,
|
|
25
|
-
CartLines: [
|
|
26
|
-
{
|
|
27
|
-
...oldData.CartLines[0],
|
|
28
|
-
Quantity: input.cartLine?.[0]?.Quantity,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
}));
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
case "deleteCartLine":
|
|
35
|
-
return {
|
|
36
|
-
mutate: (input: MutationInput) => {
|
|
37
|
-
console.log(input);
|
|
38
|
-
queryClient.setQueryData(["cart"], (oldData: CartMockData) => ({
|
|
39
|
-
...oldData,
|
|
40
|
-
CartLines: [],
|
|
41
|
-
}));
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
case "addToCart":
|
|
45
|
-
return {
|
|
46
|
-
mutate: (input: MutationInput) => {
|
|
47
|
-
console.log(input);
|
|
48
|
-
queryClient.setQueryData(["cart"], (oldData: CartMockData) => ({
|
|
49
|
-
...oldData,
|
|
50
|
-
CartLines: [
|
|
51
|
-
{
|
|
52
|
-
ProductId: 1,
|
|
53
|
-
Quantity: 1,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
}));
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
case "sessionInit":
|
|
60
|
-
return { mutateAsync: () => {} };
|
|
61
|
-
default:
|
|
62
|
-
return {
|
|
63
|
-
mutate: () => {
|
|
64
|
-
console.log("No Mock Implemented");
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import categories from "../__mocks__/data/categories.json";
|
|
3
|
-
import { data as products } from "../__mocks__/products";
|
|
4
|
-
import wishlists from "../__mocks__/wishlists.json";
|
|
5
|
-
|
|
6
|
-
const cartBase = {
|
|
7
|
-
Id: "cart-123",
|
|
8
|
-
Version: 1,
|
|
9
|
-
CartLines: [
|
|
10
|
-
{
|
|
11
|
-
LineId: "line-1",
|
|
12
|
-
ProductId: 1,
|
|
13
|
-
Quantity: 0,
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
const cart = cartBase;
|
|
18
|
-
|
|
19
|
-
const shippingInventoryData = {
|
|
20
|
-
AggregatedProductInventoryAvailabilities: [
|
|
21
|
-
{
|
|
22
|
-
TotalAvailableInventoryLevelCode: "AVAIL",
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Need to mock create query as fn() and then
|
|
28
|
-
// mock the return value in the respective storeies
|
|
29
|
-
// files, per component
|
|
30
|
-
export const createQuery = (apiManagerPath: string[]) => {
|
|
31
|
-
console.log(apiManagerPath);
|
|
32
|
-
if (apiManagerPath[0] === "cart")
|
|
33
|
-
return {
|
|
34
|
-
useData: () => useQuery({ queryKey: ["cart"], queryFn: () => cart }),
|
|
35
|
-
};
|
|
36
|
-
if (apiManagerPath[1] === "getInventory") {
|
|
37
|
-
return {
|
|
38
|
-
useData: () =>
|
|
39
|
-
useQuery({
|
|
40
|
-
queryKey: ["cart", "getInventory"],
|
|
41
|
-
queryFn: () => shippingInventoryData,
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (apiManagerPath[1] === "searchProducts") {
|
|
46
|
-
console.log("here are the products");
|
|
47
|
-
console.log(products.products.length);
|
|
48
|
-
return {
|
|
49
|
-
useData: () =>
|
|
50
|
-
useQuery({
|
|
51
|
-
queryKey: ["product", "searchProducts"],
|
|
52
|
-
queryFn: () => Promise.resolve(products.products),
|
|
53
|
-
}),
|
|
54
|
-
useSuspenseData: () =>
|
|
55
|
-
useQuery({
|
|
56
|
-
queryKey: ["product", "searchProducts"],
|
|
57
|
-
queryFn: () => Promise.resolve(products.products),
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (apiManagerPath[1] === "getWishlists") {
|
|
62
|
-
return {
|
|
63
|
-
useData: () =>
|
|
64
|
-
useQuery({
|
|
65
|
-
queryKey: ["wishlists"],
|
|
66
|
-
queryFn: () => wishlists,
|
|
67
|
-
}),
|
|
68
|
-
useSuspenseData: () =>
|
|
69
|
-
useQuery({
|
|
70
|
-
queryKey: ["wishlists"],
|
|
71
|
-
queryFn: () => wishlists,
|
|
72
|
-
}),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (apiManagerPath[1] === "getCategories") {
|
|
76
|
-
console.log("Here i am!");
|
|
77
|
-
return {
|
|
78
|
-
useData: () =>
|
|
79
|
-
useQuery({
|
|
80
|
-
queryKey: ["categories", "getCategories"],
|
|
81
|
-
queryFn: () => categories,
|
|
82
|
-
}),
|
|
83
|
-
useSuspenseData: () =>
|
|
84
|
-
useQuery({
|
|
85
|
-
queryKey: ["cateogires", "getCategories"],
|
|
86
|
-
queryFn: () => categories,
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const createApiPath = (key: string, method: string) => {
|
|
93
|
-
return [key, method];
|
|
94
|
-
};
|