@evenicanpm/storefront-core 1.0.0-alpha → 1.0.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.
Files changed (78) hide show
  1. package/package.json +1 -1
  2. package/src/api-manager/api-manager.config.json +1 -1
  3. package/src/api-manager/datasources/d365/d365-address.datasource.ts +4 -4
  4. package/src/api-manager/datasources/d365/d365-cart.datasource.ts +100 -7
  5. package/src/api-manager/datasources/d365/d365-product.datasource.ts +39 -17
  6. package/src/api-manager/datasources/d365/d365-user.datasource.ts +220 -49
  7. package/src/api-manager/datasources/d365/utils/decode-jwt.ts +2 -2
  8. package/src/api-manager/datasources/e4/e4-cart.datasource.ts +6 -0
  9. package/src/api-manager/datasources/e4/e4-product.datasource.ts +5 -0
  10. package/src/api-manager/datasources/e4/e4-user.datasource.ts +39 -15
  11. package/src/api-manager/datasources/e4/e4.datasource.ts +1 -0
  12. package/src/api-manager/datasources/e4/e4.translator.ts +2 -1
  13. package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +5231 -38282
  14. package/src/api-manager/index.ts +58 -11
  15. package/src/api-manager/lib/get-graphql-client.ts +7 -7
  16. package/src/api-manager/schemas/address.schema.ts +1 -19
  17. package/src/api-manager/schemas/cart.schema.ts +18 -0
  18. package/src/api-manager/schemas/product.schema.ts +7 -0
  19. package/src/api-manager/schemas/user.schema.ts +52 -1
  20. package/src/api-manager/services/address/queries/get-states.ts +1 -1
  21. package/src/api-manager/services/cart/mutations/checkout.ts +16 -1
  22. package/src/api-manager/services/cart/queries/get-cart-lines-inventory.ts +15 -0
  23. package/src/api-manager/services/create-extension-query.ts +26 -0
  24. package/src/api-manager/services/create-mutation.ts +5 -1
  25. package/src/api-manager/services/create-query.ts +0 -1
  26. package/src/api-manager/services/organization/queries/get-channel-configuration.ts +1 -1
  27. package/src/api-manager/services/product/queries/get-product-prices.ts +16 -0
  28. package/src/api-manager/services/product/queries/search-products.ts +1 -0
  29. package/src/api-manager/services/user/mutations/add-to-wishlist.ts +24 -0
  30. package/src/api-manager/services/user/mutations/copy-cart-to-wishlist.ts +23 -0
  31. package/src/api-manager/services/user/mutations/create-wishlist.ts +4 -4
  32. package/src/api-manager/services/user/mutations/delete-wishlist.ts +4 -3
  33. package/src/api-manager/services/user/mutations/remove-from-wishlist.ts +21 -0
  34. package/src/api-manager/services/user/mutations/update-wishlist.ts +23 -0
  35. package/src/api-manager/services/user/queries/get-wishlist-details.ts +11 -4
  36. package/src/api-manager/services/user/queries/get-wishlists.ts +4 -3
  37. package/src/api-manager/types/Datasource.ts +33 -5
  38. package/src/auth/auth-options.ts +2 -2
  39. package/src/auth/msal.ts +9 -9
  40. package/src/auth/next-auth-cookie-manager.ts +5 -3
  41. package/src/auth/providers/aadb2c-provider.ts +3 -4
  42. package/src/cms/endpoints.ts +2 -3
  43. package/src/components/_components/LazyImage.tsx +5 -2
  44. package/src/components/_components/header/components/user.tsx +1 -2
  45. package/src/components/_components/product-cards/product-card-1/components/quantity-buttons.tsx +17 -8
  46. package/src/components/_components/product-cards/product-card-1/product-card-1-wrapper.tsx +304 -0
  47. package/src/components/_components/product-cards/product-card-1/product-card.tsx +16 -55
  48. package/src/components/_components/product-cards/product-card-8/product-card.tsx +80 -60
  49. package/src/components/_components/product-cards/product-card-8/styles/index.ts +10 -0
  50. package/src/components/_components/product-cards/product-card-wishlist/components/hover-actions.tsx +37 -0
  51. package/src/components/_components/product-cards/product-card-wishlist/index.ts +1 -0
  52. package/src/components/_components/product-cards/product-card-wishlist/product-card.tsx +118 -0
  53. package/src/components/_components/product-cards/product-card-wishlist/styles/index.ts +51 -0
  54. package/src/components/_components/products-view/product-view-dialog.tsx +48 -10
  55. package/src/components/_components/products-view/products-grid-view.tsx +31 -17
  56. package/src/components/_components/products-view/products-list-view.tsx +30 -16
  57. package/src/components/_components/search-box/__test__/search-input-category.test.tsx +110 -0
  58. package/src/components/_components/search-box/__test__/search-input.test.tsx +137 -0
  59. package/src/components/_components/search-box/__test__/search-results.json +165 -0
  60. package/src/components/_components/search-box/components/search-result.tsx +66 -12
  61. package/src/components/_components/search-box/search-input-category.tsx +135 -32
  62. package/src/components/_components/search-box/styles/index.ts +2 -0
  63. package/src/components/_components/section-header/section-creator.tsx +1 -0
  64. package/src/components/_components/wishlist/add-to-wishlist-dialog.tsx +161 -0
  65. package/src/components/_components/wishlist/components/create-new-list.tsx +167 -0
  66. package/src/components/_components/wishlist/components/create-wishlist-button.tsx +40 -0
  67. package/src/components/_components/wishlist/components/dashboard-header.tsx +123 -0
  68. package/src/components/_components/wishlist/components/navigation.tsx +87 -0
  69. package/src/components/_components/wishlist/components/no-records.tsx +20 -0
  70. package/src/components/_components/wishlist/components/wishlist-modal-item.tsx +66 -0
  71. package/src/components/_components/wishlist/remove-from-wishlist-dialog.tsx +174 -0
  72. package/src/components/_components/wishlist/styles.ts +61 -0
  73. package/src/components/countries-input.tsx +6 -12
  74. package/src/lib/cart-cookie-handler-constants.ts +8 -0
  75. package/src/lib/cart-cookie-handler.ts +27 -5
  76. package/src/lib/create-graphql-client.ts +1 -2
  77. package/src/lib/product-list-types.ts +41 -0
  78. package/src/config.ts +0 -47
@@ -1,11 +1,19 @@
1
1
  import getGraphqlClient from "../../lib/get-graphql-client";
2
- import { User, UserCounts } from "@/api-manager/schemas/user.schema";
2
+ import {
3
+ CopyCartToWishlistInput,
4
+ User,
5
+ UserCounts,
6
+ Wishlist,
7
+ WishlistCreateInput,
8
+ WishlistDetailInput,
9
+ WishlistLinesInput,
10
+ } from "@/api-manager/schemas/user.schema";
3
11
  import * as translator from "./e4.translator";
4
- import { CreateWishListInput, WishList } from "./graphqlRequestSdk";
5
12
  import { userMap } from "./e4.remaps";
6
13
  import { merge } from "object-mapper";
14
+ import { UserApi } from "@/api-manager/types/Datasource";
7
15
 
8
- const user = {
16
+ const user: UserApi = {
9
17
  async updateUser(user: User): Promise<User> {
10
18
  const e4Api = await getGraphqlClient(true);
11
19
 
@@ -46,7 +54,9 @@ const user = {
46
54
  addressCount: data?.getAddressCount ?? 0,
47
55
  };
48
56
  },
49
- async getWishlists(): Promise<WishList[]> {
57
+
58
+ //TODO: Fix the wishlist return and map to schema.
59
+ async getWishlists(): Promise<Wishlist[]> {
50
60
  const e4Api = await getGraphqlClient(true);
51
61
 
52
62
  const { data, errors } = await e4Api.e4WishListListSM();
@@ -55,13 +65,13 @@ const user = {
55
65
  throw new Error("Error getting wishlists");
56
66
  }
57
67
 
58
- return data?.wishlistList?.nodes ?? [];
68
+ return (data?.wishlistList?.nodes as Wishlist[]) ?? [];
59
69
  },
60
70
 
61
- async getWishlistDetails(id: string): Promise<WishList> {
71
+ async getWishlistDetails(input: WishlistDetailInput): Promise<Wishlist> {
62
72
  const e4Api = await getGraphqlClient(true);
63
73
 
64
- const { data, errors } = await e4Api.e4WishListReadMD({ id });
74
+ const { data, errors } = await e4Api.e4WishListReadMD({ id: input.Id });
65
75
 
66
76
  if (errors) {
67
77
  throw new Error("Error getting wishlist details");
@@ -79,16 +89,17 @@ const user = {
79
89
  edges: [],
80
90
  ...wishList.products,
81
91
  },
82
- } as unknown as WishList;
92
+ } as unknown as Wishlist;
83
93
  },
84
- async createWishlist(wishlist: CreateWishListInput): Promise<WishList> {
85
- if (!wishlist.name) {
94
+ async createWishlist(input: WishlistCreateInput): Promise<Wishlist> {
95
+ const { Name: name } = input;
96
+ if (name) {
86
97
  throw new Error("Wishlist name is required");
87
98
  }
88
99
 
89
100
  const e4Api = await getGraphqlClient(true);
90
101
 
91
- const { data, errors } = await e4Api.upsertWishlist({ wishlist });
102
+ const { data, errors } = await e4Api.upsertWishlist({ wishlist: { name } });
92
103
 
93
104
  if (errors) {
94
105
  throw new Error("Error creating wishlist");
@@ -100,18 +111,31 @@ const user = {
100
111
  throw new Error("No wishlist found");
101
112
  }
102
113
 
103
- return wishList as WishList;
114
+ return wishList as Wishlist;
104
115
  },
105
- async deleteWishlist(id: string): Promise<string> {
116
+ async deleteWishlist(input: WishlistDetailInput): Promise<void> {
106
117
  const e4Api = await getGraphqlClient(true);
107
118
 
108
- const { data, errors } = await e4Api.deleteWishList({ id });
119
+ const { data, errors } = await e4Api.deleteWishList({ id: input.Id });
109
120
 
110
121
  if (errors) {
111
122
  throw new Error("Error creating wishlist");
112
123
  }
124
+ },
125
+ async updateWishlist(input: WishlistLinesInput): Promise<Wishlist> {
126
+ throw new Error("updateWishlist not implemented");
127
+ },
128
+
129
+ async addProductsToWishlist(input: WishlistLinesInput): Promise<Wishlist> {
130
+ throw new Error("addProductsToWishlist not implemented");
131
+ },
132
+
133
+ async removeProductsFromWishlist(input: WishlistLinesInput): Promise<void> {
134
+ throw new Error("removeProductsFromWishlist not implemented");
135
+ },
113
136
 
114
- return data?.deleteWishList ?? "";
137
+ async copyCartToWishlist(input: CopyCartToWishlistInput): Promise<Wishlist> {
138
+ throw new Error("copyCartToWishlist not implemented");
115
139
  },
116
140
  };
117
141
 
@@ -14,6 +14,7 @@ import organization from "./e4-organization.datasource";
14
14
 
15
15
  const E4Datasource: PrimaryDatasource = {
16
16
  name: "e4",
17
+
17
18
  user,
18
19
  session,
19
20
  cart,
@@ -475,7 +475,8 @@ const getStateId = async (stateCode: string, countryId: string) => {
475
475
  } else {
476
476
  const e4Api = await getGraphqlClient();
477
477
  const { data } = await e4Api.e4Country({ id: countryId });
478
- countryCache.set(cacheKey, data?.country as Country);
478
+ country = data?.country as Country;
479
+ countryCache.set(cacheKey, country);
479
480
  }
480
481
 
481
482
  const state = country?.state?.find((s) => s?.code === stateCode);