@procraft/widget-order 2.28.0 → 2.30.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 (84) hide show
  1. package/dist/CourseItem/FieldValues/index.js +13 -44
  2. package/dist/CourseItem/FieldValues/index.js.map +1 -1
  3. package/dist/CourseItem/FieldValues/interfaces.d.ts +4 -0
  4. package/dist/CourseItem/FieldValuesByType/index.js +12 -11
  5. package/dist/CourseItem/FieldValuesByType/index.js.map +1 -1
  6. package/dist/CourseItem/FieldValuesByType/interfaces.d.ts +4 -0
  7. package/dist/CourseItem/Materials/index.js +16 -17
  8. package/dist/CourseItem/Materials/index.js.map +1 -1
  9. package/dist/CourseItem/Materials/interfaces.d.ts +3 -0
  10. package/dist/CourseItem/OrderButton/index.js +17 -4
  11. package/dist/CourseItem/OrderButton/index.js.map +1 -1
  12. package/dist/CourseItem/OrderButton/interfaces.d.ts +6 -1
  13. package/dist/CourseItem/OrderButton/styles.js +2 -2
  14. package/dist/CourseItem/OrderButton/styles.js.map +1 -1
  15. package/dist/CourseItem/PlacesLeft/index.js +10 -8
  16. package/dist/CourseItem/PlacesLeft/index.js.map +1 -1
  17. package/dist/CourseItem/PlacesLeft/interfaces.d.ts +2 -0
  18. package/dist/CourseItem/Reviews/index.js +7 -6
  19. package/dist/CourseItem/Reviews/index.js.map +1 -1
  20. package/dist/CourseItem/Reviews/interfaces.d.ts +1 -0
  21. package/dist/CourseItem/Sales/Sale/index.js +16 -38
  22. package/dist/CourseItem/Sales/Sale/index.js.map +1 -1
  23. package/dist/CourseItem/Sales/Sale/interfaces.d.ts +4 -0
  24. package/dist/CourseItem/Sales/Sale/styles.d.ts +3 -1
  25. package/dist/CourseItem/Sales/Sale/styles.js +1 -0
  26. package/dist/CourseItem/Sales/Sale/styles.js.map +1 -1
  27. package/dist/CourseItem/Sales/index.js +11 -3
  28. package/dist/CourseItem/Sales/index.js.map +1 -1
  29. package/dist/CourseItem/Sales/interfaces.d.ts +4 -0
  30. package/dist/CourseItem/index.js +44 -26
  31. package/dist/CourseItem/index.js.map +1 -1
  32. package/dist/CourseItem/styles.js +0 -2
  33. package/dist/CourseItem/styles.js.map +1 -1
  34. package/dist/components/Button/index.js +5 -1
  35. package/dist/components/Button/index.js.map +1 -1
  36. package/dist/components/Button/interfaces.d.ts +3 -1
  37. package/dist/components/Container/styles.d.ts +1 -0
  38. package/dist/components/Container/styles.js +2 -0
  39. package/dist/components/Container/styles.js.map +1 -1
  40. package/dist/components/RadioGroup/index.js +3 -6
  41. package/dist/components/RadioGroup/index.js.map +1 -1
  42. package/dist/components/RadioGroup/interfaces.d.ts +2 -0
  43. package/dist/components/RadioGroup/styles.d.ts +2 -0
  44. package/dist/components/RadioGroup/styles.js +4 -3
  45. package/dist/components/RadioGroup/styles.js.map +1 -1
  46. package/dist/components/Typography/styles.js +1 -1
  47. package/dist/constants/colors.d.ts +7 -0
  48. package/dist/constants/colors.js +11 -0
  49. package/dist/constants/colors.js.map +1 -0
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +4 -4
  52. package/dist/index.js.map +1 -1
  53. package/dist/tsconfig.build.tsbuildinfo +1 -1
  54. package/package.json +1 -1
  55. package/src/CourseItem/FieldValues/index.tsx +52 -89
  56. package/src/CourseItem/FieldValues/interfaces.ts +4 -1
  57. package/src/CourseItem/FieldValuesByType/index.tsx +18 -4
  58. package/src/CourseItem/FieldValuesByType/interfaces.tsx +4 -0
  59. package/src/CourseItem/Materials/index.tsx +35 -6
  60. package/src/CourseItem/Materials/interfaces.ts +3 -0
  61. package/src/CourseItem/OrderButton/index.tsx +36 -3
  62. package/src/CourseItem/OrderButton/interfaces.ts +7 -15
  63. package/src/CourseItem/OrderButton/styles.ts +2 -2
  64. package/src/CourseItem/PlacesLeft/index.tsx +27 -17
  65. package/src/CourseItem/PlacesLeft/interfaces.ts +2 -0
  66. package/src/CourseItem/Reviews/index.tsx +14 -8
  67. package/src/CourseItem/Reviews/interfaces.ts +1 -2
  68. package/src/CourseItem/Sales/Sale/index.tsx +23 -45
  69. package/src/CourseItem/Sales/Sale/interfaces.ts +4 -2
  70. package/src/CourseItem/Sales/Sale/styles.ts +4 -1
  71. package/src/CourseItem/Sales/index.tsx +17 -2
  72. package/src/CourseItem/Sales/interfaces.ts +4 -4
  73. package/src/CourseItem/index.tsx +81 -30
  74. package/src/CourseItem/interfaces.ts +1 -8
  75. package/src/CourseItem/styles.ts +0 -2
  76. package/src/components/Button/index.tsx +10 -2
  77. package/src/components/Button/interfaces.ts +3 -1
  78. package/src/components/Container/styles.ts +3 -0
  79. package/src/components/RadioGroup/index.tsx +6 -22
  80. package/src/components/RadioGroup/interfaces.ts +2 -0
  81. package/src/components/RadioGroup/styles.ts +9 -3
  82. package/src/components/Typography/styles.ts +1 -1
  83. package/src/constants/colors.ts +7 -0
  84. package/src/index.tsx +4 -3
@@ -2,13 +2,16 @@ import React, { useMemo } from 'react'
2
2
  import NumberFormat from 'react-number-format'
3
3
  import Button from '../../../components/Button'
4
4
  import OldPrice from '../../../components/OldPrice'
5
+ import {
6
+ TITLE_BG_DEFAULT_COLOR,
7
+ TITLE_TEXT_DEFAULT_COLOR,
8
+ } from '../../../constants/colors'
5
9
  import { useOrderLink } from '../../../hooks/useOrderLink'
6
- // import { getCatalogItemData } from '../../../helpers/getCatalogItemData'
7
10
  import { CatalogItemSale } from '../../../interfaces'
8
11
  import { CatalogFieldValue } from '../../../modules/gql/generated/types'
12
+ import { getCurrencyPrefix, getCurrencySuffix } from '../../../utils'
9
13
  import { SaleProps } from './interfaces'
10
14
  import { SaleStyled } from './styles'
11
- import {getCurrencyPrefix, getCurrencySuffix} from "../../../utils";
12
15
 
13
16
  /**
14
17
  * Считаем стоимость с учетом скидки
@@ -47,7 +50,10 @@ const Sale: React.FC<SaleProps> = ({
47
50
  sale,
48
51
  orderLink,
49
52
  fieldsValueSelected,
50
- // course,
53
+ bgColor,
54
+ buttonColor,
55
+ buttonTextColor,
56
+ titleTextColor,
51
57
  ...other
52
58
  }) => {
53
59
  const {
@@ -76,12 +82,6 @@ const Sale: React.FC<SaleProps> = ({
76
82
  const items: JSX.Element[] = []
77
83
 
78
84
  sale.benefitItems.forEach((n, index) => {
79
- // console.log('items n', n)
80
-
81
- // if (!n.fieldValues?.length) {
82
- // return
83
- // }
84
-
85
85
  /**
86
86
  * В каждом элементе есть свой набор fieldValues.
87
87
  * Из этого набора надо выбрать те, что указаны в fieldsValueSelected.
@@ -93,20 +93,14 @@ const Sale: React.FC<SaleProps> = ({
93
93
  (i) => fieldsValueSelected.findIndex((f) => f.uid === i.uid) !== -1
94
94
  ) || []
95
95
 
96
- // console.log('itemFieldValues', itemFieldValues)
97
-
98
96
  /**
99
97
  * Если не был получен ни один элемент, то берем дефолтные
100
98
  */
101
99
  if (!itemFieldValues.length) {
102
100
  const itemFieldValueDefault = n.fieldValues?.find(
103
101
  (f) => f.isSelected === true
104
- // f.isSelected === true &&
105
- // (f.availableCount === null || (f.availableCount || 0) > 0)
106
102
  )
107
103
 
108
- // console.log('itemFieldValues 2', itemFieldValues)
109
-
110
104
  if (itemFieldValueDefault) {
111
105
  /**
112
106
  * Если есть дефолтный элемент и в нем нет свободных мест, то пропускаем его
@@ -114,7 +108,6 @@ const Sale: React.FC<SaleProps> = ({
114
108
  if (itemFieldValueDefault.availableCount !== 0) {
115
109
  itemFieldValues.push(itemFieldValueDefault)
116
110
  }
117
- // console.log('itemFieldValues 2.2', itemFieldValues)
118
111
  } else {
119
112
  /**
120
113
  * Если не был найден ни один элемент, то берем дефолтный селектед и находим любой
@@ -138,8 +131,6 @@ const Sale: React.FC<SaleProps> = ({
138
131
  }
139
132
  }
140
133
 
141
- // console.log('itemFieldValues 3', itemFieldValues)
142
-
143
134
  /**
144
135
  * Если нет ни одного итогового филда, то пропускаем элемент
145
136
  */
@@ -176,14 +167,9 @@ const Sale: React.FC<SaleProps> = ({
176
167
  saleFieldsValueSelected.push(fieldValue)
177
168
  })
178
169
 
179
- const priceWithDiscount = calcPriceWithDiscount(
180
- // n.unitPrice || n.unitPriceOriginal || 0,
181
- price,
182
- sale
183
- )
170
+ const priceWithDiscount = calcPriceWithDiscount(price, sale)
184
171
 
185
172
  totalPrice += priceWithDiscount
186
- // totalPriceOriginal += n.unitPriceOriginal || n.unitPrice || 0
187
173
  totalPriceOriginal += priceOrigin
188
174
 
189
175
  items.push(
@@ -214,8 +200,6 @@ const Sale: React.FC<SaleProps> = ({
214
200
  }
215
201
  }, [fieldsValueSelected, sale])
216
202
 
217
- // console.log('saleFieldsValueSelected', saleFieldsValueSelected)
218
-
219
203
  const uri = useOrderLink({
220
204
  catalogItem,
221
205
  orderLink,
@@ -239,23 +223,8 @@ const Sale: React.FC<SaleProps> = ({
239
223
  return null
240
224
  }
241
225
 
242
- /**
243
- * Проверяем каждый элемент скидки, и если какой-либо не доступен для покупки,
244
- * не выводим виджет
245
- */
246
- // TODO Надо перепроверить и если надо, восстановить
247
- // if (
248
- // sale.benefitItems.find((n) => {
249
- // const item = getCatalogItemData(n, course)
250
-
251
- // return item?.available !== true
252
- // })
253
- // ) {
254
- // return null
255
- // }
256
-
257
226
  return (
258
- <SaleStyled {...other}>
227
+ <SaleStyled bgColor={bgColor} {...other}>
259
228
  <div>
260
229
  <svg
261
230
  width="30"
@@ -271,7 +240,7 @@ const Sale: React.FC<SaleProps> = ({
271
240
  </svg>
272
241
  </div>
273
242
  <div className="content">
274
- <p className="title">
243
+ <p style={{ color: titleTextColor }} className="title">
275
244
  Дополнительно Скидка {sale.benefitAmount}
276
245
  {sale.benefitUnit === 'Percent' ? `%` : `₽`}
277
246
  </p>
@@ -283,9 +252,14 @@ const Sale: React.FC<SaleProps> = ({
283
252
  <OldPrice price={totalPriceOriginal} />
284
253
  </div>
285
254
 
286
- {/* <a href={`${orderLink}/${catalogItem.uid}?sale=${sale.id}`}> */}
287
255
  <a href={uri.toString()}>
288
- <Button className="buy-link">
256
+ <Button
257
+ style={{
258
+ backgroundColor: buttonColor ?? TITLE_BG_DEFAULT_COLOR,
259
+ color: buttonTextColor ?? TITLE_TEXT_DEFAULT_COLOR,
260
+ }}
261
+ className="buy-link"
262
+ >
289
263
  Купить за{' '}
290
264
  <NumberFormat
291
265
  value={totalPrice}
@@ -310,6 +284,10 @@ const Sale: React.FC<SaleProps> = ({
310
284
  totalPriceOriginal,
311
285
  uri,
312
286
  totalPrice,
287
+ bgColor,
288
+ buttonColor,
289
+ buttonTextColor,
290
+ titleTextColor,
313
291
  ])
314
292
  }
315
293
 
@@ -1,11 +1,13 @@
1
1
  import { CatalogItem, CatalogItemSale } from '../../../interfaces'
2
2
  import { CatalogFieldValue } from '../../../modules/gql/generated/types'
3
- // import { CourseFragment } from '../../../interfaces/CourseFragment'
4
3
 
5
4
  export type SaleProps = {
6
5
  catalogItem: CatalogItem
7
6
  sale: CatalogItemSale
8
7
  orderLink: string
9
- // course: CourseFragment
8
+ bgColor?: string
9
+ buttonColor?: string
10
+ buttonTextColor?: string
11
+ titleTextColor?: string
10
12
  fieldsValueSelected: CatalogFieldValue[]
11
13
  }
@@ -2,7 +2,10 @@ import styled from 'styled-components'
2
2
  import { ButtonStyled } from '../../../components/Button/styles'
3
3
  import { OldPriceStyled } from '../../../components/OldPrice/styles'
4
4
 
5
- export const SaleStyled = styled.div`
5
+ export const SaleStyled = styled.div<{
6
+ bgColor?: string
7
+ }>`
8
+ background-color: ${({ bgColor }) => bgColor ?? '#FFFFFF'};
6
9
  border: 1px solid #dae7f4;
7
10
  border-radius: 16px;
8
11
  width: 100%;
@@ -6,6 +6,10 @@ const Sales: React.FC<SalesProps> = ({
6
6
  catalogItem,
7
7
  orderLink,
8
8
  fieldsValueSelected,
9
+ bgColor,
10
+ buttonColor,
11
+ buttonTextColor,
12
+ titleTextColor,
9
13
  }) => {
10
14
  return useMemo(() => {
11
15
  if (!catalogItem.sales?.length) {
@@ -21,12 +25,23 @@ const Sales: React.FC<SalesProps> = ({
21
25
  sale={n}
22
26
  orderLink={orderLink}
23
27
  fieldsValueSelected={fieldsValueSelected}
24
- // course={course}
28
+ bgColor={bgColor}
29
+ buttonColor={buttonColor}
30
+ buttonTextColor={buttonTextColor}
31
+ titleTextColor={titleTextColor}
25
32
  />
26
33
  ))}
27
34
  </>
28
35
  )
29
- }, [catalogItem, orderLink, fieldsValueSelected])
36
+ }, [
37
+ catalogItem,
38
+ orderLink,
39
+ fieldsValueSelected,
40
+ bgColor,
41
+ buttonColor,
42
+ buttonTextColor,
43
+ titleTextColor,
44
+ ])
30
45
  }
31
46
 
32
47
  export default Sales
@@ -1,14 +1,14 @@
1
- // import { WidgetOrderCourseItem } from '../../interfaces'
2
1
  import {
3
2
  CatalogFieldValue,
4
3
  OrderCatalogItemFragment,
5
4
  } from '../../modules/gql/generated/types'
6
- // import { SaleProps } from './Sale/interfaces'
7
5
 
8
6
  export type SalesProps = {
9
- // item: WidgetOrderCourseItem
10
7
  catalogItem: OrderCatalogItemFragment
11
8
  orderLink: string
12
- // course: SaleProps['course']
9
+ bgColor?: string
10
+ buttonColor?: string
13
11
  fieldsValueSelected: CatalogFieldValue[]
12
+ buttonTextColor?: string
13
+ titleTextColor?: string
14
14
  }
@@ -1,18 +1,27 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react'
2
- import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
3
2
  import Typography from '../components/Typography'
4
- import { CourseItemComponentProps } from './interfaces'
5
- import Materials from './Materials'
6
- import Sales from './Sales'
7
- import { OrderButton } from './OrderButton'
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'
8
13
  import {
9
14
  CatalogFieldValueType,
10
15
  CourseTariffFlowBehaviour,
11
16
  } from '../modules/gql/generated/types'
12
- import { Reviews } from './Reviews'
13
17
  import { FieldValuesProps } from './FieldValues/interfaces'
14
- import { usePrices } from '../hooks/usePrices'
15
18
  import { FieldValuesByType } from './FieldValuesByType'
19
+ import { CourseItemComponentProps } from './interfaces'
20
+ import Materials from './Materials'
21
+ import { OrderButton } from './OrderButton'
22
+ import { Reviews } from './Reviews'
23
+ import Sales from './Sales'
24
+ import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
16
25
 
17
26
  const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
18
27
  const {
@@ -21,13 +30,18 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
21
30
  course,
22
31
  catalogItem: item,
23
32
  ratesVisible,
33
+ style,
24
34
  } = props
25
35
 
26
- /**
27
- * ID текущего элемента
28
- */
29
- // const [currentItemId, setCurrentItemId] = useState(items[0]?.uid)
30
- // const [currentItemId, setCurrentItemId] = useState(0)
36
+ const colors = style?.['colors']
37
+
38
+ const titleBgColor = colors?.['titleBg'] ?? TITLE_BG_DEFAULT_COLOR
39
+ const mainBgColor = colors?.['mainBg'] ?? MAIN_BG_DEFAULT_COLOR
40
+ const contentBgColor = colors?.['contentBg'] ?? CONTENT_BG_DEFAULT_COLOR
41
+ const extraBgColor = colors?.['extraBg'] ?? EXTRA_BG_DEFAULT_COLOR
42
+ const titleTextColor = colors?.['titleText'] ?? TITLE_TEXT_DEFAULT_COLOR
43
+ const contentTextColor = colors?.['contentText'] ?? CONTENT_TEXT_DEFAULT_COLOR
44
+ const coloredTextColor = colors?.['coloredText'] ?? COLORED_TEXT_DEFAULT_COLOR
31
45
 
32
46
  /**
33
47
  * Текущий элемент
@@ -36,18 +50,25 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
36
50
  FieldValuesProps['fieldsValueSelected']
37
51
  >([])
38
52
 
39
- const {extraBenefits} = useMemo(() => {
40
- const flowId = fieldsValueSelected.filter(x => x.fieldId === -1808).map(fv => +fv.uid.substr(6))[0]
53
+ const { extraBenefits } = useMemo(() => {
54
+ const flowId = fieldsValueSelected
55
+ .filter((x) => x.fieldId === -1808)
56
+ .map((fv) => +fv.uid.substr(6))[0]
41
57
  const tariffId = item.course?.tariffId
42
58
 
43
- const extraBenefits = (course.tariffPerFlowDataItems || [])
44
- .filter(x => x.flowId === flowId && (!tariffId || x.courseTariffId === tariffId))
45
- .map(pfdi => pfdi.marketingBenefitsComputed)[0] || []
46
- return {extraBenefits}
47
- }, [fieldsValueSelected, course.tariffPerFlowDataItems, item.course?.tariffId])
48
-
49
-
50
- // console.log('useEffect fieldsValueSelected', [...fieldsValueSelected]);
59
+ const extraBenefits =
60
+ (course.tariffPerFlowDataItems || [])
61
+ .filter(
62
+ (x) =>
63
+ x.flowId === flowId && (!tariffId || x.courseTariffId === tariffId)
64
+ )
65
+ .map((pfdi) => pfdi.marketingBenefitsComputed)[0] || []
66
+ return { extraBenefits }
67
+ }, [
68
+ fieldsValueSelected,
69
+ course.tariffPerFlowDataItems,
70
+ item.course?.tariffId,
71
+ ])
51
72
 
52
73
  const fieldValuesInfo = usePrices({
53
74
  fieldValues: item.fieldValues || [],
@@ -76,10 +97,8 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
76
97
  }
77
98
 
78
99
  fieldsValueSelectedSetter(fieldsValueSelected)
79
-
80
100
  }, [item.fieldValues])
81
101
 
82
-
83
102
  const fieldValuesByType = useMemo(() => {
84
103
  const content: JSX.Element[] = []
85
104
 
@@ -91,12 +110,23 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
91
110
  fieldsValueSelectedSetter={fieldsValueSelectedSetter}
92
111
  fieldValuesInfo={fieldValuesInfo}
93
112
  type={type}
113
+ checkedBgColor={titleBgColor}
114
+ checkedTextColor={titleTextColor}
115
+ placesLeftBgColor={extraBgColor}
116
+ placesLeftTextColor={coloredTextColor}
94
117
  />
95
118
  )
96
119
  })
97
120
 
98
121
  return content
99
- }, [fieldValuesInfo, fieldsValueSelected])
122
+ }, [
123
+ fieldValuesInfo,
124
+ fieldsValueSelected,
125
+ titleBgColor,
126
+ titleTextColor,
127
+ coloredTextColor,
128
+ extraBgColor,
129
+ ])
100
130
 
101
131
  return useMemo(() => {
102
132
  if (!item) {
@@ -123,9 +153,13 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
123
153
 
124
154
  return (
125
155
  <>
126
- <WidgetStyled>
127
- <NavigationStyled>
128
- <Typography>{flowBehaviourTitle}</Typography>
156
+ <WidgetStyled style={{ backgroundColor: mainBgColor }}>
157
+ <NavigationStyled style={{ backgroundColor: titleBgColor }}>
158
+ <Typography>
159
+ <span style={{ color: titleTextColor }}>
160
+ {flowBehaviourTitle}
161
+ </span>
162
+ </Typography>
129
163
  </NavigationStyled>
130
164
 
131
165
  <BoxStyled>
@@ -136,11 +170,18 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
136
170
  </Typography>
137
171
 
138
172
  {ratesVisible && item.reviewsCount ? (
139
- <Reviews reviewsCount={item.reviewsCount} item={item} />
173
+ <Reviews textColor={coloredTextColor} reviewsCount={item.reviewsCount} item={item} />
140
174
  ) : null}
141
175
 
142
176
  {tariff ? (
143
- <Materials benefits={tariff.marketingBenefits} extraBenefits={extraBenefits} limit={materialsLimit} />
177
+ <Materials
178
+ backgroundColor={contentBgColor}
179
+ textColor={contentTextColor}
180
+ linkColor={coloredTextColor}
181
+ benefits={tariff.marketingBenefits}
182
+ extraBenefits={extraBenefits}
183
+ limit={materialsLimit}
184
+ />
144
185
  ) : null}
145
186
 
146
187
  {fieldValuesByType}
@@ -152,6 +193,11 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
152
193
  orderLink={orderLink}
153
194
  course={course}
154
195
  fieldsValueSelected={fieldsValueSelected}
196
+ buttonBgColor={titleBgColor}
197
+ buttonTextColor={titleTextColor}
198
+ containerBgColor={contentBgColor}
199
+ dateTextColor={coloredTextColor}
200
+ selectedDateTextColor={titleTextColor}
155
201
  />
156
202
  </BoxStyled>
157
203
  </WidgetStyled>
@@ -160,6 +206,10 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
160
206
  catalogItem={item}
161
207
  orderLink={orderLink}
162
208
  fieldsValueSelected={fieldsValueSelected}
209
+ bgColor={mainBgColor}
210
+ buttonColor={titleBgColor}
211
+ buttonTextColor={titleTextColor}
212
+ titleTextColor={coloredTextColor}
163
213
  />
164
214
  </>
165
215
  )
@@ -172,6 +222,7 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
172
222
  orderLink,
173
223
  fieldsValueSelected,
174
224
  ratesVisible,
225
+ style,
175
226
  ])
176
227
  }
177
228
 
@@ -1,10 +1,3 @@
1
1
  import { WidgetOrderProps } from '../interfaces'
2
2
 
3
- export type CourseItemComponentProps = WidgetOrderProps & {
4
- /**
5
- * ID Текущего элемента
6
- */
7
- // currentItemId: CourseItem["uid"]
8
- // altItems?: CourseItem[]
9
- // orderLink: string
10
- }
3
+ export type CourseItemComponentProps = WidgetOrderProps & {}
@@ -51,10 +51,8 @@ export const WidgetStyled = styled.div`
51
51
  text-transform: uppercase;
52
52
  font-weight: 600;
53
53
  font-size: 13px;
54
- color: #233d78;
55
54
  padding: 5px 0;
56
55
  margin: 5px 0;
57
- background: rgba(35, 61, 120, 0.1);
58
56
  }
59
57
 
60
58
  &.buy {
@@ -1,9 +1,17 @@
1
1
  import React from 'react'
2
- import { ButtonStyled } from './styles'
2
+ import { TITLE_BG_DEFAULT_COLOR } from '../../constants/colors'
3
3
  import { ButtonProps } from './interfaces'
4
+ import { ButtonStyled } from './styles'
4
5
 
5
6
  const Button: React.FC<ButtonProps> = (props) => {
6
- return <ButtonStyled {...props} />
7
+ return (
8
+ <ButtonStyled
9
+ style={{
10
+ backgroundColor: props.backgroundColor ?? TITLE_BG_DEFAULT_COLOR,
11
+ }}
12
+ {...props}
13
+ />
14
+ )
7
15
  }
8
16
 
9
17
  export default Button
@@ -1 +1,3 @@
1
- export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>
1
+ export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
2
+ backgroundColor?: string
3
+ }
@@ -1,11 +1,14 @@
1
1
  import styled from 'styled-components'
2
+ import { CONTENT_BG_DEFAULT_COLOR } from '../../constants/colors'
2
3
 
3
4
  export type ContainerStyledProps = {
4
5
  variant?: 'transparent' | 'white'
6
+ bgColor?: string
5
7
  }
6
8
 
7
9
  export const ContainerStyled = styled.div<ContainerStyledProps>`
8
10
  background: ${({ variant }) => variant || 'transparent'};
11
+ background-color: ${({ bgColor }) => bgColor ?? CONTENT_BG_DEFAULT_COLOR};
9
12
  border-radius: 8px;
10
13
  padding: 10px;
11
14
  width: 100%;
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useMemo } from 'react'
2
- import { RadioGroupRowStyled, RadioGroupStyled } from './styles'
3
2
  import { RadioGroupProps } from './interfaces'
3
+ import { RadioGroupRowStyled, RadioGroupStyled } from './styles'
4
4
 
5
5
  export * from './interfaces'
6
6
 
@@ -11,11 +11,10 @@ export const RadioGroup: React.FC<RadioGroupProps> = ({
11
11
  items,
12
12
  value,
13
13
  onChangeIndex,
14
+ checkedBgColor,
15
+ checkedTextColor,
14
16
  ...other
15
17
  }) => {
16
- // console.log('RadioGroup items', items);
17
- // console.log('RadioGroup value', value);
18
-
19
18
  /**
20
19
  * Это просто заглушка, так как на клик изменения навешаны
21
20
  */
@@ -27,7 +26,6 @@ export const RadioGroup: React.FC<RadioGroupProps> = ({
27
26
  (event: React.MouseEvent<HTMLDivElement>) => {
28
27
  const value = event.currentTarget.dataset.value
29
28
 
30
- // value && tariffIdSetter(parseInt(value))
31
29
  onChangeIndex(value)
32
30
  },
33
31
  [onChangeIndex]
@@ -50,29 +48,15 @@ export const RadioGroup: React.FC<RadioGroupProps> = ({
50
48
  data-value={n.uid}
51
49
  onClick={onRowClick}
52
50
  checked={checked}
51
+ checkedBgColor={checkedBgColor}
52
+ checkedTextColor={checkedTextColor}
53
53
  >
54
54
  <input type="radio" checked={checked} onChange={onChange} />{' '}
55
55
  {n.label}
56
- {/* <Typography
57
- variant="grey-sm"
58
- component="label"
59
- className="altItemText"
60
- >
61
- {n.course?.prolongationDays
62
- ? `Продление на ${n.course?.prolongationDays} дней`
63
- : n.name}{' '}
64
- -{' '}
65
- <NumberFormat
66
- value={n.unitPrice}
67
- displayType="text"
68
- thousandSeparator={' '}
69
- />{' '}
70
- ₽
71
- </Typography> */}
72
56
  </RadioGroupRowStyled>
73
57
  )
74
58
  })}
75
59
  </RadioGroupStyled>
76
60
  )
77
- }, [items, onChange, onRowClick, other, value])
61
+ }, [items, onChange, onRowClick, other, value, checkedBgColor])
78
62
  }
@@ -6,6 +6,8 @@ export type RadioGroupItem = Record<string, unknown> & {
6
6
  export type RadioGroupProps = {
7
7
  items: RadioGroupItem[]
8
8
  value: number | string
9
+ checkedBgColor?: string
10
+ checkedTextColor?: string
9
11
 
10
12
  /**
11
13
  * Ивент на изменение активного элемента
@@ -1,8 +1,14 @@
1
1
  import styled, { css } from 'styled-components'
2
+ import {
3
+ TITLE_BG_DEFAULT_COLOR,
4
+ TITLE_TEXT_DEFAULT_COLOR,
5
+ } from '../../constants/colors'
2
6
  import { WidgetOrderStyled } from '../../styles'
3
7
 
4
8
  export const RadioGroupRowStyled = styled.div<{
5
9
  checked: boolean
10
+ checkedBgColor?: string
11
+ checkedTextColor?: string
6
12
  }>`
7
13
  /*
8
14
  Добавляем вложенность для жесткости стилей
@@ -33,14 +39,14 @@ export const RadioGroupRowStyled = styled.div<{
33
39
  /*
34
40
  JS-логика не работает во вложенности WidgetOrderStyled &
35
41
  */
36
- ${({ checked }) => {
42
+ ${({ checked, checkedBgColor, checkedTextColor }) => {
37
43
  if (checked) {
38
44
  return css`
39
- background: #233d78;
45
+ background-color: ${checkedBgColor ?? TITLE_BG_DEFAULT_COLOR};
40
46
  border-radius: 5px;
41
47
 
42
48
  label {
43
- color: white;
49
+ color: ${checkedTextColor ?? TITLE_TEXT_DEFAULT_COLOR};
44
50
  }
45
51
  `
46
52
  }
@@ -19,5 +19,5 @@ export const TypographyStyled = styled.p<TypographyStyledProps>`
19
19
 
20
20
  default:
21
21
  }
22
- }}
22
+ }};
23
23
  `
@@ -0,0 +1,7 @@
1
+ export const TITLE_BG_DEFAULT_COLOR = '#233D78'
2
+ export const MAIN_BG_DEFAULT_COLOR = '#F1F5F9'
3
+ export const CONTENT_BG_DEFAULT_COLOR = '#FFFFFF'
4
+ export const EXTRA_BG_DEFAULT_COLOR = '#233D78'
5
+ export const TITLE_TEXT_DEFAULT_COLOR = '#FFFFFF'
6
+ export const CONTENT_TEXT_DEFAULT_COLOR = '#1D3247'
7
+ export const COLORED_TEXT_DEFAULT_COLOR = '#233d78'
package/src/index.tsx CHANGED
@@ -1,9 +1,9 @@
1
+ import moment from 'moment'
2
+ import 'moment/locale/ru'
1
3
  import React, { useMemo } from 'react'
4
+ import CourseItem from './CourseItem'
2
5
  import { WidgetOrderProps } from './interfaces'
3
6
  import { WidgetOrderStyled } from './styles'
4
- import CourseItem from './CourseItem'
5
- import moment from 'moment'
6
- import 'moment/locale/ru'
7
7
 
8
8
  moment.locale('ru')
9
9
 
@@ -25,6 +25,7 @@ const WidgetOrder: React.FC<WidgetOrderProps> = ({
25
25
  materialsLimit={materialsLimit}
26
26
  ratesVisible={other.ratesVisible}
27
27
  course={course}
28
+ style={other.style}
28
29
  />
29
30
  </WidgetOrderStyled>
30
31
  )