@riosst100/pwa-marketplace 1.0.5 → 1.0.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.
- package/package.json +1 -1
- package/src/componentOverrideMapping.js +1 -0
- package/src/components/BecomeSeller/becomeSeller.js +20 -4
- package/src/components/BecomeSellerLink/becomeSellerLink.js +1 -1
- package/src/components/SellerAccountPage/sellerAccountPage.js +1 -3
- package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -0
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ module.exports = componentOverrideMapping = {
|
|
|
7
7
|
[`@magento/peregrine/lib/talons/Adapter/useAdapter.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js',
|
|
8
8
|
[`@magento/peregrine/lib/talons/Header/useStoreSwitcher.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js',
|
|
9
9
|
[`@magento/peregrine/lib/talons/Header/storeSwitcher.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js',
|
|
10
|
+
[`@magento/peregrine/lib/talons/Region/useRegion.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Region/useRegion.js',
|
|
10
11
|
[`@magento/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql`]: '@riosst100/pwa-marketplace/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql',
|
|
11
12
|
[`@magento/peregrine/lib/store/actions/user/asyncActions.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js',
|
|
12
13
|
[`@magento/peregrine/lib/talons/SignIn/signIn.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js',
|
|
@@ -22,6 +22,8 @@ import GoogleRecaptcha from '@magento/venia-ui/lib/components/GoogleReCaptcha';
|
|
|
22
22
|
import Country from '@magento/venia-ui/lib/components/Country';
|
|
23
23
|
import Region from '@magento/venia-ui/lib/components/Region';
|
|
24
24
|
import Postcode from '@magento/venia-ui/lib/components/Postcode';
|
|
25
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
26
|
+
import { Link } from 'react-router-dom';
|
|
25
27
|
|
|
26
28
|
const BecomeSeller = props => {
|
|
27
29
|
const talonProps = useBecomeSeller({
|
|
@@ -257,6 +259,7 @@ const BecomeSeller = props => {
|
|
|
257
259
|
id: 'global.region',
|
|
258
260
|
defaultMessage: 'Region'
|
|
259
261
|
})}
|
|
262
|
+
translationId="global.region"
|
|
260
263
|
countryCodeField="seller.country_id"
|
|
261
264
|
validate={isRequired}
|
|
262
265
|
/>
|
|
@@ -286,10 +289,23 @@ const BecomeSeller = props => {
|
|
|
286
289
|
field="become_seller_agreement"
|
|
287
290
|
id="becomeSellerAgreement"
|
|
288
291
|
validate={isRequired}
|
|
289
|
-
label={
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
label={(
|
|
293
|
+
<>
|
|
294
|
+
{formatMessage({
|
|
295
|
+
id: 'becomeSeller.becomeSellerAgreementText',
|
|
296
|
+
defaultMessage: 'I agree the Terms and Condition'
|
|
297
|
+
})} <span>
|
|
298
|
+
(<a href={'/seller-term-conditions'}>
|
|
299
|
+
<u>
|
|
300
|
+
{formatMessage({
|
|
301
|
+
id: 'becomeSellerPage.termConditions',
|
|
302
|
+
defaultMessage: 'Terms and Conditions'
|
|
303
|
+
})}
|
|
304
|
+
</u>
|
|
305
|
+
</a>)
|
|
306
|
+
</span>
|
|
307
|
+
</>
|
|
308
|
+
)}
|
|
293
309
|
/>
|
|
294
310
|
</div>
|
|
295
311
|
<GoogleRecaptcha {...recaptchaWidgetProps} />
|
|
@@ -17,7 +17,7 @@ const BecomeSellerLink = props => {
|
|
|
17
17
|
|
|
18
18
|
return isSeller ? (
|
|
19
19
|
<div className={classes.root} data-cy="BecomeSellerLink-root">
|
|
20
|
-
<a href=
|
|
20
|
+
<a href={process.env.MAGENTO_BACKEND_URL + "/lofmarketplace/seller/login"}>
|
|
21
21
|
{formatMessage({
|
|
22
22
|
id: 'sellerDashboard.title',
|
|
23
23
|
defaultMessage: 'Seller Dashboard'
|
|
@@ -70,9 +70,7 @@ const SellerAccountPage = props => {
|
|
|
70
70
|
</span>
|
|
71
71
|
</div>
|
|
72
72
|
<div className={classes.editButtonContainer}>
|
|
73
|
-
<a href=
|
|
74
|
-
className={classes.editInformationButton}
|
|
75
|
-
>
|
|
73
|
+
<a href={process.env.MAGENTO_BACKEND_URL + "/lofmarketplace/seller/login"} className={classes.editInformationButton}>
|
|
76
74
|
<FormattedMessage
|
|
77
75
|
id={'global.sellerDashboardText'}
|
|
78
76
|
defaultMessage={'Seller Dashboard'}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useQuery } from '@apollo/client';
|
|
3
|
+
import { useFieldApi } from 'informed';
|
|
4
|
+
import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInformedFieldStateWrapper';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The useRegion talon handles logic for:
|
|
8
|
+
*
|
|
9
|
+
* * Resetting the region field value when the country changes.
|
|
10
|
+
* * Querying for available regions for a country and rendering them.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} props
|
|
13
|
+
* @param {string} props.countryCodeField
|
|
14
|
+
* @param {string} props.fieldInput - the reference field path for free form text input Defaults to "region".
|
|
15
|
+
* @param {string} props.fieldSelect - the reference field path for selectable list of regions. Defaults to "region".
|
|
16
|
+
* @param {string} props.optionValueKey - the key used to get the value for the field. Defaults to "code"
|
|
17
|
+
* @param {GraphQLAST} props.queries.getRegionsQuery - query to fetch regions for a country.
|
|
18
|
+
*
|
|
19
|
+
* @return {RegionTalonProps}
|
|
20
|
+
*/
|
|
21
|
+
export const useRegion = props => {
|
|
22
|
+
const {
|
|
23
|
+
countryCodeField = 'country',
|
|
24
|
+
fieldInput = 'region',
|
|
25
|
+
fieldSelect = 'region',
|
|
26
|
+
optionValueKey = 'code',
|
|
27
|
+
queries: { getRegionsQuery }
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
const hasInitialized = useRef(false);
|
|
31
|
+
const countryFieldState = useFieldState(countryCodeField);
|
|
32
|
+
const { value: country } = countryFieldState;
|
|
33
|
+
|
|
34
|
+
const regionInputFieldApi = useFieldApi(fieldInput);
|
|
35
|
+
const regionSelectFieldApi = useFieldApi(fieldSelect);
|
|
36
|
+
|
|
37
|
+
const { data, loading } = useQuery(getRegionsQuery, {
|
|
38
|
+
variables: { countryCode: country },
|
|
39
|
+
skip: !country
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Reset region value when country changes. Because of how Informed sets
|
|
43
|
+
// initialValues, we want to skip the first state change of the value being
|
|
44
|
+
// initialized.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (country && !loading) {
|
|
47
|
+
if (hasInitialized.current) {
|
|
48
|
+
regionInputFieldApi.exists() && regionInputFieldApi.setValue();
|
|
49
|
+
regionSelectFieldApi.exists() &&
|
|
50
|
+
regionSelectFieldApi.setValue();
|
|
51
|
+
} else {
|
|
52
|
+
hasInitialized.current = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [country, regionInputFieldApi, regionSelectFieldApi, loading]);
|
|
56
|
+
|
|
57
|
+
let formattedRegionsData = [{ label: 'Loading Regions...', value: '' }];
|
|
58
|
+
if (data) {
|
|
59
|
+
const { country } = data;
|
|
60
|
+
const { available_regions: availableRegions } = country;
|
|
61
|
+
if (availableRegions) {
|
|
62
|
+
formattedRegionsData = availableRegions.map(region => ({
|
|
63
|
+
key: region.id,
|
|
64
|
+
label: region.name,
|
|
65
|
+
value: region[optionValueKey]
|
|
66
|
+
}));
|
|
67
|
+
formattedRegionsData.unshift({
|
|
68
|
+
disabled: true,
|
|
69
|
+
hidden: true,
|
|
70
|
+
label: '',
|
|
71
|
+
value: ''
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
formattedRegionsData = [];
|
|
75
|
+
}
|
|
76
|
+
} else if (!loading) {
|
|
77
|
+
formattedRegionsData = [];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
loading,
|
|
82
|
+
regions: formattedRegionsData
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** JSDocs type definitions */
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {Object} RegionTalonProps
|
|
90
|
+
*
|
|
91
|
+
* @property {boolean} loading whether the regions are loading
|
|
92
|
+
* @property {Array<Region>} regions array of formatted regions for the country
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {Object} Region
|
|
98
|
+
*
|
|
99
|
+
* @property {number} key the id of the region
|
|
100
|
+
* @property {String} label the label of the region
|
|
101
|
+
* @property {String} value the value of the region
|
|
102
|
+
*/
|