@riosst100/pwa-marketplace 1.1.8 → 1.2.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "1.1.8",
4
+ "version": "1.2.0",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -9,7 +9,8 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "axios": "^1.6.5"
12
+ "axios": "^1.6.5",
13
+ "react-phone-number-input": "^3.3.9"
13
14
  },
14
15
  "license": "MIT",
15
16
  "private": false
@@ -24,7 +24,7 @@ import Region from '@magento/venia-ui/lib/components/Region';
24
24
  import Postcode from '@magento/venia-ui/lib/components/Postcode';
25
25
  import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
26
26
  import { Link } from 'react-router-dom';
27
- import PhoneInput from '@riosst100/pwa-marketplace/src/components/PhoneInput';
27
+ import PhoneTextInput from '@riosst100/pwa-marketplace/src/components/PhoneTextInput';
28
28
 
29
29
  const BecomeSeller = props => {
30
30
  const talonProps = useBecomeSeller({
@@ -274,9 +274,10 @@ const BecomeSeller = props => {
274
274
  defaultMessage: 'Contact Number'
275
275
  })}
276
276
  >
277
- <PhoneInput
277
+ <PhoneTextInput
278
278
  id="contactNumber"
279
279
  field="seller.contact_number"
280
+ countryCodeField="seller.country_id"
280
281
  validate={isRequired}
281
282
  />
282
283
  </Field>
@@ -312,6 +313,17 @@ const BecomeSeller = props => {
312
313
  ) : '';
313
314
  };
314
315
 
316
+ BecomeSeller.defaultProps = {
317
+ seller: {
318
+ country: {
319
+ code: DEFAULT_COUNTRY_CODE
320
+ },
321
+ region: {
322
+ id: null
323
+ }
324
+ }
325
+ };
326
+
315
327
  BecomeSeller.propTypes = {
316
328
  classes: shape({
317
329
  actions: string,
@@ -0,0 +1 @@
1
+ export { default } from './phoneTextInput';
@@ -1,12 +1,14 @@
1
- import React, { Fragment } from 'react';
1
+ import React, { Fragment, useState } from 'react';
2
2
  import { node, shape, string } from 'prop-types';
3
3
  import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInformedFieldStateWrapper';
4
4
 
5
5
  import { useStyle } from '@magento/venia-ui/lib/classify';
6
6
  import { FieldIcons, Message } from '@magento/venia-ui/lib/components/Field';
7
- import defaultClasses from './phoneInput.module.css';
7
+ import defaultClasses from './phoneTextInput.module.css';
8
+ import PhoneInput from 'react-phone-number-input'
9
+ import 'react-phone-number-input/style.css'
8
10
 
9
- const PhoneInput = props => {
11
+ const PhoneTextInput = props => {
10
12
  const {
11
13
  after,
12
14
  before,
@@ -14,6 +16,7 @@ const PhoneInput = props => {
14
16
  regionError,
15
17
  field,
16
18
  message,
19
+ countryCodeField,
17
20
  ...rest
18
21
  } = props;
19
22
  const fieldState = useFieldState(field);
@@ -21,7 +24,10 @@ const PhoneInput = props => {
21
24
  var inputClass =
22
25
  fieldState.error || regionError ? classes.input_error : classes.input;
23
26
 
24
- const [value, setValue] = useState(null);
27
+ const [value, setValue] = useState('');
28
+
29
+ const countryFieldState = useFieldState(countryCodeField);
30
+ const { value: country } = countryFieldState;
25
31
 
26
32
  return (
27
33
  <Fragment>
@@ -29,7 +35,7 @@ const PhoneInput = props => {
29
35
  <PhoneInput
30
36
  international
31
37
  countryCallingCodeEditable={false}
32
- defaultCountry="ID"
38
+ defaultCountry={country}
33
39
  value={value}
34
40
  onChange={setValue}/>
35
41
  </FieldIcons>
@@ -38,9 +44,9 @@ const PhoneInput = props => {
38
44
  );
39
45
  };
40
46
 
41
- export default PhoneInput;
47
+ export default PhoneTextInput;
42
48
 
43
- PhoneInput.propTypes = {
49
+ PhoneTextInput.propTypes = {
44
50
  after: node,
45
51
  before: node,
46
52
  classes: shape({
@@ -1,11 +1,11 @@
1
1
  .input {
2
- composes: input from '../Field/field.module.css';
2
+ composes: input from '@magento/venia-ui/lib/components/Field/field.module.css';
3
3
 
4
4
  composes: disabled_text-subtle from global;
5
5
  }
6
6
 
7
7
  .input_error {
8
- composes: input from '../Field/field.module.css';
8
+ composes: input from '@magento/venia-ui/lib/components/Field/field.module.css';
9
9
 
10
10
  composes: border-error from global;
11
11
  }
@@ -8,6 +8,9 @@ import Field from '@magento/venia-ui/lib/components/Field';
8
8
  import Select from '@magento/venia-ui/lib/components/Select';
9
9
  import defaultClasses from './sellerCountry.module.css';
10
10
  import { GET_SELLER_COUNTRIES_QUERY } from './sellerCountry.gql';
11
+ import { BrowserPersistence } from '@magento/peregrine/lib/util';
12
+
13
+ const storage = new BrowserPersistence();
11
14
 
12
15
  const SellerCountry = props => {
13
16
  const talonProps = useSellerCountry({
@@ -26,11 +29,14 @@ const SellerCountry = props => {
26
29
  const { formatMessage } = useIntl();
27
30
 
28
31
  const classes = useStyle(defaultClasses, propClasses);
32
+ const websiteCode = storage.getItem('website_code') || null;
33
+ const currentWebsiteCountry = websiteCode && websiteCode != "base" ? websiteCode.toUpperCase() : DEFAULT_COUNTRY_CODE;
29
34
  const selectProps = {
30
35
  classes,
31
36
  disabled: loading,
32
37
  field,
33
38
  items: countries,
39
+ initialValue: currentWebsiteCountry,
34
40
  ...inputProps
35
41
  };
36
42
 
@@ -119,8 +119,6 @@ export const useSignIn = props => {
119
119
  fetchPolicy: 'cache-only'
120
120
  });
121
121
 
122
- console.log(data.customer)
123
-
124
122
  if (data.customer.is_seller) {
125
123
  storage.setItem('is_seller', true);
126
124
  }
@@ -108,7 +108,6 @@ export const useWebsiteSwitcher = (props = {}) => {
108
108
 
109
109
  // availableStores => mapped options or empty map if undefined.
110
110
  const availableStores = useMemo(() => {
111
- console.log(availableStoresData)
112
111
  return (
113
112
  (storeConfigData &&
114
113
  availableStoresData &&
@@ -13,7 +13,6 @@ export const useWebsiteByIp = websiteCodeInUrl => {
13
13
  setWebsiteByUserIpData(data)
14
14
  }
15
15
  }).catch((error) => {
16
- console.log(error);
17
16
  });
18
17
  };
19
18
 
@@ -1 +0,0 @@
1
- export { default } from './phoneInput';