@procraft/widget-order 2.30.5 → 2.30.7

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/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.30.5",
4
+ "version": "2.30.7",
5
5
  "private": false,
6
6
  "main": "dist",
7
7
  "scripts": {
@@ -49,12 +49,12 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
49
49
  */
50
50
  const [dateIndex, dateIndexSetter] = useState(0)
51
51
 
52
- const uri = useOrderLink({
52
+ let uri = useOrderLink({
53
53
  catalogItem,
54
54
  orderLink,
55
55
  fieldsValueSelected,
56
56
  sale: undefined,
57
- })
57
+ }).toString()
58
58
 
59
59
  const onClickDateIndex = useCallback((event: MouseEvent<HTMLSpanElement>) => {
60
60
  const idx = parseInt(event.currentTarget.dataset.idx ?? '')
@@ -162,6 +162,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
162
162
 
163
163
  let oldPrice = 0
164
164
  let price = 0
165
+ let promoCode = ''
165
166
 
166
167
  /**
167
168
  * Можно ли сделать заказ
@@ -192,6 +193,12 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
192
193
  price = saleDateItem.priceReal
193
194
  }
194
195
 
196
+ if (catalogItem.priceWithPromoCode && catalogItem.promoCode?.code) {
197
+ price = catalogItem.priceWithPromoCode
198
+ promoCode = catalogItem.promoCode.code
199
+ uri = `${uri}&promoCode=${promoCode}`
200
+ }
201
+
195
202
  const currencyPrefix = getCurrencyPrefix(catalogItem.master?.currency || '')
196
203
  const currencySuffix = getCurrencySuffix(catalogItem.master?.currency || '')
197
204
 
@@ -221,7 +228,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
221
228
  <div className="buy">
222
229
  <a href={uri.toString()} className="buy-link">
223
230
  <Button
224
- backgroundColor={buttonBgColor}
231
+ backgroundColor={promoCode ? '#F04020' : buttonBgColor}
225
232
  textColor={buttonTextColor}
226
233
  disabled={
227
234
  Boolean(currStartDate) && moment(currStartDate) > moment()
@@ -229,7 +236,7 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
229
236
  >
230
237
  {price ? (
231
238
  <>
232
- Купить за{' '}
239
+ {promoCode ? 'По промо за ' : 'Купить за '}
233
240
  <NumberFormat
234
241
  value={price}
235
242
  displayType="text"
@@ -11,8 +11,7 @@ import {
11
11
  } from '../constants/colors'
12
12
  import { usePrices } from '../hooks/usePrices'
13
13
  import {
14
- CatalogFieldValueType,
15
- CourseTariffFlowBehaviour,
14
+ CatalogFieldValueType, CourseSubKind,
16
15
  } from '../modules/gql/generated/types'
17
16
  import { FieldValuesProps } from './FieldValues/interfaces'
18
17
  import { FieldValuesByType } from './FieldValuesByType'
@@ -22,6 +21,7 @@ import { OrderButton } from './OrderButton'
22
21
  import { Reviews } from './Reviews'
23
22
  import Sales from './Sales'
24
23
  import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
24
+ import { formatCourseSubKindLabel } from '../models/Course'
25
25
 
26
26
  const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
27
27
  const {
@@ -135,21 +135,10 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
135
135
 
136
136
  const tariff = course.tariffs?.find((n) => n.uid === item.course?.tariffId)
137
137
 
138
- let flowBehaviourTitle: string | undefined
139
-
140
- switch (tariff?.flowBehaviour) {
141
- case CourseTariffFlowBehaviour.CONTINUOUS:
142
- flowBehaviourTitle = 'Постоянный набор'
143
- break
144
-
145
- case CourseTariffFlowBehaviour.MULTIPLE:
146
- flowBehaviourTitle = 'Поточный набор'
147
- break
148
-
149
- case CourseTariffFlowBehaviour.SINGLE:
150
- flowBehaviourTitle = 'Разовый набор'
151
- break
152
- }
138
+ const title = formatCourseSubKindLabel({
139
+ subKind: course.subKind ?? CourseSubKind.COURSE,
140
+ subKindLabel: course.subKindLabel,
141
+ })
153
142
 
154
143
  return (
155
144
  <>
@@ -157,7 +146,7 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
157
146
  <NavigationStyled style={{ backgroundColor: titleBgColor }}>
158
147
  <Typography>
159
148
  <span style={{ color: titleTextColor }}>
160
- {flowBehaviourTitle}
149
+ {title}
161
150
  </span>
162
151
  </Typography>
163
152
  </NavigationStyled>