@riosst100/pwa-marketplace 3.2.5 → 3.2.7

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/components/AgeVerification/ageVerificationModal.js +2 -2
  3. package/src/components/AgeVerification/index.js +1 -1
  4. package/src/components/BecomeSeller/becomeSeller.js +15 -12
  5. package/src/components/BecomeSellerPage/becomeSellerPage.js +29 -10
  6. package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -0
  7. package/src/components/LiveChat/MessagesModal.js +6 -6
  8. package/src/components/RFQ/index.js +3 -2
  9. package/src/components/RFQ/modalRfq.js +186 -68
  10. package/src/components/RFQPage/orderRow.js +84 -249
  11. package/src/components/RFQPage/orderRow.module.css +146 -0
  12. package/src/components/RFQPage/quoteDetail.js +173 -86
  13. package/src/components/RFQPage/quoteList.js +87 -65
  14. package/src/components/SellerMegaMenu/sellerMegaMenu.js +3 -1
  15. package/src/components/SellerMegaMenu/sellerMegaMenuItem.js +1 -1
  16. package/src/components/SellerMegaMenu/sellerMegaMenuItem.module.css +2 -1
  17. package/src/components/SocialLogin/googleSignInButton.js +50 -0
  18. package/src/components/SocialLogin/index.js +1 -10
  19. package/src/components/SocialLogin/socialLogin.js +28 -23
  20. package/src/components/WebsiteSwitcher/websiteSwitcherItem.js +0 -7
  21. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +3 -1
  22. package/src/overwrites/venia-ui/lib/components/CreateAccount/createAccount.js +4 -4
  23. package/src/overwrites/venia-ui/lib/components/CreateAccountPage/createAccountPage.js +28 -9
  24. package/src/overwrites/venia-ui/lib/components/CreateAccountPage/createAccountPage.module.css +12 -2
  25. package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +1 -1
  26. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +1 -0
  27. package/src/overwrites/venia-ui/lib/components/SignIn/signIn.js +23 -30
  28. package/src/overwrites/venia-ui/lib/components/SignInPage/signInPage.js +22 -9
  29. package/src/overwrites/venia-ui/lib/components/SignInPage/signInPage.module.css +10 -0
  30. package/src/talons/RFQ/rfq.gql.js +162 -0
  31. package/src/talons/RFQ/useRFQ.js +81 -0
  32. package/src/talons/SellerMegaMenu/megaMenu.gql.js +4 -3
  33. package/src/talons/SellerMegaMenu/useSellerMegaMenu.js +106 -33
  34. package/src/talons/SellerMegaMenu/useSellerMegaMenuItem.js +1 -1
  35. package/src/talons/SellerProducts/useProductContent.js +11 -7
  36. package/src/talons/SocialLogin/socialLogin.gql.js +106 -0
  37. package/src/talons/SocialLogin/useSocialLogin.js +169 -0
@@ -0,0 +1,81 @@
1
+ import { useLazyQuery, useMutation } from '@apollo/client';
2
+ import { useCallback } from 'react';
3
+
4
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
+ import DEFAULT_OPERATIONS from './rfq.gql';
6
+
7
+ export const useRFQ = props => {
8
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props?.operations);
9
+ const {
10
+ getQuickRfqListQuery,
11
+ getQuickRfqDetailQuery,
12
+ createQuickRfqMutation,
13
+ sendRfqMessageMutation,
14
+ convertQuickrfqToCartMutation
15
+ } = operations;
16
+
17
+ const [fetchRfqList, rfqListState] = useLazyQuery(getQuickRfqListQuery, {
18
+ fetchPolicy: 'network-only',
19
+ nextFetchPolicy: 'cache-first'
20
+ });
21
+
22
+ const [fetchRfqDetail, rfqDetailState] = useLazyQuery(getQuickRfqDetailQuery, {
23
+ fetchPolicy: 'network-only',
24
+ nextFetchPolicy: 'cache-first',
25
+ notifyOnNetworkStatusChange: true,
26
+ errorPolicy: 'all'
27
+ });
28
+
29
+ const [createQuickRfq, createState] = useMutation(createQuickRfqMutation);
30
+ const [sendRfqMessage, sendMessageState] = useMutation(sendRfqMessageMutation);
31
+ const [convertQuickrfqToCart, convertState] = useMutation(convertQuickrfqToCartMutation);
32
+
33
+ const loadRfqList = useCallback(
34
+ variables => fetchRfqList({ variables }),
35
+ [fetchRfqList]
36
+ );
37
+
38
+ const loadRfqDetail = useCallback(
39
+ variables => {
40
+ const id = variables && variables.quickrfqId;
41
+ const parsedId = typeof id === 'number' ? id : parseInt(id, 10);
42
+ if (isNaN(parsedId)) {
43
+ return Promise.resolve(null);
44
+ }
45
+ return fetchRfqDetail({ variables: { quickrfqId: parsedId } });
46
+ },
47
+ [fetchRfqDetail]
48
+ );
49
+
50
+ const handleCreateQuickRfq = useCallback(
51
+ input => createQuickRfq({ variables: { input } }),
52
+ [createQuickRfq]
53
+ );
54
+
55
+ const handleSendRfqMessage = useCallback(
56
+ input => sendRfqMessage({ variables: { input } }),
57
+ [sendRfqMessage]
58
+ );
59
+
60
+ const handleConvertQuickrfqToCart = useCallback(
61
+ quickrfqId => convertQuickrfqToCart({ variables: { quickrfqId } }),
62
+ [convertQuickrfqToCart]
63
+ );
64
+
65
+ return {
66
+ loadRfqList,
67
+ rfqListState,
68
+ loadRfqDetail,
69
+ rfqDetailState,
70
+ startDetailPolling: rfqDetailState && rfqDetailState.startPolling ? rfqDetailState.startPolling : undefined,
71
+ stopDetailPolling: rfqDetailState && rfqDetailState.stopPolling ? rfqDetailState.stopPolling : undefined,
72
+ handleCreateQuickRfq,
73
+ createState,
74
+ handleSendRfqMessage,
75
+ sendMessageState,
76
+ handleConvertQuickrfqToCart,
77
+ convertState
78
+ };
79
+ };
80
+
81
+ export default useRFQ;
@@ -10,9 +10,9 @@ export const GET_STORE_CONFIG_DATA = gql`
10
10
  `;
11
11
 
12
12
  export const GET_MEGA_MENU = gql`
13
- query getSellerMegaMenu {
13
+ query getSellerMegaMenu($sellerUrl: String!) {
14
14
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
15
- sellerCategories {
15
+ sellerCategories(sellerUrl: $sellerUrl) {
16
16
  uid
17
17
  name
18
18
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
@@ -79,11 +79,12 @@ export const GET_MEGA_MENU = gql`
79
79
  }
80
80
  }
81
81
  }
82
+ __typename
82
83
  }
83
84
  }
84
85
  `;
85
86
 
86
87
  export default {
87
- getMegaMenuQuery: GET_MEGA_MENU,
88
+ getSellerMegaMenuQuery: GET_MEGA_MENU,
88
89
  getStoreConfigQuery: GET_STORE_CONFIG_DATA
89
90
  };
@@ -20,10 +20,11 @@ import DEFAULT_OPERATIONS from './megaMenu.gql';
20
20
  */
21
21
  export const useSellerMegaMenu = (props = {}) => {
22
22
  const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
23
- const { getMegaMenuQuery, getStoreConfigQuery } = operations;
23
+ const { getSellerMegaMenuQuery, getStoreConfigQuery } = operations;
24
24
 
25
25
  const location = useLocation();
26
26
  const [activeCategoryId, setActiveCategoryId] = useState(null);
27
+ const [activeCategory, setActiveCategory] = useState(null);
27
28
  const [sellerSubMenuState, setSellerSubMenuState] = useState(false);
28
29
  const [disableFocus, setDisableFocus] = useState(false);
29
30
 
@@ -32,9 +33,11 @@ export const useSellerMegaMenu = (props = {}) => {
32
33
  nextFetchPolicy: 'cache-first'
33
34
  });
34
35
 
35
- const { data } = useQuery(getMegaMenuQuery, {
36
- fetchPolicy: 'cache-and-network',
37
- nextFetchPolicy: 'cache-first'
36
+ const { sellerUrl } = props;
37
+
38
+ const { data } = useQuery(getSellerMegaMenuQuery, {
39
+ variables: { sellerUrl: sellerUrl },
40
+ fetchPolicy: 'cache-and-network'
38
41
  });
39
42
 
40
43
  const categoryUrlSuffix = useMemo(() => {
@@ -66,7 +69,7 @@ export const useSellerMegaMenu = (props = {}) => {
66
69
 
67
70
  const categoryUrlPath = `/${url_path}${categoryUrlSuffix || ''}`;
68
71
 
69
- return location.pathname === categoryUrlPath;
72
+ return location.pathname.includes(categoryUrlPath);
70
73
  },
71
74
  [location.pathname, categoryUrlSuffix]
72
75
  );
@@ -119,6 +122,29 @@ export const useSellerMegaMenu = (props = {}) => {
119
122
 
120
123
  const history = useHistory();
121
124
 
125
+ const setQueryPath = ({ history, location, pathname, replace }) => {
126
+ // const { pathname } = location;
127
+
128
+ const destination = { pathname: pathname };
129
+
130
+ if (replace) {
131
+ history.replace(destination);
132
+ }
133
+ };
134
+
135
+ const setDefaultCategory = useCallback(
136
+ (pathname) => {
137
+ // Update the query parameter.
138
+ setQueryPath({
139
+ history,
140
+ location,
141
+ pathname,
142
+ replace: true
143
+ });
144
+ },
145
+ [history, location]
146
+ );
147
+
122
148
  const setQueryParam = ({ history, location, parameter, replace, value }) => {
123
149
  const { search } = location;
124
150
  const queryParams = new URLSearchParams(search);
@@ -147,25 +173,19 @@ export const useSellerMegaMenu = (props = {}) => {
147
173
  [history, location]
148
174
  );
149
175
 
150
- useEffect(() => {
151
- const { search } = location;
176
+ const hasCategoryPath = (pathname) => {
177
+ // const pathname = new URL(url).pathname;
178
+ const parts = pathname.split("/").filter(Boolean);
152
179
 
153
- // if (category && category.default_top_filter) {
154
- // const defaultTopFilter = category.default_top_filter;
180
+ // cari index "seller"
181
+ const sellerIndex = parts.indexOf("seller");
155
182
 
156
- // const attrCode = defaultTopFilter.attribute_code;
157
- // const label = defaultTopFilter.label;
158
- // const value = defaultTopFilter.value;
183
+ if (sellerIndex === -1) return false;
159
184
 
160
- // if (!search.includes(attrCode)) {
161
- // setDefaultSubcategoryAndTopFilter(
162
- // label + ',' + value,
163
- // attrCode + '[filter]',
164
- // true
165
- // );
166
- // }
167
- // }
168
- }, [category, location, setDefaultSubcategoryAndTopFilter]);
185
+ // seller/<store-name> → minimal 2 segment
186
+ // kalau lebih dari itu → ada category path
187
+ return parts.length > sellerIndex + 2;
188
+ }
169
189
 
170
190
  const findActiveCategory = useCallback(
171
191
  (pathname, category) => {
@@ -182,6 +202,70 @@ export const useSellerMegaMenu = (props = {}) => {
182
202
  [isActive]
183
203
  );
184
204
 
205
+ useEffect(() => {
206
+ const activeCategory = findActiveCategory(
207
+ location.pathname,
208
+ megaMenuData
209
+ );
210
+
211
+ console.log('megaMenuData',megaMenuData)
212
+ console.log('activeCategory',activeCategory)
213
+
214
+ if (activeCategory) {
215
+ setActiveCategoryId(activeCategory.path[0]);
216
+ setActiveCategory(activeCategory);
217
+ } else {
218
+ setActiveCategoryId(null);
219
+ setActiveCategory(null);
220
+ }
221
+ }, [findActiveCategory, location.pathname, megaMenuData]);
222
+
223
+ useEffect(() => {
224
+ const { search, pathname } = location;
225
+
226
+ console.log('category555',category)
227
+
228
+ if (!hasCategoryPath(pathname) && category && category.url_path) {
229
+ const url_path = category.url_path;
230
+ const categoryUrlPath = `/${url_path}${categoryUrlSuffix || ''}`;
231
+ const newPathname = pathname.replace(/\/+$/, "");
232
+
233
+ if (!newPathname.includes(categoryUrlPath)) {
234
+ setDefaultCategory(
235
+ newPathname + categoryUrlPath
236
+ );
237
+ }
238
+ }
239
+ }, [category, location, setDefaultCategory]);
240
+
241
+ useEffect(() => {
242
+ const { search } = location;
243
+
244
+ if (activeCategory && activeCategory.default_top_filter) {
245
+ const defaultTopFilter = activeCategory.default_top_filter;
246
+
247
+ console.log('activeCategory',activeCategory)
248
+ console.log('2defaultTopFilte344444',defaultTopFilter)
249
+ console.log('search',search)
250
+
251
+ const attrCode = defaultTopFilter.attribute_code;
252
+ const label = defaultTopFilter.label;
253
+ const value = defaultTopFilter.value;
254
+
255
+ if (!search.includes(attrCode)) {
256
+ console.log('setDefaultSubcategoryAndTopFilter',attrCode)
257
+
258
+ setDefaultSubcategoryAndTopFilter(
259
+ label + ',' + value,
260
+ attrCode + '[filter]',
261
+ true
262
+ );
263
+ }
264
+ }
265
+ }, [activeCategory, location, setDefaultSubcategoryAndTopFilter]);
266
+
267
+
268
+
185
269
  const handleClickOutside = e => {
186
270
  if (!props.mainNavRef.current.contains(e.target)) {
187
271
  setSellerSubMenuState(false);
@@ -195,18 +279,7 @@ export const useSellerMegaMenu = (props = {}) => {
195
279
  setSellerSubMenuState(true);
196
280
  }, [setSellerSubMenuState]);
197
281
 
198
- useEffect(() => {
199
- const activeCategory = findActiveCategory(
200
- location.pathname,
201
- megaMenuData
202
- );
203
-
204
- if (activeCategory) {
205
- setActiveCategoryId(activeCategory.path[0]);
206
- } else {
207
- setActiveCategoryId(null);
208
- }
209
- }, [findActiveCategory, location.pathname, megaMenuData]);
282
+
210
283
 
211
284
  /**
212
285
  * Sets next root component to show proper loading effect
@@ -4,7 +4,7 @@ export const useSellerMegaMenuItem = props => {
4
4
  const { category, activeCategoryId, sellerSubMenuState, disableFocus } = props;
5
5
 
6
6
  const [isFocused, setIsFocused] = useState(false);
7
- const isActive = category.id === activeCategoryId;
7
+ const isActive = category.uid === activeCategoryId;
8
8
 
9
9
  const handleMenuItemFocus = useCallback(() => {
10
10
  setIsFocused(true);
@@ -146,17 +146,21 @@ export const useProductContent = props => {
146
146
  if (category && category.default_top_filter) {
147
147
  const defaultTopFilter = category.default_top_filter;
148
148
 
149
+ // console.log('defaultTopFilter222',defaultTopFilter)
150
+
149
151
  const attrCode = defaultTopFilter.attribute_code;
150
152
  const label = defaultTopFilter.label;
151
153
  const value = defaultTopFilter.value;
152
154
 
153
- if (!search.includes(attrCode)) {
154
- setDefaultSubcategoryAndTopFilter(
155
- label + ',' + value,
156
- attrCode + '[filter]',
157
- true
158
- );
159
- }
155
+ // if (!search.includes(attrCode)) {
156
+ // console.log('setDefaultSubcategoryAndTopFilter',attrCode)
157
+
158
+ // setDefaultSubcategoryAndTopFilter(
159
+ // label + ',' + value,
160
+ // attrCode + '[filter]',
161
+ // true
162
+ // );
163
+ // }
160
164
  }
161
165
  }, [category, location, setDefaultSubcategoryAndTopFilter]);
162
166
 
@@ -0,0 +1,106 @@
1
+ import { gql } from '@apollo/client';
2
+ import { CheckoutPageFragment } from '@magento/peregrine/lib/talons/CheckoutPage/checkoutPageFragments.gql';
3
+ import { CartPageFragment } from '@magento/peregrine/lib/talons/CartPage/cartPageFragments.gql.js';
4
+
5
+ export const GET_CART_DETAILS_QUERY = gql`
6
+ query GetCartDetailsAfterSignIn($cartId: String!) {
7
+ cart(cart_id: $cartId) {
8
+ id
9
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
10
+ items {
11
+ uid
12
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
13
+ product {
14
+ uid
15
+ name
16
+ sku
17
+ small_image {
18
+ url
19
+ label
20
+ }
21
+ price {
22
+ regularPrice {
23
+ amount {
24
+ value
25
+ }
26
+ }
27
+ }
28
+ }
29
+ quantity
30
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
31
+ ... on ConfigurableCartItem {
32
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
33
+ configurable_options {
34
+ configurable_product_option_uid
35
+ option_label
36
+ configurable_product_option_value_uid
37
+ value_label
38
+ }
39
+ }
40
+ }
41
+ prices {
42
+ grand_total {
43
+ value
44
+ currency
45
+ }
46
+ }
47
+ ...CartPageFragment
48
+ }
49
+ }
50
+ ${CartPageFragment}
51
+ `;
52
+
53
+ export const GET_CUSTOMER = gql`
54
+ query GetCustomerAfterSignIn {
55
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
56
+ customer {
57
+ email
58
+ firstname
59
+ lastname
60
+ is_subscribed
61
+ is_seller
62
+ }
63
+ }
64
+ `;
65
+
66
+ export const CREATE_CART = gql`
67
+ mutation CreateCartAfterSignIn {
68
+ cartId: createEmptyCart
69
+ }
70
+ `;
71
+
72
+ export const MERGE_CARTS = gql`
73
+ mutation MergeCartsAfterSignIn(
74
+ $sourceCartId: String!
75
+ $destinationCartId: String!
76
+ ) {
77
+ mergeCarts(
78
+ source_cart_id: $sourceCartId
79
+ destination_cart_id: $destinationCartId
80
+ ) {
81
+ id
82
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
83
+ items {
84
+ uid
85
+ }
86
+ ...CheckoutPageFragment
87
+ }
88
+ }
89
+ ${CheckoutPageFragment}
90
+ `;
91
+
92
+ export const SOCIAL_GOOGLE_AUTHENTICATE = gql`
93
+ mutation SocialGoogleAuthenticate($jwt_token: String!) {
94
+ socialGoogleAuthenticate(jwt_token: $jwt_token) {
95
+ token
96
+ }
97
+ }
98
+ `;
99
+
100
+ export default {
101
+ GET_CART_DETAILS_QUERY: GET_CART_DETAILS_QUERY,
102
+ createCartMutation: CREATE_CART,
103
+ getCustomerQuery: GET_CUSTOMER,
104
+ mergeCartsMutation: MERGE_CARTS,
105
+ socialGoogleAuthenticateMutation: SOCIAL_GOOGLE_AUTHENTICATE
106
+ };
@@ -0,0 +1,169 @@
1
+ import { useCallback, useEffect, useRef, useState, useMemo } from 'react';
2
+ import { useApolloClient, useMutation } from '@apollo/client';
3
+
4
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
+ import { useCartContext } from '@magento/peregrine/lib/context/cart';
6
+ import { useUserContext } from '@magento/peregrine/lib/context/user';
7
+ import { useAwaitQuery } from '@magento/peregrine/lib/hooks/useAwaitQuery';
8
+ import { retrieveCartId } from '@magento/peregrine/lib/store/actions/cart';
9
+ import { useToasts } from '@magento/peregrine/lib/Toasts';
10
+ import DEFAULT_OPERATIONS from './socialLogin.gql'
11
+ import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
12
+ import { BrowserPersistence } from '@magento/peregrine/lib/util';
13
+
14
+ const storage = new BrowserPersistence();
15
+
16
+ export const useSocialLogin = props => {
17
+ const {
18
+ jwtToken
19
+ } = props;
20
+
21
+ const [, { addToast }] = useToasts();
22
+
23
+ const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
24
+ const {
25
+ createCartMutation,
26
+ getCustomerQuery,
27
+ mergeCartsMutation,
28
+ getCartDetailsQuery,
29
+ socialGoogleAuthenticateMutation
30
+ } = operations;
31
+
32
+ const apolloClient = useApolloClient();
33
+ const [isSigningIn, setIsSigningIn] = useState(false);
34
+
35
+ const [
36
+ { cartId },
37
+ { createCart, removeCart, getCartDetails }
38
+ ] = useCartContext();
39
+
40
+ const [
41
+ { isGettingDetails, getDetailsError },
42
+ { getUserDetails, setToken }
43
+ ] = useUserContext();
44
+
45
+ const [, { dispatch }] = useEventingContext();
46
+
47
+ const [signIn, { error: signInError }] = useMutation(socialGoogleAuthenticateMutation, {
48
+ fetchPolicy: 'no-cache'
49
+ });
50
+
51
+ const generateReCaptchaData = null;
52
+
53
+ const [fetchCartId] = useMutation(createCartMutation);
54
+ const [mergeCarts] = useMutation(mergeCartsMutation);
55
+ const fetchUserDetails = useAwaitQuery(getCustomerQuery);
56
+ const fetchCartDetails = useAwaitQuery(getCartDetailsQuery);
57
+
58
+ const formApiRef = useRef(null);
59
+ const setFormApi = useCallback(api => (formApiRef.current = api), []);
60
+
61
+ useEffect(async () => {
62
+ if (jwtToken) {
63
+ setIsSigningIn(true);
64
+ try {
65
+ // Get source cart id (guest cart id).
66
+ const sourceCartId = cartId;
67
+
68
+ // Sign in and set the token.
69
+ const signInResponse = await signIn({
70
+ variables: {
71
+ jwt_token: jwtToken
72
+ }
73
+ });
74
+
75
+ const token = signInResponse.data.socialGoogleAuthenticate.token;
76
+ await setToken(token);
77
+
78
+ await getUserDetails({ fetchUserDetails });
79
+
80
+ // Clear all cart/customer data from cache and redux.
81
+ await apolloClient.clearCacheData(apolloClient, 'cart');
82
+ await apolloClient.clearCacheData(apolloClient, 'customer');
83
+ await removeCart();
84
+
85
+ // Create and get the customer's cart id.
86
+ await createCart({
87
+ fetchCartId
88
+ });
89
+ const destinationCartId = await retrieveCartId();
90
+
91
+ // Merge the guest cart into the customer cart.
92
+ await mergeCarts({
93
+ variables: {
94
+ destinationCartId,
95
+ sourceCartId
96
+ }
97
+ });
98
+
99
+ // Ensure old stores are updated with any new data.
100
+
101
+
102
+ const { data } = await fetchUserDetails({
103
+ fetchPolicy: 'cache-only'
104
+ });
105
+
106
+ if (data.customer.is_seller) {
107
+ storage.setItem('is_seller', true);
108
+ }
109
+
110
+ dispatch({
111
+ type: 'USER_SIGN_IN',
112
+ payload: {
113
+ ...data.customer
114
+ }
115
+ });
116
+
117
+ getCartDetails({ fetchCartId, fetchCartDetails });
118
+
119
+ addToast({
120
+ type: 'success',
121
+ message: formatMessage({
122
+ id: 'signIn.signInSuccessToast',
123
+ defaultMessage: "You have successfully signed in."
124
+ }),
125
+ timeout: 5000
126
+ });
127
+ } catch (error) {
128
+ if (process.env.NODE_ENV !== 'production') {
129
+ console.error(error);
130
+ }
131
+
132
+ setIsSigningIn(false);
133
+ }
134
+ }
135
+ }, [
136
+ jwtToken,
137
+ cartId,
138
+ generateReCaptchaData,
139
+ signIn,
140
+ setToken,
141
+ apolloClient,
142
+ removeCart,
143
+ createCart,
144
+ fetchCartId,
145
+ mergeCarts,
146
+ getUserDetails,
147
+ fetchUserDetails,
148
+ getCartDetails,
149
+ fetchCartDetails,
150
+ dispatch
151
+ ]
152
+ );
153
+
154
+ const errors = useMemo(
155
+ () =>
156
+ new Map([
157
+ ['getUserDetailsQuery', getDetailsError],
158
+ ['socialGoogleAuthenticateMutation', signInError]
159
+ ]),
160
+ [getDetailsError, signInError]
161
+ );
162
+
163
+ return {
164
+ errors,
165
+ // isBusy: isGettingDetails || isSigningIn || recaptchaLoading,
166
+ isBusy: isGettingDetails || isSigningIn,
167
+ setFormApi
168
+ };
169
+ };