@woosmap/ui 4.162.7 → 4.162.9

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.162.7",
3
+ "version": "4.162.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -12,14 +12,16 @@ class PricingSimulator extends Component {
12
12
  if (!sliders[category]) {
13
13
  sliders[category] = {};
14
14
  }
15
- sliders[category][pricingKey] = { queries: PricingData[category].pricings[pricingKey].defaultQueries };
15
+ sliders[category][pricingKey] = {
16
+ queries: PricingData[category].pricings[pricingKey].defaultQueries || 0,
17
+ amount: 0,
18
+ };
16
19
  });
17
20
  });
18
21
  this.state = { sliders };
19
22
  }
20
23
 
21
24
  onChange = (category, pricingKey) => (data) => {
22
- console.log(pricingKey, data);
23
25
  const { sliders } = this.state;
24
26
  const newSliders = { ...sliders };
25
27
  newSliders[category][pricingKey] = data;
@@ -35,13 +37,13 @@ class PricingSimulator extends Component {
35
37
  Object.keys(sliders).forEach((category) => {
36
38
  Object.keys(sliders[category]).forEach((pricingKey) => {
37
39
  const { discountEligible } = PricingData[category].pricings[pricingKey];
38
- const { amount, queries } = sliders[category];
39
- if (Number.isNaN(amount) || Number.isNaN(queries)) {
40
+ const { amount, queries } = sliders[category][pricingKey];
41
+ if (typeof amount !== 'number' || typeof queries !== 'number') {
40
42
  console.log('REJECT', pricingKey, amount, queries);
41
43
  return;
42
44
  }
43
45
  if (discountEligible) {
44
- if (!Number.isNaN(freeQueriesTotal)) {
46
+ if (typeof freeQueriesTotal === 'number') {
45
47
  freeQueriesTotal += queries;
46
48
  }
47
49
  console.log('Eligible', pricingKey, eligibleTotal, amount, queries, freeQueriesTotal);
@@ -53,15 +55,20 @@ class PricingSimulator extends Component {
53
55
  }
54
56
  });
55
57
  });
56
- const total = notEligibleTotal + eligibleTotal;
57
- console.log(total, freeQueriesTotal, notEligibleTotal, eligibleTotal);
58
+ const { currency } = this.props;
59
+ const discount = currency === '$' ? 180 : 200;
60
+ const total = notEligibleTotal + Math.max(eligibleTotal - discount, 0);
58
61
  return { total, freeQueriesTotal, notEligibleTotal, eligibleTotal };
59
62
  };
60
63
 
61
64
  render() {
62
65
  const { sliders } = this.state;
63
66
  const { publicMode, currency } = this.props;
64
- const { total } = this.computeTotal();
67
+ const { total, freeQueriesTotal, notEligibleTotal } = this.computeTotal();
68
+ let totalDisplayed = total;
69
+ if (notEligibleTotal === 0 && freeQueriesTotal < 10000) {
70
+ totalDisplayed = 0;
71
+ }
65
72
  return (
66
73
  <>
67
74
  <div className="pricing-nav">
@@ -74,7 +81,7 @@ class PricingSimulator extends Component {
74
81
  </ul>
75
82
  <div className="pricing-total">
76
83
  <div className="pricing-total__label">Monthly price</div>
77
- <div className="pricing-total__amount">{total + currency}</div>
84
+ <div className="pricing-total__amount">{totalDisplayed + currency}</div>
78
85
  </div>
79
86
  </div>
80
87
  <div className="pricing-simulator__wrapper">