@procraft/widget-order 2.30.15 → 2.31.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.
Files changed (99) hide show
  1. package/README.md +4 -0
  2. package/dist/CourseItem/AltItem/index.js +3 -3
  3. package/dist/CourseItem/AltItem/index.js.map +1 -1
  4. package/dist/CourseItem/AltItemText/index.js +1 -1
  5. package/dist/CourseItem/AltItemText/index.js.map +1 -1
  6. package/dist/CourseItem/FieldValues/index.js +6 -6
  7. package/dist/CourseItem/FieldValues/index.js.map +1 -1
  8. package/dist/CourseItem/FieldValuesByType/index.js +2 -2
  9. package/dist/CourseItem/FieldValuesByType/index.js.map +1 -1
  10. package/dist/CourseItem/Materials/index.js +6 -13
  11. package/dist/CourseItem/Materials/index.js.map +1 -1
  12. package/dist/CourseItem/Materials/styles.js +1 -1
  13. package/dist/CourseItem/Materials/styles.js.map +1 -1
  14. package/dist/CourseItem/OrderButton/index.js +16 -15
  15. package/dist/CourseItem/OrderButton/index.js.map +1 -1
  16. package/dist/CourseItem/OrderButton/styles.js +1 -1
  17. package/dist/CourseItem/OrderButton/styles.js.map +1 -1
  18. package/dist/CourseItem/PlacesLeft/index.js +1 -1
  19. package/dist/CourseItem/PlacesLeft/index.js.map +1 -1
  20. package/dist/CourseItem/Reviews/ReviewsPopup/Filters/index.js +7 -7
  21. package/dist/CourseItem/Reviews/ReviewsPopup/Filters/index.js.map +1 -1
  22. package/dist/CourseItem/Reviews/ReviewsPopup/ProgressBar/index.js +1 -1
  23. package/dist/CourseItem/Reviews/ReviewsPopup/ProgressBar/index.js.map +1 -1
  24. package/dist/CourseItem/Reviews/ReviewsPopup/Review/index.js +1 -1
  25. package/dist/CourseItem/Reviews/ReviewsPopup/Review/index.js.map +1 -1
  26. package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js +6 -6
  27. package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js.map +1 -1
  28. package/dist/CourseItem/Reviews/ReviewsPopup/index.js +10 -10
  29. package/dist/CourseItem/Reviews/ReviewsPopup/index.js.map +1 -1
  30. package/dist/CourseItem/Reviews/Stars/index.js +1 -1
  31. package/dist/CourseItem/Reviews/Stars/index.js.map +1 -1
  32. package/dist/CourseItem/Reviews/index.js +6 -6
  33. package/dist/CourseItem/Reviews/index.js.map +1 -1
  34. package/dist/CourseItem/Sales/Sale/index.js +10 -8
  35. package/dist/CourseItem/Sales/Sale/index.js.map +1 -1
  36. package/dist/CourseItem/Sales/index.js +1 -1
  37. package/dist/CourseItem/Sales/index.js.map +1 -1
  38. package/dist/CourseItem/Subscriptions/index.js +3 -3
  39. package/dist/CourseItem/Subscriptions/index.js.map +1 -1
  40. package/dist/CourseItem/Subscriptions/styles.js +1 -1
  41. package/dist/CourseItem/Subscriptions/styles.js.map +1 -1
  42. package/dist/CourseItem/index.js +19 -12
  43. package/dist/CourseItem/index.js.map +1 -1
  44. package/dist/components/DateFormat/index.js +1 -1
  45. package/dist/components/DateFormat/index.js.map +1 -1
  46. package/dist/components/OldPrice/index.js.map +1 -1
  47. package/dist/components/OldPrice/styles.js +1 -1
  48. package/dist/components/OldPrice/styles.js.map +1 -1
  49. package/dist/components/ProlongationWidget/index.js +10 -10
  50. package/dist/components/ProlongationWidget/index.js.map +1 -1
  51. package/dist/components/ProlongationWidget/styles.js +1 -1
  52. package/dist/components/ProlongationWidget/styles.js.map +1 -1
  53. package/dist/components/RadioGroup/index.js +12 -4
  54. package/dist/components/RadioGroup/index.js.map +1 -1
  55. package/dist/components/RadioGroup/styles.js +1 -1
  56. package/dist/components/RadioGroup/styles.js.map +1 -1
  57. package/dist/components/Tabs/index.js +2 -2
  58. package/dist/components/Tabs/index.js.map +1 -1
  59. package/dist/components/Tabs/styles.js +1 -1
  60. package/dist/components/Tabs/styles.js.map +1 -1
  61. package/dist/components/Typography/index.js +1 -1
  62. package/dist/components/Typography/index.js.map +1 -1
  63. package/dist/components/Typography/styles.js +2 -2
  64. package/dist/components/Typography/styles.js.map +1 -1
  65. package/dist/helpers/getCatalogItems/index.js +1 -1
  66. package/dist/helpers/getCatalogItems/index.js.map +1 -1
  67. package/dist/hooks/useCatalogItemSubscription/index.js +3 -3
  68. package/dist/hooks/useCatalogItemSubscription/index.js.map +1 -1
  69. package/dist/hooks/useOrderLink/index.js +3 -3
  70. package/dist/hooks/useOrderLink/index.js.map +1 -1
  71. package/dist/hooks/usePrices/index.js +2 -2
  72. package/dist/hooks/usePrices/index.js.map +1 -1
  73. package/dist/index.js +1 -1
  74. package/dist/index.js.map +1 -1
  75. package/dist/models/Course.js +4 -4
  76. package/dist/models/Course.js.map +1 -1
  77. package/dist/modules/gql/cli/generateTypes/generateTypes.js +2 -2
  78. package/dist/modules/gql/cli/generateTypes/generateTypes.js.map +1 -1
  79. package/dist/modules/gql/cli/generateTypes/run.js +1 -1
  80. package/dist/modules/gql/cli/generateTypes/run.js.map +1 -1
  81. package/dist/modules/gql/cli/generateTypes/types.js +7 -7
  82. package/dist/modules/gql/cli/generateTypes/types.js.map +1 -1
  83. package/dist/styles/GlobalStyle/index.js +1 -1
  84. package/dist/styles/GlobalStyle/index.js.map +1 -1
  85. package/dist/tsconfig.build.tsbuildinfo +1 -1
  86. package/dist/utils.js +18 -12
  87. package/dist/utils.js.map +1 -1
  88. package/package.json +1 -1
  89. package/src/CourseItem/Materials/index.tsx +1 -8
  90. package/src/CourseItem/OrderButton/index.tsx +4 -3
  91. package/src/CourseItem/OrderButton/interfaces.ts +1 -1
  92. package/src/CourseItem/Reviews/index.tsx +1 -2
  93. package/src/CourseItem/Sales/Sale/index.tsx +8 -3
  94. package/src/CourseItem/index.tsx +47 -22
  95. package/src/components/OldPrice/index.tsx +6 -1
  96. package/src/components/RadioGroup/index.tsx +9 -1
  97. package/src/hooks/usePrices/index.tsx +1 -1
  98. package/src/interfaces/CourseFragment.ts +7 -6
  99. package/src/utils.ts +21 -11
package/dist/utils.js CHANGED
@@ -18,17 +18,23 @@ const roundStd = (num, decimalPlaces) => {
18
18
  exports.roundStd = roundStd;
19
19
  const getCurrencyPrefix = (currency) => {
20
20
  switch (currency) {
21
- case 'USD': return '$';
22
- default: return '';
21
+ case 'USD':
22
+ return '$';
23
+ default:
24
+ return '';
23
25
  }
24
26
  };
25
27
  exports.getCurrencyPrefix = getCurrencyPrefix;
26
28
  const getCurrencySuffix = (currency) => {
27
29
  switch (currency) {
28
- case 'RUB': return ' ₽';
29
- case 'USD': return '';
30
- case 'KZT': return ' ₸';
31
- case 'UAH': return ' ₴';
30
+ case 'RUB':
31
+ return ' ₽';
32
+ case 'USD':
33
+ return '';
34
+ case 'KZT':
35
+ return ' ₸';
36
+ case 'UAH':
37
+ return ' ₴';
32
38
  default:
33
39
  return ` ${currency}`;
34
40
  }
@@ -36,8 +42,8 @@ const getCurrencySuffix = (currency) => {
36
42
  exports.getCurrencySuffix = getCurrencySuffix;
37
43
  function isNowYear(dateMoment) {
38
44
  if (dateMoment) {
39
- dateMoment = moment_1.default(dateMoment);
40
- return moment_1.default().year() === dateMoment.year();
45
+ dateMoment = (0, moment_1.default)(dateMoment);
46
+ return (0, moment_1.default)().year() === dateMoment.year();
41
47
  }
42
48
  else {
43
49
  return false;
@@ -49,7 +55,7 @@ exports.isNowYear = isNowYear;
49
55
  */
50
56
  function formatDate(dateMoment) {
51
57
  if (dateMoment) {
52
- dateMoment = moment_1.default(dateMoment);
58
+ dateMoment = (0, moment_1.default)(dateMoment);
53
59
  if (!isNowYear(dateMoment)) {
54
60
  return dateMoment.format('D MMMM YYYY');
55
61
  }
@@ -67,13 +73,13 @@ function hasTime(dateMoment, optionalTimeReplacement = '00:00') {
67
73
  return !(dateMoment.hours() === 23 && dateMoment.minutes() === 59);
68
74
  }
69
75
  else {
70
- return (dateMoment.hours() * 60 + dateMoment.minutes()) > 0;
76
+ return dateMoment.hours() * 60 + dateMoment.minutes() > 0;
71
77
  }
72
78
  }
73
79
  exports.hasTime = hasTime;
74
80
  function formatTimeHoursMinutes(dateMoment) {
75
81
  if (dateMoment) {
76
- return moment_1.default(dateMoment).format('HH:mm');
82
+ return (0, moment_1.default)(dateMoment).format('HH:mm');
77
83
  }
78
84
  else {
79
85
  return '';
@@ -82,7 +88,7 @@ function formatTimeHoursMinutes(dateMoment) {
82
88
  exports.formatTimeHoursMinutes = formatTimeHoursMinutes;
83
89
  function formatDateOptionalTime(dateMoment, separator = ' в ', optionalTimeReplacement = '00:00') {
84
90
  if (dateMoment) {
85
- const timestamp = moment_1.default(dateMoment);
91
+ const timestamp = (0, moment_1.default)(dateMoment);
86
92
  if (hasTime(timestamp, optionalTimeReplacement)) {
87
93
  return `${formatDate(timestamp)}${separator}${formatTimeHoursMinutes(timestamp)}`;
88
94
  }
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuC;AAIhC,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,KA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,7 @@
1
1
  {
2
2
  "name": "@procraft/widget-order",
3
3
  "description": "Order widget for landing",
4
- "version": "2.30.15",
4
+ "version": "2.31.0",
5
5
  "private": false,
6
6
  "main": "dist",
7
7
  "scripts": {
@@ -106,14 +106,7 @@ const Materials: React.FC<MaterialsProps> = ({
106
106
  {showAllButton}
107
107
  </MaterialsStyled>
108
108
  )
109
- }, [
110
- materials,
111
- renderBenefit,
112
- showAllButton,
113
- backgroundColor,
114
- textColor,
115
- linkColor,
116
- ])
109
+ }, [materials, renderBenefit, showAllButton, backgroundColor, textColor])
117
110
  }
118
111
 
119
112
  export default Materials
@@ -4,7 +4,7 @@ import React, {
4
4
  useCallback,
5
5
  useEffect,
6
6
  useMemo,
7
- useState
7
+ useState,
8
8
  } from 'react'
9
9
  import NumberFormat from 'react-number-format'
10
10
  import Button from '../../components/Button'
@@ -14,13 +14,13 @@ import Typography from '../../components/Typography'
14
14
  import {
15
15
  COLORED_TEXT_DEFAULT_COLOR,
16
16
  TITLE_BG_DEFAULT_COLOR,
17
- TITLE_TEXT_DEFAULT_COLOR
17
+ TITLE_TEXT_DEFAULT_COLOR,
18
18
  } from '../../constants/colors'
19
19
  import { useOrderLink } from '../../hooks/useOrderLink'
20
20
  import { formatFreeLabel } from '../../models/Course'
21
21
  import {
22
22
  CourseTariffPriceDetailsChangeByTimeItem,
23
- CourseTariffPriceKind
23
+ CourseTariffPriceKind,
24
24
  } from '../../modules/gql/generated/types'
25
25
  import { getCurrencyPrefix, getCurrencySuffix } from '../../utils'
26
26
  import { OrderButtonProps } from './interfaces'
@@ -196,6 +196,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
196
196
  if (catalogItem.priceWithPromoCode && catalogItem.promoCode?.code) {
197
197
  price = catalogItem.priceWithPromoCode
198
198
  promoCode = catalogItem.promoCode.code
199
+ // eslint-disable-next-line react-hooks/exhaustive-deps
199
200
  uri = `${uri}&promoCode=${promoCode}`
200
201
  }
201
202
 
@@ -1,7 +1,7 @@
1
1
  import { CourseFragment } from '../../interfaces/CourseFragment'
2
2
  import {
3
3
  CatalogFieldValue,
4
- OrderCatalogItemFragment
4
+ OrderCatalogItemFragment,
5
5
  } from '../../modules/gql/generated/types'
6
6
 
7
7
  export type OrderButtonProps = {
@@ -14,7 +14,6 @@ export const Reviews: React.FC<ReviewsProps> = ({
14
14
  textColor,
15
15
  ...other
16
16
  }) => {
17
-
18
17
  const [active, activeSetter] = useState(false)
19
18
 
20
19
  useEffect(() => {
@@ -71,5 +70,5 @@ export const Reviews: React.FC<ReviewsProps> = ({
71
70
  />
72
71
  </>
73
72
  )
74
- }, [active, other, reviewsCount, item, toggleActive])
73
+ }, [reviewsCount, item, other, toggleActive, textColor, active])
75
74
  }
@@ -175,7 +175,8 @@ const Sale: React.FC<SaleProps> = ({
175
175
  items.push(
176
176
  <span key={n.id} className="item">
177
177
  <span className="item--name">
178
- {index > 0 ? '+ ' : ''}{n.name}
178
+ {index > 0 ? '+ ' : ''}
179
+ {n.name}
179
180
  </span>{' '}
180
181
  {priceWithDiscount ? (
181
182
  <span>
@@ -241,8 +242,12 @@ const Sale: React.FC<SaleProps> = ({
241
242
  </div>
242
243
  <div className="content">
243
244
  <p style={{ color: titleTextColor }} className="title">
244
- Дополнительно Скидка {totalPriceOriginal - totalPrice}
245
- {sale.benefitUnit === 'Percent' ? `%` : `₽`}
245
+ Дополнительно Скидка{' '}
246
+ {sale.benefitUnit === 'Percent'
247
+ ? `${Math.round(
248
+ ((totalPriceOriginal - totalPrice) / totalPriceOriginal) * 100
249
+ )}%`
250
+ : `${totalPriceOriginal - totalPrice} ₽`}
246
251
  </p>
247
252
 
248
253
  <div className="items">{items}</div>
@@ -1,19 +1,31 @@
1
- import React, {useEffect, useMemo, useState} from 'react'
1
+ import React, { useEffect, useMemo, useState } from 'react'
2
2
  import Typography from '../components/Typography'
3
- import {COLORED_TEXT_DEFAULT_COLOR, CONTENT_BG_DEFAULT_COLOR, CONTENT_TEXT_DEFAULT_COLOR, EXTRA_BG_DEFAULT_COLOR, MAIN_BG_DEFAULT_COLOR, TITLE_BG_DEFAULT_COLOR, TITLE_TEXT_DEFAULT_COLOR,} from '../constants/colors'
4
- import {usePrices} from '../hooks/usePrices'
5
- import {CatalogFieldValueType, CourseKind, CourseSubKind,} from '../modules/gql/generated/types'
6
- import {FieldValuesProps} from './FieldValues/interfaces'
7
- import {FieldValuesByType} from './FieldValuesByType'
8
- import {CourseItemComponentProps} from './interfaces'
3
+ import {
4
+ COLORED_TEXT_DEFAULT_COLOR,
5
+ CONTENT_BG_DEFAULT_COLOR,
6
+ CONTENT_TEXT_DEFAULT_COLOR,
7
+ EXTRA_BG_DEFAULT_COLOR,
8
+ MAIN_BG_DEFAULT_COLOR,
9
+ TITLE_BG_DEFAULT_COLOR,
10
+ TITLE_TEXT_DEFAULT_COLOR,
11
+ } from '../constants/colors'
12
+ import { usePrices } from '../hooks/usePrices'
13
+ import {
14
+ CatalogFieldValueType,
15
+ CourseKind,
16
+ CourseSubKind,
17
+ } from '../modules/gql/generated/types'
18
+ import { FieldValuesProps } from './FieldValues/interfaces'
19
+ import { FieldValuesByType } from './FieldValuesByType'
20
+ import { CourseItemComponentProps } from './interfaces'
9
21
  import Materials from './Materials'
10
- import {OrderButton} from './OrderButton'
11
- import {Reviews} from './Reviews'
22
+ import { OrderButton } from './OrderButton'
23
+ import { Reviews } from './Reviews'
12
24
  import Sales from './Sales'
13
- import {BoxStyled, NavigationStyled, WidgetStyled} from './styles'
14
- import {formatCourseSubKindLabel} from '../models/Course'
15
- import styled from 'styled-components';
16
- import {formatDateOptionalTime} from '../utils';
25
+ import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
26
+ import { formatCourseSubKindLabel } from '../models/Course'
27
+ import styled from 'styled-components'
28
+ import { formatDateOptionalTime } from '../utils'
17
29
 
18
30
  const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
19
31
  const {
@@ -137,9 +149,7 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
137
149
  <WidgetStyled style={{ backgroundColor: mainBgColor }}>
138
150
  <NavigationStyled style={{ backgroundColor: titleBgColor }}>
139
151
  <Typography>
140
- <span style={{ color: titleTextColor }}>
141
- {title}
142
- </span>
152
+ <span style={{ color: titleTextColor }}>{title}</span>
143
153
  </Typography>
144
154
  </NavigationStyled>
145
155
 
@@ -150,12 +160,22 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
150
160
  : course.name}
151
161
  </Typography>
152
162
 
153
- {(item.course?.courseMeta?.courseKind === CourseKind.WEBINAR && item.course.courseMeta.webinarStartsAt) && (
154
- <WebinarDate>Начало {formatDateOptionalTime(item.course.courseMeta.webinarStartsAt)}</WebinarDate>
155
- )}
163
+ {item.course?.courseMeta?.courseKind === CourseKind.WEBINAR &&
164
+ item.course.courseMeta.webinarStartsAt && (
165
+ <WebinarDate>
166
+ Начало{' '}
167
+ {formatDateOptionalTime(
168
+ item.course.courseMeta.webinarStartsAt
169
+ )}
170
+ </WebinarDate>
171
+ )}
156
172
 
157
173
  {ratesVisible && item.reviewsCount ? (
158
- <Reviews textColor={coloredTextColor} reviewsCount={item.reviewsCount} item={item} />
174
+ <Reviews
175
+ textColor={coloredTextColor}
176
+ reviewsCount={item.reviewsCount}
177
+ item={item}
178
+ />
159
179
  ) : null}
160
180
 
161
181
  {tariff ? (
@@ -201,13 +221,18 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
201
221
  }, [
202
222
  item,
203
223
  course,
224
+ mainBgColor,
225
+ titleBgColor,
226
+ titleTextColor,
227
+ ratesVisible,
228
+ coloredTextColor,
229
+ contentBgColor,
230
+ contentTextColor,
204
231
  extraBenefits,
205
232
  materialsLimit,
206
233
  fieldValuesByType,
207
234
  orderLink,
208
235
  fieldsValueSelected,
209
- ratesVisible,
210
- style,
211
236
  ])
212
237
  }
213
238
 
@@ -3,7 +3,12 @@ import NumberFormat from 'react-number-format'
3
3
  import { OldPriceProps } from './interfaces'
4
4
  import { OldPriceStyled } from './styles'
5
5
 
6
- const OldPrice: React.FC<OldPriceProps> = ({ price, prefix, suffix, ...other }) => {
6
+ const OldPrice: React.FC<OldPriceProps> = ({
7
+ price,
8
+ prefix,
9
+ suffix,
10
+ ...other
11
+ }) => {
7
12
  return (
8
13
  <OldPriceStyled component="span" {...other}>
9
14
  <NumberFormat
@@ -58,5 +58,13 @@ export const RadioGroup: React.FC<RadioGroupProps> = ({
58
58
  })}
59
59
  </RadioGroupStyled>
60
60
  )
61
- }, [items, onChange, onRowClick, other, value, checkedBgColor])
61
+ }, [
62
+ items,
63
+ other,
64
+ value,
65
+ onRowClick,
66
+ checkedBgColor,
67
+ checkedTextColor,
68
+ onChange,
69
+ ])
62
70
  }
@@ -31,7 +31,7 @@ export const usePrices = ({
31
31
  },
32
32
  LessonCount: {
33
33
  fieldValues: [],
34
- }
34
+ },
35
35
  }
36
36
 
37
37
  for (const typeKey in CatalogFieldValueType) {
@@ -1,10 +1,11 @@
1
1
  import {
2
- Maybe,
3
- OrderCatalogItemFragment,
4
- CourseTariffFlowPublic,
5
- CourseTariffFlowBehaviour,
6
- CourseKind,
7
- CourseSubKind, LangRussianNoun,
2
+ Maybe,
3
+ OrderCatalogItemFragment,
4
+ CourseTariffFlowPublic,
5
+ CourseTariffFlowBehaviour,
6
+ CourseKind,
7
+ CourseSubKind,
8
+ LangRussianNoun,
8
9
  } from '../modules/gql/generated/types'
9
10
 
10
11
  export type CourseFragmentCatalogItem = {
package/src/utils.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import moment, { Moment } from 'moment'
2
2
  type DateTime = Moment | Date | string
3
3
 
4
-
5
4
  export const roundByStep = (v: number, s = 1.0) => {
6
5
  const inv = 1.0 / s
7
6
  return Math.round(v * inv) / inv
@@ -16,17 +15,23 @@ export const roundStd = (num: number, decimalPlaces: number) => {
16
15
 
17
16
  export const getCurrencyPrefix = (currency: string) => {
18
17
  switch (currency) {
19
- case 'USD': return '$'
20
- default: return ''
18
+ case 'USD':
19
+ return '$'
20
+ default:
21
+ return ''
21
22
  }
22
23
  }
23
24
 
24
25
  export const getCurrencySuffix = (currency: string) => {
25
26
  switch (currency) {
26
- case 'RUB': return ' ₽'
27
- case 'USD': return ''
28
- case 'KZT': return ' ₸'
29
- case 'UAH': return ' ₴'
27
+ case 'RUB':
28
+ return ' ₽'
29
+ case 'USD':
30
+ return ''
31
+ case 'KZT':
32
+ return ' ₸'
33
+ case 'UAH':
34
+ return ' ₴'
30
35
  default:
31
36
  return ` ${currency}`
32
37
  }
@@ -60,11 +65,14 @@ export function formatDate(dateMoment: DateTime | null): string {
60
65
  }
61
66
  }
62
67
 
63
- export function hasTime(dateMoment: Moment, optionalTimeReplacement: DateOptionalTimeReplacement = '00:00'): boolean {
68
+ export function hasTime(
69
+ dateMoment: Moment,
70
+ optionalTimeReplacement: DateOptionalTimeReplacement = '00:00'
71
+ ): boolean {
64
72
  if (optionalTimeReplacement == '23:59') {
65
73
  return !(dateMoment.hours() === 23 && dateMoment.minutes() === 59)
66
74
  } else {
67
- return (dateMoment.hours() * 60 + dateMoment.minutes()) > 0
75
+ return dateMoment.hours() * 60 + dateMoment.minutes() > 0
68
76
  }
69
77
  }
70
78
 
@@ -79,13 +87,15 @@ export function formatTimeHoursMinutes(dateMoment: DateTime | null): string {
79
87
  export function formatDateOptionalTime(
80
88
  dateMoment: DateTime | null,
81
89
  separator = ' в ',
82
- optionalTimeReplacement: DateOptionalTimeReplacement = '00:00',
90
+ optionalTimeReplacement: DateOptionalTimeReplacement = '00:00'
83
91
  ): string {
84
92
  if (dateMoment) {
85
93
  const timestamp = moment(dateMoment)
86
94
 
87
95
  if (hasTime(timestamp, optionalTimeReplacement)) {
88
- return `${formatDate(timestamp)}${separator}${formatTimeHoursMinutes(timestamp)}`
96
+ return `${formatDate(timestamp)}${separator}${formatTimeHoursMinutes(
97
+ timestamp
98
+ )}`
89
99
  } else {
90
100
  return formatDate(timestamp)
91
101
  }