@procraft/widget-order 2.28.0 → 2.29.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/CourseItem/Materials/index.js +4 -15
- package/dist/CourseItem/Materials/index.js.map +1 -1
- package/dist/CourseItem/Materials/interfaces.d.ts +1 -0
- package/dist/CourseItem/OrderButton/index.js +3 -2
- package/dist/CourseItem/OrderButton/index.js.map +1 -1
- package/dist/CourseItem/OrderButton/interfaces.d.ts +2 -1
- package/dist/CourseItem/index.js +26 -20
- package/dist/CourseItem/index.js.map +1 -1
- package/dist/components/Button/index.js +5 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/interfaces.d.ts +3 -1
- package/dist/constants/colors.d.ts +3 -0
- package/dist/constants/colors.js +7 -0
- package/dist/constants/colors.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/CourseItem/Materials/index.tsx +14 -4
- package/src/CourseItem/Materials/interfaces.ts +1 -0
- package/src/CourseItem/OrderButton/index.tsx +3 -0
- package/src/CourseItem/OrderButton/interfaces.ts +2 -13
- package/src/CourseItem/index.tsx +44 -26
- package/src/CourseItem/interfaces.ts +1 -8
- package/src/components/Button/index.tsx +10 -2
- package/src/components/Button/interfaces.ts +3 -1
- package/src/constants/colors.ts +3 -0
- package/src/index.tsx +4 -3
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react'
|
|
2
|
+
import { INFO_BG_DEFAULT_COLOR } from '../../constants/colors'
|
|
2
3
|
import { MaterialsProps } from './interfaces'
|
|
3
4
|
import { MaterialsStyled } from './styles'
|
|
4
5
|
|
|
5
|
-
const Materials: React.FC<MaterialsProps> = ({
|
|
6
|
+
const Materials: React.FC<MaterialsProps> = ({
|
|
7
|
+
benefits,
|
|
8
|
+
extraBenefits,
|
|
9
|
+
limit,
|
|
10
|
+
backgroundColor,
|
|
11
|
+
}) => {
|
|
6
12
|
const [showAll, showAllSetter] = useState(false)
|
|
7
13
|
|
|
8
14
|
const renderBenefit = useMemo(
|
|
@@ -67,7 +73,8 @@ const Materials: React.FC<MaterialsProps> = ({ benefits, extraBenefits, limit, .
|
|
|
67
73
|
) : null
|
|
68
74
|
|
|
69
75
|
return {
|
|
70
|
-
materials:
|
|
76
|
+
materials:
|
|
77
|
+
showAll || !hasMore ? allBenefits : allBenefits.slice(0, limit),
|
|
71
78
|
showAllButton,
|
|
72
79
|
}
|
|
73
80
|
}, [showAll, showAllOnClick, limit, benefits, extraBenefits])
|
|
@@ -78,13 +85,16 @@ const Materials: React.FC<MaterialsProps> = ({ benefits, extraBenefits, limit, .
|
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
return (
|
|
81
|
-
<MaterialsStyled
|
|
88
|
+
<MaterialsStyled
|
|
89
|
+
style={{ backgroundColor: backgroundColor ?? INFO_BG_DEFAULT_COLOR }}
|
|
90
|
+
variant="white"
|
|
91
|
+
>
|
|
82
92
|
<ol>{materials.map(renderBenefit)}</ol>
|
|
83
93
|
|
|
84
94
|
{showAllButton}
|
|
85
95
|
</MaterialsStyled>
|
|
86
96
|
)
|
|
87
|
-
}, [materials,
|
|
97
|
+
}, [materials, renderBenefit, showAllButton, backgroundColor])
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
export default Materials
|
|
@@ -29,6 +29,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
29
29
|
fieldsValueSelected,
|
|
30
30
|
orderLink,
|
|
31
31
|
course,
|
|
32
|
+
backgroundColor,
|
|
32
33
|
}) => {
|
|
33
34
|
useEffect(() => {
|
|
34
35
|
dateIndexSetter(0)
|
|
@@ -195,6 +196,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
195
196
|
<div className="buy">
|
|
196
197
|
<a href={uri.toString()} className="buy-link">
|
|
197
198
|
<Button
|
|
199
|
+
backgroundColor={backgroundColor}
|
|
198
200
|
disabled={
|
|
199
201
|
Boolean(currStartDate) && moment(currStartDate) > moment()
|
|
200
202
|
}
|
|
@@ -230,5 +232,6 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
230
232
|
catalogItem.master?.currency,
|
|
231
233
|
dateIndex,
|
|
232
234
|
onClickDateIndex,
|
|
235
|
+
backgroundColor
|
|
233
236
|
])
|
|
234
237
|
}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
// import { WidgetOrderCourseItem } from '../../interfaces'
|
|
2
1
|
import { CourseFragment } from '../../interfaces/CourseFragment'
|
|
3
2
|
import {
|
|
4
3
|
CatalogFieldValue,
|
|
5
4
|
OrderCatalogItemFragment,
|
|
6
5
|
} from '../../modules/gql/generated/types'
|
|
7
|
-
// import { CourseTariffPriceDetailsSubscriptionItem } from '../../modules/gql/generated/types'
|
|
8
6
|
|
|
9
7
|
export type OrderButtonProps = {
|
|
10
|
-
// item: WidgetOrderCourseItem
|
|
11
|
-
|
|
12
|
-
catalogItem: OrderCatalogItemFragment
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
* Выбранные элементы, которые войдут в заказ
|
|
16
11
|
*/
|
|
17
12
|
fieldsValueSelected: CatalogFieldValue[]
|
|
18
|
-
|
|
19
|
-
// courses: CourseFragment[]
|
|
13
|
+
catalogItem: OrderCatalogItemFragment
|
|
20
14
|
course: CourseFragment
|
|
21
|
-
|
|
22
15
|
orderLink: string
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Выбранный вариант подписки, если есть
|
|
26
|
-
*/
|
|
27
|
-
// subscription: CourseTariffPriceDetailsSubscriptionItem | null
|
|
16
|
+
backgroundColor?: string
|
|
28
17
|
}
|
package/src/CourseItem/index.tsx
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
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 {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
INFO_BG_DEFAULT_COLOR,
|
|
5
|
+
MAIN_BG_DEFAULT_COLOR,
|
|
6
|
+
TITLE_DEFAULT_COLOR,
|
|
7
|
+
} from '../constants/colors'
|
|
8
|
+
import { usePrices } from '../hooks/usePrices'
|
|
8
9
|
import {
|
|
9
10
|
CatalogFieldValueType,
|
|
10
11
|
CourseTariffFlowBehaviour,
|
|
11
12
|
} from '../modules/gql/generated/types'
|
|
12
|
-
import { Reviews } from './Reviews'
|
|
13
13
|
import { FieldValuesProps } from './FieldValues/interfaces'
|
|
14
|
-
import { usePrices } from '../hooks/usePrices'
|
|
15
14
|
import { FieldValuesByType } from './FieldValuesByType'
|
|
15
|
+
import { CourseItemComponentProps } from './interfaces'
|
|
16
|
+
import Materials from './Materials'
|
|
17
|
+
import { OrderButton } from './OrderButton'
|
|
18
|
+
import { Reviews } from './Reviews'
|
|
19
|
+
import Sales from './Sales'
|
|
20
|
+
import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
|
|
16
21
|
|
|
17
22
|
const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
18
23
|
const {
|
|
@@ -21,14 +26,9 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
21
26
|
course,
|
|
22
27
|
catalogItem: item,
|
|
23
28
|
ratesVisible,
|
|
29
|
+
style,
|
|
24
30
|
} = props
|
|
25
31
|
|
|
26
|
-
/**
|
|
27
|
-
* ID текущего элемента
|
|
28
|
-
*/
|
|
29
|
-
// const [currentItemId, setCurrentItemId] = useState(items[0]?.uid)
|
|
30
|
-
// const [currentItemId, setCurrentItemId] = useState(0)
|
|
31
|
-
|
|
32
32
|
/**
|
|
33
33
|
* Текущий элемент
|
|
34
34
|
*/
|
|
@@ -36,16 +36,25 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
36
36
|
FieldValuesProps['fieldsValueSelected']
|
|
37
37
|
>([])
|
|
38
38
|
|
|
39
|
-
const {extraBenefits} = useMemo(() => {
|
|
40
|
-
const flowId = fieldsValueSelected
|
|
39
|
+
const { extraBenefits } = useMemo(() => {
|
|
40
|
+
const flowId = fieldsValueSelected
|
|
41
|
+
.filter((x) => x.fieldId === -1808)
|
|
42
|
+
.map((fv) => +fv.uid.substr(6))[0]
|
|
41
43
|
const tariffId = item.course?.tariffId
|
|
42
44
|
|
|
43
|
-
const extraBenefits =
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const extraBenefits =
|
|
46
|
+
(course.tariffPerFlowDataItems || [])
|
|
47
|
+
.filter(
|
|
48
|
+
(x) =>
|
|
49
|
+
x.flowId === flowId && (!tariffId || x.courseTariffId === tariffId)
|
|
50
|
+
)
|
|
51
|
+
.map((pfdi) => pfdi.marketingBenefitsComputed)[0] || []
|
|
52
|
+
return { extraBenefits }
|
|
53
|
+
}, [
|
|
54
|
+
fieldsValueSelected,
|
|
55
|
+
course.tariffPerFlowDataItems,
|
|
56
|
+
item.course?.tariffId,
|
|
57
|
+
])
|
|
49
58
|
|
|
50
59
|
// console.log('useEffect fieldsValueSelected', [...fieldsValueSelected]);
|
|
51
60
|
|
|
@@ -76,10 +85,8 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
fieldsValueSelectedSetter(fieldsValueSelected)
|
|
79
|
-
|
|
80
88
|
}, [item.fieldValues])
|
|
81
89
|
|
|
82
|
-
|
|
83
90
|
const fieldValuesByType = useMemo(() => {
|
|
84
91
|
const content: JSX.Element[] = []
|
|
85
92
|
|
|
@@ -121,10 +128,14 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
121
128
|
break
|
|
122
129
|
}
|
|
123
130
|
|
|
131
|
+
const titleColor = style?.['titleColor'] ?? TITLE_DEFAULT_COLOR
|
|
132
|
+
const mainBgColor = style?.['mainBgColor'] ?? MAIN_BG_DEFAULT_COLOR
|
|
133
|
+
const infoBgColor = style?.['infoBgColor'] ?? INFO_BG_DEFAULT_COLOR
|
|
134
|
+
|
|
124
135
|
return (
|
|
125
136
|
<>
|
|
126
|
-
<WidgetStyled>
|
|
127
|
-
<NavigationStyled>
|
|
137
|
+
<WidgetStyled style={{ backgroundColor: mainBgColor }}>
|
|
138
|
+
<NavigationStyled style={{ backgroundColor: titleColor }}>
|
|
128
139
|
<Typography>{flowBehaviourTitle}</Typography>
|
|
129
140
|
</NavigationStyled>
|
|
130
141
|
|
|
@@ -140,7 +151,12 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
140
151
|
) : null}
|
|
141
152
|
|
|
142
153
|
{tariff ? (
|
|
143
|
-
<Materials
|
|
154
|
+
<Materials
|
|
155
|
+
backgroundColor={infoBgColor}
|
|
156
|
+
benefits={tariff.marketingBenefits}
|
|
157
|
+
extraBenefits={extraBenefits}
|
|
158
|
+
limit={materialsLimit}
|
|
159
|
+
/>
|
|
144
160
|
) : null}
|
|
145
161
|
|
|
146
162
|
{fieldValuesByType}
|
|
@@ -152,6 +168,7 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
152
168
|
orderLink={orderLink}
|
|
153
169
|
course={course}
|
|
154
170
|
fieldsValueSelected={fieldsValueSelected}
|
|
171
|
+
backgroundColor={titleColor}
|
|
155
172
|
/>
|
|
156
173
|
</BoxStyled>
|
|
157
174
|
</WidgetStyled>
|
|
@@ -172,6 +189,7 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
172
189
|
orderLink,
|
|
173
190
|
fieldsValueSelected,
|
|
174
191
|
ratesVisible,
|
|
192
|
+
style,
|
|
175
193
|
])
|
|
176
194
|
}
|
|
177
195
|
|
|
@@ -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 & {}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { TITLE_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
|
|
7
|
+
return (
|
|
8
|
+
<ButtonStyled
|
|
9
|
+
style={{
|
|
10
|
+
backgroundColor: props.backgroundColor ?? TITLE_DEFAULT_COLOR,
|
|
11
|
+
}}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
export default Button
|
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
|
)
|