@procraft/widget-order 2.31.1 → 2.31.2

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/dist/utils.js CHANGED
@@ -18,10 +18,8 @@ const roundStd = (num, decimalPlaces) => {
18
18
  exports.roundStd = roundStd;
19
19
  const getCurrencyPrefix = (currency) => {
20
20
  switch (currency) {
21
- case 'USD':
22
- return '$';
23
- default:
24
- return '';
21
+ case 'USD': return '$';
22
+ default: return '';
25
23
  }
26
24
  };
27
25
  exports.getCurrencyPrefix = getCurrencyPrefix;
@@ -36,7 +34,7 @@ const getCurrencySuffix = (currency) => {
36
34
  case 'UAH':
37
35
  return ' ₴';
38
36
  default:
39
- return ` ${currency}`;
37
+ return `\u202F${currency}`;
40
38
  }
41
39
  };
42
40
  exports.getCurrencySuffix = getCurrencySuffix;
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuC;AAGhC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE;IAChD,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAA;IACnB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;AAClC,CAAC,CAAA;AAHY,QAAA,WAAW,eAGvB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,aAAqB,EAAE,EAAE;IAC7D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,CAAC,CAAA;IAElC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;AACpC,CAAC,CAAA;AALY,QAAA,QAAQ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}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@procraft/widget-order",
3
3
  "description": "Order widget for landing",
4
- "version": "2.31.1",
4
+ "version": "2.31.2",
5
5
  "private": false,
6
6
  "main": "dist",
7
7
  "scripts": {
@@ -6,7 +6,6 @@ import React, {
6
6
  useMemo,
7
7
  useState,
8
8
  } from 'react'
9
- import NumberFormat from 'react-number-format'
10
9
  import Button from '../../components/Button'
11
10
  import Container from '../../components/Container'
12
11
  import OldPrice from '../../components/OldPrice'
@@ -25,6 +24,7 @@ import {
25
24
  import { getCurrencyPrefix, getCurrencySuffix } from '../../utils'
26
25
  import { OrderButtonProps } from './interfaces'
27
26
  import { OrderButtonByDateSalesStyled } from './styles'
27
+ import { PriceFormat } from '../../PriceFormat'
28
28
 
29
29
  /**
30
30
  * Кнопка заказа
@@ -238,13 +238,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
238
238
  {price ? (
239
239
  <>
240
240
  {promoCode ? 'По промо за ' : 'Купить за '}
241
- <NumberFormat
242
- value={price}
243
- displayType="text"
244
- thousandSeparator={' '}
245
- prefix={currencyPrefix}
246
- suffix={currencySuffix}
247
- />
241
+ <PriceFormat prefix={currencyPrefix} suffix={currencySuffix} value={price} />
248
242
  </>
249
243
  ) : (
250
244
  'Зарегистрироваться'
@@ -1,5 +1,4 @@
1
1
  import React, { useMemo } from 'react'
2
- import NumberFormat from 'react-number-format'
3
2
  import Button from '../../../components/Button'
4
3
  import OldPrice from '../../../components/OldPrice'
5
4
  import {
@@ -12,6 +11,7 @@ import { CatalogFieldValue } from '../../../modules/gql/generated/types'
12
11
  import { getCurrencyPrefix, getCurrencySuffix } from '../../../utils'
13
12
  import { SaleProps } from './interfaces'
14
13
  import { SaleStyled } from './styles'
14
+ import { PriceFormat } from '../../../PriceFormat'
15
15
 
16
16
  /**
17
17
  * Считаем стоимость с учетом скидки
@@ -56,6 +56,10 @@ const Sale: React.FC<SaleProps> = ({
56
56
  titleTextColor,
57
57
  ...other
58
58
  }) => {
59
+
60
+ const currencyPrefix = getCurrencyPrefix(catalogItem.master?.currency || '')
61
+ const currencySuffix = getCurrencySuffix(catalogItem.master?.currency || '')
62
+
59
63
  const {
60
64
  canOrder,
61
65
  items,
@@ -178,16 +182,9 @@ const Sale: React.FC<SaleProps> = ({
178
182
  {index > 0 ? '+ ' : ''}
179
183
  {n.name}
180
184
  </span>{' '}
181
- {priceWithDiscount ? (
182
- <span>
183
- <NumberFormat
184
- value={priceWithDiscount}
185
- displayType="text"
186
- thousandSeparator=" "
187
- />{' '}
188
- ₽
189
- </span>
190
- ) : null}
185
+ {priceWithDiscount && (
186
+ <PriceFormat prefix={currencyPrefix} suffix={currencySuffix} value={price} />
187
+ )}
191
188
  </span>
192
189
  )
193
190
  })
@@ -199,7 +196,7 @@ const Sale: React.FC<SaleProps> = ({
199
196
  totalPrice,
200
197
  saleFieldsValueSelected,
201
198
  }
202
- }, [fieldsValueSelected, sale])
199
+ }, [fieldsValueSelected, sale, currencyPrefix, currencySuffix])
203
200
 
204
201
  const uri = useOrderLink({
205
202
  catalogItem,
@@ -242,19 +239,18 @@ const Sale: React.FC<SaleProps> = ({
242
239
  </div>
243
240
  <div className="content">
244
241
  <p style={{ color: titleTextColor }} className="title">
245
- Дополнительно Скидка{' '}
242
+ Дополнительно скидка{' '}
246
243
  {sale.benefitUnit === 'Percent'
247
- ? `${Math.round(
248
- ((totalPriceOriginal - totalPrice) / totalPriceOriginal) * 100
249
- )}%`
250
- : `${totalPriceOriginal - totalPrice} ₽`}
244
+ ? `${Math.round(((totalPriceOriginal - totalPrice) / totalPriceOriginal) * 100)}%`
245
+ : <PriceFormat value={totalPriceOriginal - totalPrice} prefix={currencyPrefix} suffix={currencySuffix} />
246
+ }
251
247
  </p>
252
248
 
253
249
  <div className="items">{items}</div>
254
250
 
255
251
  <div className="prices">
256
252
  <div>
257
- <OldPrice price={totalPriceOriginal} />
253
+ <OldPrice price={totalPriceOriginal} prefix={currencyPrefix} suffix={currencySuffix} />
258
254
  </div>
259
255
 
260
256
  <a href={uri.toString()}>
@@ -266,14 +262,7 @@ const Sale: React.FC<SaleProps> = ({
266
262
  className="buy-link"
267
263
  >
268
264
  Купить за{' '}
269
- <NumberFormat
270
- value={totalPrice}
271
- displayType="text"
272
- thousandSeparator={' '}
273
- decimalScale={0}
274
- prefix={getCurrencyPrefix(catalogItem.master?.currency || '')}
275
- suffix={getCurrencySuffix(catalogItem.master?.currency || '')}
276
- />
265
+ <PriceFormat prefix={currencyPrefix} suffix={currencySuffix} value={totalPrice} />
277
266
  </Button>
278
267
  </a>
279
268
  </div>
@@ -293,6 +282,8 @@ const Sale: React.FC<SaleProps> = ({
293
282
  buttonColor,
294
283
  buttonTextColor,
295
284
  titleTextColor,
285
+ currencyPrefix,
286
+ currencySuffix,
296
287
  ])
297
288
  }
298
289
 
@@ -0,0 +1,17 @@
1
+ import NumberFormat from 'react-number-format'
2
+ import React from 'react'
3
+
4
+ export const PriceFormat: React.FC<{
5
+ prefix: string | undefined,
6
+ suffix: string | undefined,
7
+ value: number,
8
+ }> = ({ prefix, suffix, value }) => (
9
+ <NumberFormat
10
+ value={value}
11
+ displayType="text"
12
+ thousandSeparator={'\u202F'}
13
+ decimalScale={0}
14
+ prefix={prefix}
15
+ suffix={suffix}
16
+ />
17
+ )
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
- import NumberFormat from 'react-number-format'
3
2
  import { OldPriceProps } from './interfaces'
4
3
  import { OldPriceStyled } from './styles'
4
+ import { PriceFormat } from '../../PriceFormat'
5
5
 
6
6
  const OldPrice: React.FC<OldPriceProps> = ({
7
7
  price,
@@ -11,14 +11,7 @@ const OldPrice: React.FC<OldPriceProps> = ({
11
11
  }) => {
12
12
  return (
13
13
  <OldPriceStyled component="span" {...other}>
14
- <NumberFormat
15
- value={price}
16
- displayType={'text'}
17
- thousandSeparator={' '}
18
- decimalScale={0}
19
- prefix={prefix}
20
- suffix={suffix}
21
- />{' '}
14
+ <PriceFormat prefix={prefix} suffix={suffix} value={price} />
22
15
  </OldPriceStyled>
23
16
  )
24
17
  }
@@ -14,8 +14,6 @@ import { ContainerStyled } from '../Container/styles'
14
14
  import Button from '../Button'
15
15
  import NumberFormat from 'react-number-format'
16
16
  import { RadioGroup, RadioGroupItem } from '../RadioGroup'
17
- // import { ProlongationCoursesProps } from './ProlongationCourse/interfaces'
18
- // import { ProlongationCourses } from './ProlongationCourse'
19
17
 
20
18
  /**
21
19
  * Виджет заказа продления курса
package/src/utils.ts CHANGED
@@ -15,10 +15,8 @@ export const roundStd = (num: number, decimalPlaces: number) => {
15
15
 
16
16
  export const getCurrencyPrefix = (currency: string) => {
17
17
  switch (currency) {
18
- case 'USD':
19
- return '$'
20
- default:
21
- return ''
18
+ case 'USD': return '$'
19
+ default: return ''
22
20
  }
23
21
  }
24
22
 
@@ -33,7 +31,7 @@ export const getCurrencySuffix = (currency: string) => {
33
31
  case 'UAH':
34
32
  return ' ₴'
35
33
  default:
36
- return ` ${currency}`
34
+ return `\u202F${currency}`
37
35
  }
38
36
  }
39
37