@woosmap/ui 4.226.4 → 4.226.6

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.
@@ -163,7 +163,7 @@ export default class PricingSimulator extends Component {
163
163
 
164
164
  render() {
165
165
  const { sliders } = this.state;
166
- const { publicMode, currency } = this.props;
166
+ const { currency, hlPricings, planId } = this.props;
167
167
  const { total, contactSale, totalBeforeDiscount } = this.computeTotal();
168
168
  const totalDisplayed = this.displayAmount(parseInt(total, 10), currency);
169
169
  // if (contactSale) {
@@ -221,10 +221,11 @@ export default class PricingSimulator extends Component {
221
221
  productPricing={productPricing}
222
222
  name={pricingKey}
223
223
  key={`pricing_${pricingKey.replace(' ', '')}`}
224
- publicMode={publicMode}
225
224
  currency={currency}
226
225
  values={sliders[category][pricingKey]}
227
226
  onChange={this.onChange(category, pricingKey)}
227
+ hlPricings={hlPricings}
228
+ planId={planId}
228
229
  />
229
230
  );
230
231
  })}
@@ -261,9 +262,10 @@ export default class PricingSimulator extends Component {
261
262
  }
262
263
  }
263
264
 
264
- PricingSimulator.defaultProps = { currency: '€', publicMode: true };
265
+ PricingSimulator.defaultProps = { currency: '€', planId: 'plan_ohNpgeVMtJ3veT' };
265
266
 
266
267
  PricingSimulator.propTypes = {
267
268
  currency: PropTypes.string,
268
- publicMode: PropTypes.bool,
269
+ hlPricings: PropTypes.object.isRequired,
270
+ planId: PropTypes.string,
269
271
  };
@@ -6,10 +6,12 @@ const Story = {
6
6
  component: PricingSimulator,
7
7
  };
8
8
 
9
+ const hlPricings = require('./hl-pricings.json');
10
+
9
11
  export default Story;
10
12
 
11
13
  function Template() {
12
- return <PricingSimulator />;
14
+ return <PricingSimulator hlPricings={hlPricings} />;
13
15
  }
14
16
  export const Default = Template.bind({
15
17
  type: 'normal',
@@ -7,6 +7,12 @@ import Button from '../Button/Button';
7
7
  import { tr } from '../utils/locale';
8
8
  import Icon from '../Icon/Icon';
9
9
 
10
+ const currencyMap = {
11
+ $: 'USD',
12
+ '€': 'EUR',
13
+ '£': 'GBP',
14
+ };
15
+
10
16
  export default class PricingSlider extends Component {
11
17
  constructor(props) {
12
18
  super(props);
@@ -88,9 +94,8 @@ export default class PricingSlider extends Component {
88
94
  );
89
95
 
90
96
  renderMarks = (props) => {
91
- const { productPricing, publicMode } = this.props;
92
- const { pricing, publicTierCount } = productPricing;
93
- const displayedPricing = publicMode ? pricing.slice(0, publicTierCount + 1) : pricing;
97
+ const { publicMode } = this.props;
98
+ const displayedPricing = this.getDisplayedPricing();
94
99
 
95
100
  let value;
96
101
  if (props.key === 0) {
@@ -114,10 +119,18 @@ export default class PricingSlider extends Component {
114
119
 
115
120
  getMarks = (displayedPricing) => [-1, ...displayedPricing.keys()].map((key) => (key + 1) * 100000);
116
121
 
122
+ findProduct = (productId) => {
123
+ const { hlPricings } = this.props;
124
+ return hlPricings.find((product) => product.id === productId);
125
+ };
126
+
117
127
  getDisplayedPricing = () => {
118
- const { productPricing, publicMode } = this.props;
119
- const { pricing, publicTierCount } = productPricing;
120
- return publicMode ? pricing.slice(0, publicTierCount + 1) : pricing;
128
+ const { productPricing, currency, planId } = this.props;
129
+ const product = this.findProduct(productPricing.productId);
130
+
131
+ return product && product.pricings[planId] && product.pricings[planId][currencyMap[currency]]
132
+ ? product.pricings[planId][currencyMap[currency]]
133
+ : [];
121
134
  };
122
135
 
123
136
  getDisplayedData = (queries) => {
@@ -169,14 +182,6 @@ export default class PricingSlider extends Component {
169
182
  {displayedPricing.map((tier, index) => {
170
183
  const lower = index > 0 ? displayedPricing[index - 1][0] : 0;
171
184
  if (index === displayedPricing.length - 1) {
172
- return (
173
- <tr>
174
- <td>{`${numeral(lower).format('0.[0]a')}+`}</td>
175
- <td>{tr('Contact us for discount')}</td>
176
- </tr>
177
- );
178
- }
179
- if (index === displayedPricing.length - 2) {
180
185
  return (
181
186
  <tr>
182
187
  <td>{`${numeral(lower).format('0.[0]a')}+`}</td>
@@ -192,6 +197,7 @@ export default class PricingSlider extends Component {
192
197
  );
193
198
  })}
194
199
  </table>
200
+ {displayedPricing.length === 1 && displayedPricing[0][1] === 0 ? null : tr('For more, contact us')}
195
201
  </div>
196
202
  );
197
203
  };
@@ -287,7 +293,10 @@ export default class PricingSlider extends Component {
287
293
  }
288
294
  }
289
295
 
290
- PricingSlider.defaultProps = { defaultQueries: 1500, onChange: null };
296
+ PricingSlider.defaultProps = {
297
+ defaultQueries: 1500,
298
+ onChange: null,
299
+ };
291
300
 
292
301
  PricingSlider.propTypes = {
293
302
  productPricing: PropTypes.object.isRequired,
@@ -298,4 +307,6 @@ PricingSlider.propTypes = {
298
307
  onChange: PropTypes.func,
299
308
  values: PropTypes.object.isRequired,
300
309
  id: PropTypes.string.isRequired,
310
+ planId: PropTypes.string.isRequired,
311
+ hlPricings: PropTypes.object.isRequired,
301
312
  };