@riosst100/pwa-marketplace 1.2.7 → 1.2.8
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/package.json +1 -1
- package/src/Utilities/graphQL.js +76 -76
- package/src/componentOverrideMapping.js +17 -17
- package/src/components/BecomeSeller/becomeSeller.js +335 -335
- package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
- package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
- package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
- package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
- package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
- package/src/components/Filter/index.js +53 -53
- package/src/components/Header/becomeSellerLink.js +28 -28
- package/src/components/Header/becomeSellerLink.module.css +12 -12
- package/src/components/Header/websiteSwitcher.js +109 -109
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +35 -0
- package/src/components/Pagination/index.js +49 -49
- package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
- package/src/components/ProductItem/index.js +50 -50
- package/src/components/Search/index.js +16 -16
- package/src/components/Seller/index.js +1 -1
- package/src/components/Seller/seller.js +57 -249
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
- package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
- package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +161 -0
- package/src/components/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +86 -90
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -19
- package/src/components/SellerLocation/sellerLocationItem.js +27 -27
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +46 -46
- package/src/components/SellerReview/index.js +1 -1
- package/src/components/SellerReview/sellerReview.js +143 -143
- package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
- package/src/components/SellerVerification/sellerVerification.js +198 -198
- package/src/components/SellerVerification/sellerVerification.module.css +47 -47
- package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
- package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
- package/src/components/SortBy/index.js +24 -24
- package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
- package/src/components/commons/Slider/index.js +13 -13
- package/src/components/commons/Tabs/index.js +64 -64
- package/src/index.js +6 -6
- package/src/intercept.js +113 -113
- package/src/moduleOverrideWebpackPlugin.js +70 -70
- package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
- package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
- package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
- package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
- package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
- package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
- package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
- package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
- package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
- package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
- package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
- package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
- package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
- package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
- package/src/queries/index.js +30 -30
- package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
- package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
- package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
- package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
- package/src/talons/Header/useBecomeSellerLink.js +13 -13
- package/src/talons/Header/useWebsiteSwitcher.js +218 -218
- package/src/talons/Seller/seller.gql.js +204 -139
- package/src/talons/Seller/useSeller.js +71 -66
- package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
- package/src/talons/SellerCountry/useSellerCountry.js +25 -25
- package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
- package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
- package/src/theme/vars.js +6 -6
- package/src/util/mapSeller.js +7 -7
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
|
|
3
|
-
export const BECOME_SELLER = gql`
|
|
4
|
-
mutation BecomeSeller(
|
|
5
|
-
$seller_type: String
|
|
6
|
-
$group_id: String!
|
|
7
|
-
$url_key: String!
|
|
8
|
-
$name: String!
|
|
9
|
-
$company: String
|
|
10
|
-
$company_registration_number: String
|
|
11
|
-
$country_id: String
|
|
12
|
-
$address_line_1: String!
|
|
13
|
-
$address_line_2: String
|
|
14
|
-
$city: String!
|
|
15
|
-
$region: String
|
|
16
|
-
$region_id: String
|
|
17
|
-
$postcode: String!
|
|
18
|
-
$contact_number: String!
|
|
19
|
-
) {
|
|
20
|
-
becomeSeller(
|
|
21
|
-
input: {
|
|
22
|
-
seller_type: $seller_type
|
|
23
|
-
group_id: $group_id
|
|
24
|
-
url_key: $url_key
|
|
25
|
-
name: $name
|
|
26
|
-
company: $company
|
|
27
|
-
company_registration_number: $company_registration_number,
|
|
28
|
-
country_id: $country_id
|
|
29
|
-
address_line_1: $address_line_1
|
|
30
|
-
address_line_2: $address_line_2
|
|
31
|
-
city: $city
|
|
32
|
-
region: $region
|
|
33
|
-
region_id: $region_id
|
|
34
|
-
postcode: $postcode
|
|
35
|
-
contact_number: $contact_number
|
|
36
|
-
}
|
|
37
|
-
) {
|
|
38
|
-
code
|
|
39
|
-
message
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
export default {
|
|
45
|
-
becomeSellerMutation: BECOME_SELLER
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const BECOME_SELLER = gql`
|
|
4
|
+
mutation BecomeSeller(
|
|
5
|
+
$seller_type: String
|
|
6
|
+
$group_id: String!
|
|
7
|
+
$url_key: String!
|
|
8
|
+
$name: String!
|
|
9
|
+
$company: String
|
|
10
|
+
$company_registration_number: String
|
|
11
|
+
$country_id: String
|
|
12
|
+
$address_line_1: String!
|
|
13
|
+
$address_line_2: String
|
|
14
|
+
$city: String!
|
|
15
|
+
$region: String
|
|
16
|
+
$region_id: String
|
|
17
|
+
$postcode: String!
|
|
18
|
+
$contact_number: String!
|
|
19
|
+
) {
|
|
20
|
+
becomeSeller(
|
|
21
|
+
input: {
|
|
22
|
+
seller_type: $seller_type
|
|
23
|
+
group_id: $group_id
|
|
24
|
+
url_key: $url_key
|
|
25
|
+
name: $name
|
|
26
|
+
company: $company
|
|
27
|
+
company_registration_number: $company_registration_number,
|
|
28
|
+
country_id: $country_id
|
|
29
|
+
address_line_1: $address_line_1
|
|
30
|
+
address_line_2: $address_line_2
|
|
31
|
+
city: $city
|
|
32
|
+
region: $region
|
|
33
|
+
region_id: $region_id
|
|
34
|
+
postcode: $postcode
|
|
35
|
+
contact_number: $contact_number
|
|
36
|
+
}
|
|
37
|
+
) {
|
|
38
|
+
code
|
|
39
|
+
message
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
becomeSellerMutation: BECOME_SELLER
|
|
46
46
|
};
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import { useApolloClient, useMutation } from '@apollo/client';
|
|
3
|
-
|
|
4
|
-
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
5
|
-
import { useGoogleReCaptcha } from '@magento/peregrine/lib/hooks/useGoogleReCaptcha';
|
|
6
|
-
|
|
7
|
-
import DEFAULT_OPERATIONS from './becomeSeller.gql';
|
|
8
|
-
import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
|
|
9
|
-
|
|
10
|
-
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
11
|
-
|
|
12
|
-
const storage = new BrowserPersistence();
|
|
13
|
-
|
|
14
|
-
export const useBecomeSeller = props => {
|
|
15
|
-
const { initialValues = {}, onSubmit, onCancel } = props;
|
|
16
|
-
|
|
17
|
-
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
becomeSellerMutation
|
|
21
|
-
} = operations;
|
|
22
|
-
|
|
23
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
24
|
-
const [sellerType, setSellerType] = useState('individual');
|
|
25
|
-
|
|
26
|
-
const [, { dispatch }] = useEventingContext();
|
|
27
|
-
|
|
28
|
-
// For create account and sign in mutations, we don't want to cache any
|
|
29
|
-
// personally identifiable information (PII). So we set fetchPolicy to 'no-cache'.
|
|
30
|
-
const [becomeSeller, { error: becomeSellerError }] = useMutation(
|
|
31
|
-
becomeSellerMutation,
|
|
32
|
-
{
|
|
33
|
-
fetchPolicy: 'no-cache'
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
generateReCaptchaData,
|
|
39
|
-
recaptchaLoading,
|
|
40
|
-
recaptchaWidgetProps
|
|
41
|
-
} = useGoogleReCaptcha({
|
|
42
|
-
currentForm: 'BECOME_SELLER',
|
|
43
|
-
formAction: 'becomeSeller'
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const handleChange = useCallback(
|
|
47
|
-
async formValues => {
|
|
48
|
-
if (formValues.values.seller) {
|
|
49
|
-
setSellerType(formValues.values.seller.seller_type)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const handleSubmit = useCallback(
|
|
55
|
-
async formValues => {
|
|
56
|
-
setIsSubmitting(true);
|
|
57
|
-
try {
|
|
58
|
-
|
|
59
|
-
// Get reCaptchaV3 Data for becomeSeller mutation
|
|
60
|
-
const recaptchaDataForBecomeSeller = await generateReCaptchaData();
|
|
61
|
-
|
|
62
|
-
// Create the account and then sign in.
|
|
63
|
-
const result = await becomeSeller({
|
|
64
|
-
variables: {
|
|
65
|
-
seller_type: sellerType,
|
|
66
|
-
group_id: '',
|
|
67
|
-
url_key: formValues.seller.store_url,
|
|
68
|
-
name: formValues.seller.seller_profile_name,
|
|
69
|
-
company: formValues.seller.company_name,
|
|
70
|
-
company_registration_number: formValues.seller.company_registration_number,
|
|
71
|
-
country_id: formValues.seller.country_id,
|
|
72
|
-
address_line_1: formValues.seller.address_line_1,
|
|
73
|
-
address_line_2: formValues.seller.address_line_2,
|
|
74
|
-
city: formValues.seller.city,
|
|
75
|
-
region: formValues.seller.region,
|
|
76
|
-
region_id: formValues.seller.region_id,
|
|
77
|
-
postcode: formValues.seller.postcode,
|
|
78
|
-
contact_number: formValues.seller.contact_number
|
|
79
|
-
},
|
|
80
|
-
...recaptchaDataForBecomeSeller
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (result.data.becomeSeller.code) {
|
|
84
|
-
storage.setItem('is_seller', true);
|
|
85
|
-
|
|
86
|
-
globalThis.location.assign('/seller-account');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
dispatch({
|
|
90
|
-
type: 'BECOME_SELLER',
|
|
91
|
-
payload: {
|
|
92
|
-
group_id: 'basic',
|
|
93
|
-
url_key: formValues.seller.store_url
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Finally, invoke the post-submission callback.
|
|
98
|
-
if (onSubmit) {
|
|
99
|
-
onSubmit();
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
103
|
-
console.error(error);
|
|
104
|
-
}
|
|
105
|
-
setIsSubmitting(false);
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
[
|
|
110
|
-
generateReCaptchaData,
|
|
111
|
-
becomeSeller,
|
|
112
|
-
onSubmit,
|
|
113
|
-
dispatch
|
|
114
|
-
]
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const sanitizedInitialValues = useMemo(() => {
|
|
118
|
-
const { sellerProfileName, companyName, ...rest } = initialValues;
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
seller: { profile_name: sellerProfileName, company: companyName, country: "AF" },
|
|
122
|
-
...rest
|
|
123
|
-
};
|
|
124
|
-
}, [initialValues]);
|
|
125
|
-
|
|
126
|
-
const errors = useMemo(
|
|
127
|
-
() =>
|
|
128
|
-
new Map([
|
|
129
|
-
['becomeSellerQuery', becomeSellerError]
|
|
130
|
-
]),
|
|
131
|
-
[becomeSellerError]
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const isSeller = storage.getItem('is_seller') || false;
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
isSeller,
|
|
138
|
-
errors,
|
|
139
|
-
handleSubmit,
|
|
140
|
-
sellerType,
|
|
141
|
-
handleChange,
|
|
142
|
-
initialValues: sanitizedInitialValues,
|
|
143
|
-
isDisabled: isSubmitting || recaptchaLoading,
|
|
144
|
-
recaptchaWidgetProps
|
|
145
|
-
};
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { useApolloClient, useMutation } from '@apollo/client';
|
|
3
|
+
|
|
4
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
5
|
+
import { useGoogleReCaptcha } from '@magento/peregrine/lib/hooks/useGoogleReCaptcha';
|
|
6
|
+
|
|
7
|
+
import DEFAULT_OPERATIONS from './becomeSeller.gql';
|
|
8
|
+
import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
|
|
9
|
+
|
|
10
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
11
|
+
|
|
12
|
+
const storage = new BrowserPersistence();
|
|
13
|
+
|
|
14
|
+
export const useBecomeSeller = props => {
|
|
15
|
+
const { initialValues = {}, onSubmit, onCancel } = props;
|
|
16
|
+
|
|
17
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
becomeSellerMutation
|
|
21
|
+
} = operations;
|
|
22
|
+
|
|
23
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
24
|
+
const [sellerType, setSellerType] = useState('individual');
|
|
25
|
+
|
|
26
|
+
const [, { dispatch }] = useEventingContext();
|
|
27
|
+
|
|
28
|
+
// For create account and sign in mutations, we don't want to cache any
|
|
29
|
+
// personally identifiable information (PII). So we set fetchPolicy to 'no-cache'.
|
|
30
|
+
const [becomeSeller, { error: becomeSellerError }] = useMutation(
|
|
31
|
+
becomeSellerMutation,
|
|
32
|
+
{
|
|
33
|
+
fetchPolicy: 'no-cache'
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
generateReCaptchaData,
|
|
39
|
+
recaptchaLoading,
|
|
40
|
+
recaptchaWidgetProps
|
|
41
|
+
} = useGoogleReCaptcha({
|
|
42
|
+
currentForm: 'BECOME_SELLER',
|
|
43
|
+
formAction: 'becomeSeller'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const handleChange = useCallback(
|
|
47
|
+
async formValues => {
|
|
48
|
+
if (formValues.values.seller) {
|
|
49
|
+
setSellerType(formValues.values.seller.seller_type)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const handleSubmit = useCallback(
|
|
55
|
+
async formValues => {
|
|
56
|
+
setIsSubmitting(true);
|
|
57
|
+
try {
|
|
58
|
+
|
|
59
|
+
// Get reCaptchaV3 Data for becomeSeller mutation
|
|
60
|
+
const recaptchaDataForBecomeSeller = await generateReCaptchaData();
|
|
61
|
+
|
|
62
|
+
// Create the account and then sign in.
|
|
63
|
+
const result = await becomeSeller({
|
|
64
|
+
variables: {
|
|
65
|
+
seller_type: sellerType,
|
|
66
|
+
group_id: '',
|
|
67
|
+
url_key: formValues.seller.store_url,
|
|
68
|
+
name: formValues.seller.seller_profile_name,
|
|
69
|
+
company: formValues.seller.company_name,
|
|
70
|
+
company_registration_number: formValues.seller.company_registration_number,
|
|
71
|
+
country_id: formValues.seller.country_id,
|
|
72
|
+
address_line_1: formValues.seller.address_line_1,
|
|
73
|
+
address_line_2: formValues.seller.address_line_2,
|
|
74
|
+
city: formValues.seller.city,
|
|
75
|
+
region: formValues.seller.region,
|
|
76
|
+
region_id: formValues.seller.region_id,
|
|
77
|
+
postcode: formValues.seller.postcode,
|
|
78
|
+
contact_number: formValues.seller.contact_number
|
|
79
|
+
},
|
|
80
|
+
...recaptchaDataForBecomeSeller
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (result.data.becomeSeller.code) {
|
|
84
|
+
storage.setItem('is_seller', true);
|
|
85
|
+
|
|
86
|
+
globalThis.location.assign('/seller-account');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dispatch({
|
|
90
|
+
type: 'BECOME_SELLER',
|
|
91
|
+
payload: {
|
|
92
|
+
group_id: 'basic',
|
|
93
|
+
url_key: formValues.seller.store_url
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Finally, invoke the post-submission callback.
|
|
98
|
+
if (onSubmit) {
|
|
99
|
+
onSubmit();
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
103
|
+
console.error(error);
|
|
104
|
+
}
|
|
105
|
+
setIsSubmitting(false);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
[
|
|
110
|
+
generateReCaptchaData,
|
|
111
|
+
becomeSeller,
|
|
112
|
+
onSubmit,
|
|
113
|
+
dispatch
|
|
114
|
+
]
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const sanitizedInitialValues = useMemo(() => {
|
|
118
|
+
const { sellerProfileName, companyName, ...rest } = initialValues;
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
seller: { profile_name: sellerProfileName, company: companyName, country: "AF" },
|
|
122
|
+
...rest
|
|
123
|
+
};
|
|
124
|
+
}, [initialValues]);
|
|
125
|
+
|
|
126
|
+
const errors = useMemo(
|
|
127
|
+
() =>
|
|
128
|
+
new Map([
|
|
129
|
+
['becomeSellerQuery', becomeSellerError]
|
|
130
|
+
]),
|
|
131
|
+
[becomeSellerError]
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const isSeller = storage.getItem('is_seller') || false;
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
isSeller,
|
|
138
|
+
errors,
|
|
139
|
+
handleSubmit,
|
|
140
|
+
sellerType,
|
|
141
|
+
handleChange,
|
|
142
|
+
initialValues: sanitizedInitialValues,
|
|
143
|
+
isDisabled: isSubmitting || recaptchaLoading,
|
|
144
|
+
recaptchaWidgetProps
|
|
145
|
+
};
|
|
146
146
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
2
|
-
|
|
3
|
-
const storage = new BrowserPersistence();
|
|
4
|
-
|
|
5
|
-
export const useBecomeSellerLink = (props = {}) => {
|
|
6
|
-
const isSeller = storage.getItem('is_seller') || false;
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
isSeller
|
|
10
|
-
};
|
|
11
|
-
};
|
|
1
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
2
|
+
|
|
3
|
+
const storage = new BrowserPersistence();
|
|
4
|
+
|
|
5
|
+
export const useBecomeSellerLink = (props = {}) => {
|
|
6
|
+
const isSeller = storage.getItem('is_seller') || false;
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
isSeller
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
-
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
-
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
4
|
-
|
|
5
|
-
const validBecomeSellerParams = ['sellerUrl', 'companyName', 'sellerProfileName'];
|
|
6
|
-
|
|
7
|
-
const storage = new BrowserPersistence();
|
|
8
|
-
|
|
9
|
-
const getBecomeSellerInitialValues = search => {
|
|
10
|
-
const params = new URLSearchParams(search);
|
|
11
|
-
|
|
12
|
-
return validBecomeSellerParams.reduce(
|
|
13
|
-
(values, param) => ({ ...values, [param]: params.get(param) }),
|
|
14
|
-
{}
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {function} useBecomeSellerPage
|
|
20
|
-
*
|
|
21
|
-
* @param {String} props.signedInRedirectUrl - Url to push when user is signed in
|
|
22
|
-
* @param {String} props.signInPageUrl - Sign In Page url
|
|
23
|
-
*
|
|
24
|
-
* @returns {{
|
|
25
|
-
* becomeSellerProps: object
|
|
26
|
-
* }}
|
|
27
|
-
*/
|
|
28
|
-
export const useBecomeSellerPage = props => {
|
|
29
|
-
const { signedInRedirectUrl, signInPageUrl } = props;
|
|
30
|
-
const history = useHistory();
|
|
31
|
-
const { search } = useLocation();
|
|
32
|
-
|
|
33
|
-
const isSeller = storage.getItem('is_seller') || false;
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (isSeller) {
|
|
36
|
-
history.push('/')
|
|
37
|
-
}
|
|
38
|
-
}, [isSeller, history])
|
|
39
|
-
|
|
40
|
-
// const userCountryCode = storage.getItem('user_country_code');
|
|
41
|
-
|
|
42
|
-
// const isNotAllowedCountry = userCountryCode != "ID";
|
|
43
|
-
|
|
44
|
-
// useEffect(() => {
|
|
45
|
-
// if (isNotAllowedCountry) {
|
|
46
|
-
// history.push('/')
|
|
47
|
-
// }
|
|
48
|
-
// }, [isNotAllowedCountry, history])
|
|
49
|
-
|
|
50
|
-
// Keep location state in memory when pushing history and redirect to
|
|
51
|
-
// the `from` url instead when creating an account
|
|
52
|
-
const historyState = useMemo(() => {
|
|
53
|
-
return history && history.location.state ? history.location.state : {};
|
|
54
|
-
}, [history]);
|
|
55
|
-
|
|
56
|
-
const handleOnCancel = useCallback(() => {
|
|
57
|
-
if (signInPageUrl) {
|
|
58
|
-
history.push(signInPageUrl, historyState);
|
|
59
|
-
}
|
|
60
|
-
}, [history, historyState, signInPageUrl]);
|
|
61
|
-
|
|
62
|
-
const initialValues = useMemo(() => getBecomeSellerInitialValues(search), [
|
|
63
|
-
search
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
const becomeSellerProps = {
|
|
67
|
-
initialValues,
|
|
68
|
-
isCancelButtonHidden: false,
|
|
69
|
-
onCancel: handleOnCancel,
|
|
70
|
-
isSeller: isSeller
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
becomeSellerProps
|
|
75
|
-
};
|
|
76
|
-
};
|
|
1
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
4
|
+
|
|
5
|
+
const validBecomeSellerParams = ['sellerUrl', 'companyName', 'sellerProfileName'];
|
|
6
|
+
|
|
7
|
+
const storage = new BrowserPersistence();
|
|
8
|
+
|
|
9
|
+
const getBecomeSellerInitialValues = search => {
|
|
10
|
+
const params = new URLSearchParams(search);
|
|
11
|
+
|
|
12
|
+
return validBecomeSellerParams.reduce(
|
|
13
|
+
(values, param) => ({ ...values, [param]: params.get(param) }),
|
|
14
|
+
{}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {function} useBecomeSellerPage
|
|
20
|
+
*
|
|
21
|
+
* @param {String} props.signedInRedirectUrl - Url to push when user is signed in
|
|
22
|
+
* @param {String} props.signInPageUrl - Sign In Page url
|
|
23
|
+
*
|
|
24
|
+
* @returns {{
|
|
25
|
+
* becomeSellerProps: object
|
|
26
|
+
* }}
|
|
27
|
+
*/
|
|
28
|
+
export const useBecomeSellerPage = props => {
|
|
29
|
+
const { signedInRedirectUrl, signInPageUrl } = props;
|
|
30
|
+
const history = useHistory();
|
|
31
|
+
const { search } = useLocation();
|
|
32
|
+
|
|
33
|
+
const isSeller = storage.getItem('is_seller') || false;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (isSeller) {
|
|
36
|
+
history.push('/')
|
|
37
|
+
}
|
|
38
|
+
}, [isSeller, history])
|
|
39
|
+
|
|
40
|
+
// const userCountryCode = storage.getItem('user_country_code');
|
|
41
|
+
|
|
42
|
+
// const isNotAllowedCountry = userCountryCode != "ID";
|
|
43
|
+
|
|
44
|
+
// useEffect(() => {
|
|
45
|
+
// if (isNotAllowedCountry) {
|
|
46
|
+
// history.push('/')
|
|
47
|
+
// }
|
|
48
|
+
// }, [isNotAllowedCountry, history])
|
|
49
|
+
|
|
50
|
+
// Keep location state in memory when pushing history and redirect to
|
|
51
|
+
// the `from` url instead when creating an account
|
|
52
|
+
const historyState = useMemo(() => {
|
|
53
|
+
return history && history.location.state ? history.location.state : {};
|
|
54
|
+
}, [history]);
|
|
55
|
+
|
|
56
|
+
const handleOnCancel = useCallback(() => {
|
|
57
|
+
if (signInPageUrl) {
|
|
58
|
+
history.push(signInPageUrl, historyState);
|
|
59
|
+
}
|
|
60
|
+
}, [history, historyState, signInPageUrl]);
|
|
61
|
+
|
|
62
|
+
const initialValues = useMemo(() => getBecomeSellerInitialValues(search), [
|
|
63
|
+
search
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
const becomeSellerProps = {
|
|
67
|
+
initialValues,
|
|
68
|
+
isCancelButtonHidden: false,
|
|
69
|
+
onCancel: handleOnCancel,
|
|
70
|
+
isSeller: isSeller
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
becomeSellerProps
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useWebsiteSwitcher = (props = {}) => {
|
|
4
|
-
const handleTriggerClick = useCallback(() => {
|
|
5
|
-
// Toggle Stores Menu.
|
|
6
|
-
// setStoreMenuIsOpen(isOpen => !isOpen);
|
|
7
|
-
// globalThis.location.assign(`${newPath || ''}`);
|
|
8
|
-
}, []);
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
handleTriggerClick
|
|
12
|
-
};
|
|
13
|
-
};
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useWebsiteSwitcher = (props = {}) => {
|
|
4
|
+
const handleTriggerClick = useCallback(() => {
|
|
5
|
+
// Toggle Stores Menu.
|
|
6
|
+
// setStoreMenuIsOpen(isOpen => !isOpen);
|
|
7
|
+
// globalThis.location.assign(`${newPath || ''}`);
|
|
8
|
+
}, []);
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
handleTriggerClick
|
|
12
|
+
};
|
|
13
|
+
};
|