@woosmap/ui 4.156.1 → 4.156.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "4.156.1",
3
+ "version": "4.156.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -4,8 +4,34 @@ import PricingSlider from './PricingSlider';
4
4
  import PricingData from './PricingData';
5
5
 
6
6
  class PricingSimulator extends Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.state = { currency: '€' };
10
+ }
11
+
12
+ componentDidMount() {
13
+ this.getCurrencyFromLocation();
14
+ }
15
+
16
+ getCurrencyFromLocation = async () => {
17
+ const { publicKey } = this.props;
18
+ if (publicKey) {
19
+ const geolocation = await fetch(`https://api.woosmap.com/geolocation/position?key=${publicKey}`)
20
+ .then((response) => response.json())
21
+ .catch(() => null);
22
+ if (geolocation && geolocation.country_code) {
23
+ if (geolocation.country_code === 'GB') {
24
+ this.setState({ currency: '£' });
25
+ } else if (geolocation.country_code === 'US') {
26
+ this.setState({ currency: '$' });
27
+ }
28
+ }
29
+ }
30
+ };
31
+
7
32
  render() {
8
- const { publicMode, currency } = this.props;
33
+ const { publicMode } = this.props;
34
+ const { currency } = this.state;
9
35
  return (
10
36
  <div className="pricing-simulator__wrapper">
11
37
  {Object.keys(PricingData).map((category) => (
@@ -36,8 +62,8 @@ class PricingSimulator extends Component {
36
62
  }
37
63
  }
38
64
 
39
- PricingSimulator.defaultProps = { currency: '€', publicMode: true };
65
+ PricingSimulator.defaultProps = { publicMode: true, publicKey: null };
40
66
 
41
- PricingSimulator.propTypes = { currency: PropTypes.string, publicMode: PropTypes.bool };
67
+ PricingSimulator.propTypes = { publicMode: PropTypes.bool, publicKey: PropTypes.string };
42
68
 
43
69
  export default PricingSimulator;
@@ -7,7 +7,8 @@ import { Button, Input, tr } from '@woosmap/ui';
7
7
  class PricingSlider extends Component {
8
8
  constructor(props) {
9
9
  super(props);
10
- const { defaultQueries } = props;
10
+ const { productPricing } = props;
11
+ const { defaultQueries } = productPricing;
11
12
  this.state = {
12
13
  queries: defaultQueries,
13
14
  };