@procraft/widget-order 2.22.11 → 2.24.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/dist/utils.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export declare const roundByStep: (v: number, s?: number) => number;
2
2
  export declare const roundStd: (num: number, decimalPlaces: number) => number;
3
+ export declare const getCurrencyPrefix: (currency: string) => "" | "$";
4
+ export declare const getCurrencySuffix: (currency: string) => string;
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundStd = exports.roundByStep = void 0;
3
+ exports.getCurrencySuffix = exports.getCurrencyPrefix = exports.roundStd = exports.roundByStep = void 0;
4
4
  const roundByStep = (v, s = 1.0) => {
5
5
  const inv = 1.0 / s;
6
6
  return Math.round(v * inv) / inv;
@@ -12,4 +12,22 @@ const roundStd = (num, decimalPlaces) => {
12
12
  return Math.round(num * p + e) / p;
13
13
  };
14
14
  exports.roundStd = roundStd;
15
+ const getCurrencyPrefix = (currency) => {
16
+ switch (currency) {
17
+ case 'USD': return '$';
18
+ default: return '';
19
+ }
20
+ };
21
+ exports.getCurrencyPrefix = getCurrencyPrefix;
22
+ const getCurrencySuffix = (currency) => {
23
+ switch (currency) {
24
+ case 'RUB': return ' ₽';
25
+ case 'USD': return '';
26
+ case 'KZT': return ' ₸';
27
+ case 'UAH': return ' ₴';
28
+ default:
29
+ return ` ${currency}`;
30
+ }
31
+ };
32
+ exports.getCurrencySuffix = getCurrencySuffix;
15
33
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,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,YAKpB"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,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,YAKpB;AAEM,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACpD,QAAQ,QAAQ,EAAE;QAChB,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAA;QACtB,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;KACnB;AACH,CAAC,CAAA;AALY,QAAA,iBAAiB,qBAK7B;AAEM,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACpD,QAAQ,QAAQ,EAAE;QAChB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACrB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB;YACE,OAAO,IAAI,QAAQ,EAAE,CAAA;KACxB;AACH,CAAC,CAAA;AATY,QAAA,iBAAiB,qBAS7B"}
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.22.11",
4
+ "version": "2.24.0",
5
5
  "private": false,
6
6
  "main": "dist",
7
7
  "scripts": {
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useState } from 'react'
2
2
  import { MaterialsProps } from './interfaces'
3
3
  import { MaterialsStyled } from './styles'
4
4
 
5
- const Materials: React.FC<MaterialsProps> = ({ tariff, limit, ...other }) => {
5
+ const Materials: React.FC<MaterialsProps> = ({ benefits, extraBenefits, limit, ...other }) => {
6
6
  const [showAll, showAllSetter] = useState(false)
7
7
 
8
8
  const renderBenefit = useMemo(
@@ -53,11 +53,11 @@ const Materials: React.FC<MaterialsProps> = ({ tariff, limit, ...other }) => {
53
53
  }, [])
54
54
 
55
55
  const { materials, showAllButton } = useMemo(() => {
56
- const materials = tariff.marketingBenefits
56
+ const allBenefits = benefits.concat(extraBenefits)
57
57
 
58
- const total = materials.length
58
+ const total = allBenefits.length
59
59
 
60
- const hasMore = materials.length > limit
60
+ const hasMore = allBenefits.length > limit
61
61
 
62
62
  const showAllButton =
63
63
  hasMore && !showAll ? (
@@ -67,10 +67,10 @@ const Materials: React.FC<MaterialsProps> = ({ tariff, limit, ...other }) => {
67
67
  ) : null
68
68
 
69
69
  return {
70
- materials: showAll || !hasMore ? materials : materials.slice(0, limit),
70
+ materials: showAll || !hasMore ? allBenefits : allBenefits.slice(0, limit),
71
71
  showAllButton,
72
72
  }
73
- }, [showAll, showAllOnClick, limit, tariff.marketingBenefits])
73
+ }, [showAll, showAllOnClick, limit, benefits, extraBenefits])
74
74
 
75
75
  return useMemo(() => {
76
76
  if (!materials?.length) {
@@ -1,6 +1,5 @@
1
- import { Tariff } from '../../interfaces'
2
-
3
1
  export type MaterialsProps = {
4
- tariff: Tariff
2
+ benefits: string[]
3
+ extraBenefits: string[]
5
4
  limit: number
6
5
  }
@@ -1,5 +1,4 @@
1
1
  import moment from 'moment'
2
- // import Link from 'next/link';
3
2
  import React, {
4
3
  MouseEvent,
5
4
  useCallback,
@@ -20,6 +19,7 @@ import {
20
19
  } from '../../modules/gql/generated/types'
21
20
  import { OrderButtonProps } from './interfaces'
22
21
  import { OrderButtonByDateSalesStyled } from './styles'
22
+ import {getCurrencyPrefix, getCurrencySuffix} from "../../utils";
23
23
 
24
24
  /**
25
25
  * Кнопка заказа
@@ -73,22 +73,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
73
73
  }, [])
74
74
 
75
75
  return useMemo(() => {
76
- // if (!global.location?.origin) {
77
- // if (!loaded) {
78
- // return null
79
- // }
80
76
 
81
77
  const content: JSX.Element[] = []
82
78
 
83
- // const catalogItem = item.catalogItem
84
-
85
- // const course = courses.find((n) => n.uid === catalogItem.course?.courseId)
86
-
87
- // if (!course) {
88
- // console.error('Can no get course')
89
- // return null
90
- // }
91
-
92
79
  const saleByTime = course.tariffPerFlowDataItems?.find(
93
80
  (n) =>
94
81
  n.priceDetails.kind === CourseTariffPriceKind.CHANGESBYTIME &&
@@ -171,11 +158,6 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
171
158
  }
172
159
  }
173
160
 
174
- // let oldPrice = item.oldPrice
175
- // let price = item.price
176
-
177
- // const fieldValuesQuery: string[] = [];
178
-
179
161
  let oldPrice = 0
180
162
  let price = 0
181
163
 
@@ -197,45 +179,17 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
197
179
 
198
180
  price += extraPay
199
181
  oldPrice += extraPayOriginal || extraPay
200
-
201
- // fieldValuesQuery.push(n.uid)
202
-
203
- // uri.searchParams.append('fieldValuesQuery', n.uid)
204
182
  })
205
183
 
206
184
  if (!canOrder) {
207
185
  return null
208
186
  }
209
187
 
210
- // if(fieldValuesQuery.length) {
211
- // uri.searchParams.append('fieldValuesQuery', fieldValuesQuery)
212
- // }
213
-
214
188
  if (saleDateItem) {
215
189
  oldPrice = saleDateItem.priceMarketing
216
190
  price = saleDateItem.priceReal
217
191
  }
218
192
 
219
- /**
220
- * Если есть подписка, берем цены из нее
221
- */
222
- // if (subscription) {
223
- // oldPrice = subscription.priceMarketing || null
224
- // price = subscription.priceReal
225
-
226
- // uri.searchParams.append('subscription_unit', subscription.period.unit)
227
- // uri.searchParams.append(
228
- // 'subscription_amount',
229
- // subscription.period.amount.toString()
230
- // )
231
-
232
- // // uri.search = {
233
- // // ...uri.search,
234
- // // subscription_unit: subscription.period.unit,
235
- // // subscription_amount: subscription.period.amount,
236
- // // }
237
- // }
238
-
239
193
  let freeLabel
240
194
 
241
195
  switch (course.subKind) {
@@ -298,8 +252,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
298
252
  value={price}
299
253
  displayType="text"
300
254
  thousandSeparator={' '}
301
- />{' '}
302
- ₽
255
+ prefix={getCurrencyPrefix(catalogItem.master?.currency || '')}
256
+ suffix={getCurrencySuffix(catalogItem.master?.currency || '')}
257
+ />
303
258
  </>
304
259
  ) : (
305
260
  'Зарегистрироваться'
@@ -8,6 +8,7 @@ import { CatalogItemSale } from '../../../interfaces'
8
8
  import { CatalogFieldValue } from '../../../modules/gql/generated/types'
9
9
  import { SaleProps } from './interfaces'
10
10
  import { SaleStyled } from './styles'
11
+ import {getCurrencyPrefix, getCurrencySuffix} from "../../../utils";
11
12
 
12
13
  /**
13
14
  * Считаем стоимость с учетом скидки
@@ -291,8 +292,9 @@ const Sale: React.FC<SaleProps> = ({
291
292
  displayType="text"
292
293
  thousandSeparator={' '}
293
294
  decimalScale={0}
294
- />{' '}
295
- ₽
295
+ prefix={getCurrencyPrefix(catalogItem.master?.currency || '')}
296
+ suffix={getCurrencySuffix(catalogItem.master?.currency || '')}
297
+ />
296
298
  </Button>
297
299
  </a>
298
300
  </div>
@@ -1,11 +1,7 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react'
2
- // import ReactDecliner from 'react-decliner'
3
2
  import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
4
3
  import Typography from '../components/Typography'
5
- // import Container from '../components/Container'
6
4
  import { CourseItemComponentProps } from './interfaces'
7
- // import AltItem from './AltItem'
8
- // import AltItemText from './AltItemText'
9
5
  import Materials from './Materials'
10
6
  import Sales from './Sales'
11
7
  import { OrderButton } from './OrderButton'
@@ -14,14 +10,9 @@ import {
14
10
  CourseTariffFlowBehaviour,
15
11
  } from '../modules/gql/generated/types'
16
12
  import { Reviews } from './Reviews'
17
- // import { Subscriptions } from './Subscriptions'
18
- // import { WidgetOrderCourseItem } from '../interfaces'
19
- // import { FieldValues } from './FieldValues'
20
13
  import { FieldValuesProps } from './FieldValues/interfaces'
21
- // import { PlacesLeft } from './PlacesLeft'
22
14
  import { usePrices } from '../hooks/usePrices'
23
15
  import { FieldValuesByType } from './FieldValuesByType'
24
- // import { useCatalogItemSubscription } from '../hooks/useCatalogItemSubscription'
25
16
 
26
17
  const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
27
18
  const {
@@ -41,22 +32,18 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
41
32
  /**
42
33
  * Текущий элемент
43
34
  */
44
- // const item = useMemo(() => {
45
- // // return items.find((n) => n.uid === currentItemId)
46
- // return items.find((_n, index) => index === currentItemId)
47
- // }, [currentItemId, items])
48
-
49
- // const {
50
- // subscription,
51
- // // onChangeSubscription,
52
- // } = useCatalogItemSubscription({
53
- // item,
54
- // })
55
-
56
35
  const [fieldsValueSelected, fieldsValueSelectedSetter] = useState<
57
36
  FieldValuesProps['fieldsValueSelected']
58
37
  >([])
59
38
 
39
+ const {extraBenefits} = useMemo(() => {
40
+ const flowId = fieldsValueSelected.filter(x => x.fieldId === -1808).map(fv => +fv.uid.substr(6))[0]
41
+ const extraBenefits = (course.tariffPerFlowDataItems || []).filter(x => x.flowId === flowId)
42
+ .map(pfdi => pfdi.marketingBenefitsComputed)[0] || []
43
+ return {extraBenefits}
44
+ }, [fieldsValueSelected, course.tariffPerFlowDataItems])
45
+
46
+
60
47
  // console.log('useEffect fieldsValueSelected', [...fieldsValueSelected]);
61
48
 
62
49
  const fieldValuesInfo = usePrices({
@@ -64,12 +51,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
64
51
  fieldsValueSelected,
65
52
  })
66
53
 
67
- // useEffect(() => {
68
- // if (item.fieldValues?.length) {
69
- // fieldsValueSelectedSetter([item.fieldValues[0]])
70
- // }
71
- // }, [item.fieldValues])
72
-
73
54
  /**
74
55
  * При инициализации надо сразу задать дефолтные выбранные элементы
75
56
  */
@@ -93,10 +74,8 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
93
74
 
94
75
  fieldsValueSelectedSetter(fieldsValueSelected)
95
76
 
96
- // console.log('useEffect fieldsValueSelected 2', [...fieldsValueSelected]);
97
77
  }, [item.fieldValues])
98
78
 
99
- // console.log('fieldsValueSelected', [...fieldsValueSelected]);
100
79
 
101
80
  const fieldValuesByType = useMemo(() => {
102
81
  const content: JSX.Element[] = []
@@ -105,7 +84,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
105
84
  content.push(
106
85
  <FieldValuesByType
107
86
  key={type}
108
- // catalogItem={item}
109
87
  fieldsValueSelected={fieldsValueSelected}
110
88
  fieldsValueSelectedSetter={fieldsValueSelectedSetter}
111
89
  fieldValuesInfo={fieldValuesInfo}
@@ -122,8 +100,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
122
100
  return null
123
101
  }
124
102
 
125
- // const { tariff } = item.course
126
-
127
103
  const tariff = course.tariffs?.find((n) => n.uid === item.course?.tariffId)
128
104
 
129
105
  let flowBehaviourTitle: string | undefined
@@ -142,8 +118,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
142
118
  break
143
119
  }
144
120
 
145
- // const items: WidgetOrderCourseItem[] = []
146
-
147
121
  return (
148
122
  <>
149
123
  <WidgetStyled>
@@ -163,105 +137,33 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
163
137
  ) : null}
164
138
 
165
139
  {tariff ? (
166
- <Materials tariff={tariff} limit={materialsLimit} />
140
+ <Materials benefits={tariff.marketingBenefits} extraBenefits={extraBenefits} limit={materialsLimit} />
167
141
  ) : null}
168
142
 
169
- {/* <Container className="items">
170
- {items && items.length > 1 ? (
171
- items.map(
172
- (i, index) => (
173
- <AltItem
174
- // key={i.uid}
175
- key={index}
176
- item={i}
177
- value={index}
178
- // checked={i.uid === item.uid}
179
- checked={index === currentItemId}
180
- setCurrentItemId={setCurrentItemId}
181
- />
182
- )
183
- // renderAltItem(i, i.uid === item.uid, () => onItemChange(i))
184
- )
185
- ) : (
186
- // renderAltItemText(item)
187
- <AltItemText item={item} />
188
- )}
189
- </Container> */}
190
-
191
- {/* {typeof item.placesLeft === 'number' ? (
192
- <Container variant="white" className="placesLeft">
193
- {item.placesLeft > 0 ? (
194
- <>
195
- Осталось {item.placesLeft}{' '}
196
- <ReactDecliner
197
- num={item.placesLeft}
198
- one="место"
199
- two="места"
200
- many="мест"
201
- />
202
- !
203
- </>
204
- ) : (
205
- 'Места закончились'
206
- )}
207
- </Container>
208
- ) : null} */}
209
-
210
143
  {fieldValuesByType}
211
144
 
212
- {/* <FieldValuesByType
213
- // catalogItem={item}
214
- fieldsValueSelected={fieldsValueSelected}
215
- fieldsValueSelectedSetter={fieldsValueSelectedSetter}
216
- fieldValuesInfo={fieldValuesInfo}
217
- type={CatalogFieldValueType.COURSE}
218
- />
219
-
220
- <PlacesLeft fieldsValueSelected={fieldsValueSelected} /> */}
221
-
222
- {/* <Subscriptions
223
- item={item}
224
- // onChangeSubscription={onChangeSubscription}
225
- // subscription={subscription}
226
- /> */}
227
-
228
145
  <div className="flex-1" />
229
146
 
230
- {/* {priceDates} */}
231
-
232
- {/* <FieldValuesByType
233
- // catalogItem={item}
234
- fieldsValueSelected={fieldsValueSelected}
235
- fieldsValueSelectedSetter={fieldsValueSelectedSetter}
236
- fieldValuesInfo={fieldValuesInfo}
237
- type={CatalogFieldValueType.SUBSCRIPTION}
238
- /> */}
239
-
240
- {/* {typeof item.placesLeft !== 'number' || item.placesLeft > 0 ? ( */}
241
147
  <OrderButton
242
- // item={item}
243
148
  catalogItem={item}
244
149
  orderLink={orderLink}
245
150
  course={course}
246
151
  fieldsValueSelected={fieldsValueSelected}
247
- // subscription={subscription}
248
152
  />
249
- {/* ) : null} */}
250
153
  </BoxStyled>
251
154
  </WidgetStyled>
252
155
 
253
156
  <Sales
254
- // item={item}
255
157
  catalogItem={item}
256
158
  orderLink={orderLink}
257
159
  fieldsValueSelected={fieldsValueSelected}
258
- // course={course}
259
160
  />
260
161
  </>
261
162
  )
262
163
  }, [
263
164
  item,
264
165
  course,
166
+ extraBenefits,
265
167
  materialsLimit,
266
168
  fieldValuesByType,
267
169
  orderLink,
package/src/index.tsx CHANGED
@@ -10,36 +10,23 @@ moment.locale('ru')
10
10
  export * from './interfaces'
11
11
 
12
12
  const WidgetOrder: React.FC<WidgetOrderProps> = ({
13
- // items,
14
13
  catalogItem,
15
14
  orderLink,
16
15
  materialsLimit,
17
- // courses,
18
16
  course,
19
17
  ...other
20
18
  }) => {
21
19
  return useMemo(() => {
22
- // const currentItem = items.find(n => n.uid === currentItemId);
23
-
24
- // if (!items.length || !currentItem) {
25
- // return null;
26
- // }
27
-
28
20
  return (
29
- <>
30
- <WidgetOrderStyled {...other}>
31
- <CourseItem
32
- // item={item}
33
- // items={items}
34
- catalogItem={catalogItem}
35
- orderLink={orderLink}
36
- materialsLimit={materialsLimit}
37
- // courses={courses}
38
- ratesVisible={other.ratesVisible}
39
- course={course}
40
- />
41
- </WidgetOrderStyled>
42
- </>
21
+ <WidgetOrderStyled {...other}>
22
+ <CourseItem
23
+ catalogItem={catalogItem}
24
+ orderLink={orderLink}
25
+ materialsLimit={materialsLimit}
26
+ ratesVisible={other.ratesVisible}
27
+ course={course}
28
+ />
29
+ </WidgetOrderStyled>
43
30
  )
44
31
  }, [other, catalogItem, orderLink, materialsLimit, course])
45
32
  }
@@ -39,6 +39,7 @@ export type CourseFragment = {
39
39
  position: number
40
40
  isActive: boolean
41
41
  flowBehaviour: CourseTariffFlowBehaviour
42
+ withClientForm: boolean
42
43
  marketingBenefits: Array<string>
43
44
  // flowDetails: Array<{
44
45
  // __typename?: 'CourseTariffPerFlowDetailsCustom'
@@ -34,12 +34,17 @@ export type CatalogItemSale = {
34
34
  }[]
35
35
  }
36
36
 
37
+ export type CatalogItemMaster = {
38
+ currency: string
39
+ }
40
+
37
41
  export type CatalogItem = {
38
42
  id: string
39
43
  uid: number
40
44
  name: string
41
45
  sales?: CatalogItemSale[] | null
42
46
  course?: CourseItem | null
47
+ master?: Maybe<CatalogItemMaster>
43
48
  }
44
49
 
45
50
  /**
@@ -275,6 +275,7 @@ export interface CourseTariffFlowPublic {
275
275
  priceDetails: CourseTariffPriceDetails;
276
276
  /** Условия продления курса */
277
277
  prolongation: CourseTariffProlongation;
278
+ marketingBenefitsComputed: Array<Scalars['String']>;
278
279
  }
279
280
 
280
281
  export interface CourseTariffPriceDetails {
@@ -623,6 +624,7 @@ export interface OrderCatalogItemMaster {
623
624
  __typename?: 'OrderCatalogItemMaster';
624
625
  id: Scalars['ID'];
625
626
  uid: Scalars['Int'];
627
+ currency: Scalars['String'];
626
628
  }
627
629
 
628
630
  export interface OrderCatalogItemFragment {
package/src/utils.ts CHANGED
@@ -9,3 +9,21 @@ export const roundStd = (num: number, decimalPlaces: number) => {
9
9
 
10
10
  return Math.round(num * p + e) / p
11
11
  }
12
+
13
+ export const getCurrencyPrefix = (currency: string) => {
14
+ switch (currency) {
15
+ case 'USD': return '$'
16
+ default: return ''
17
+ }
18
+ }
19
+
20
+ export const getCurrencySuffix = (currency: string) => {
21
+ switch (currency) {
22
+ case 'RUB': return ' ₽'
23
+ case 'USD': return ''
24
+ case 'KZT': return ' ₸'
25
+ case 'UAH': return ' ₴'
26
+ default:
27
+ return ` ${currency}`
28
+ }
29
+ }