@procraft/widget-order 2.21.9 → 2.21.10
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
|
@@ -52,7 +52,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
52
52
|
orderLink,
|
|
53
53
|
fieldsValueSelected,
|
|
54
54
|
sale: undefined,
|
|
55
|
-
})
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(uri)
|
|
56
58
|
|
|
57
59
|
return useMemo(() => {
|
|
58
60
|
// if (!global.location?.origin) {
|
|
@@ -78,68 +80,66 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
78
80
|
let saleDateItem: CourseTariffPriceDetailsChangeByTimeItem | undefined
|
|
79
81
|
|
|
80
82
|
const changeByTimeItems = saleByTime?.priceDetails?.changeByTime?.items || [];
|
|
83
|
+
let currStartDate = null;
|
|
81
84
|
|
|
82
85
|
if (changeByTimeItems.length > 1) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
variant="white"
|
|
91
|
-
>
|
|
92
|
-
<span
|
|
93
|
-
key="first"
|
|
94
|
-
className={dateIndex === 0 ? 'active' : undefined}
|
|
95
|
-
onClick={() => dateIndexSetter(0)}
|
|
96
|
-
>
|
|
97
|
-
Цена до {moment(changeByTimeItemsFiltered[0].startsAt).format('DD MMMM')}
|
|
98
|
-
</span>
|
|
99
|
-
{changeByTimeItemsFiltered
|
|
100
|
-
.map((item, idx) => (
|
|
101
|
-
<span
|
|
102
|
-
key={String(item.startsAt)}
|
|
103
|
-
className={dateIndex === idx + 1 ? 'active' : undefined}
|
|
104
|
-
onClick={() => dateIndexSetter(idx + 1)}
|
|
105
|
-
>
|
|
106
|
-
Цена после {moment(item.startsAt).format('DD MMMM')}
|
|
107
|
-
</span>
|
|
108
|
-
))
|
|
86
|
+
let firstFutureItemIndex = changeByTimeItems.findIndex(item => moment(item.startsAt) > moment())
|
|
87
|
+
let changeByTimeItemsNew: any[] = [];
|
|
88
|
+
|
|
89
|
+
if(firstFutureItemIndex === -1) {
|
|
90
|
+
const item = [...changeByTimeItems].sort((a,b) => {
|
|
91
|
+
if(moment(a.startsAt) > moment(b.startsAt)) {
|
|
92
|
+
return -1;
|
|
109
93
|
}
|
|
110
|
-
</OrderButtonByDateSalesStyled>
|
|
111
|
-
)
|
|
112
94
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
return 1;
|
|
96
|
+
})[0];
|
|
97
|
+
|
|
98
|
+
changeByTimeItemsNew.push(item)
|
|
99
|
+
} else {
|
|
100
|
+
changeByTimeItemsNew = changeByTimeItemsNew.concat([
|
|
101
|
+
changeByTimeItems[firstFutureItemIndex - 1],
|
|
102
|
+
...changeByTimeItems.filter(item => moment(item.startsAt) > moment())
|
|
103
|
+
].filter(v => v))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log('>>> changeByTimeItemsNew', changeByTimeItemsNew)
|
|
107
|
+
const expiratedFound = changeByTimeItems.findIndex(item => moment(item.startsAt) < moment());
|
|
120
108
|
|
|
121
|
-
|
|
109
|
+
saleDateItem = changeByTimeItemsNew[dateIndex];
|
|
110
|
+
|
|
111
|
+
if(changeByTimeItemsNew[1]) {
|
|
112
|
+
if(expiratedFound) {
|
|
113
|
+
changeByTimeItemsNew = changeByTimeItemsNew
|
|
114
|
+
.map((item) => ({
|
|
115
|
+
...item,
|
|
116
|
+
startsAt: moment(item.startsAt) > moment() ? item.startsAt : null
|
|
117
|
+
}))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
currStartDate = changeByTimeItemsNew[dateIndex].startsAt;
|
|
122
121
|
|
|
123
122
|
content.push(
|
|
124
123
|
<OrderButtonByDateSalesStyled
|
|
125
124
|
key="OrderButtonByDateSalesStyled"
|
|
126
125
|
variant="white"
|
|
127
126
|
>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
{changeByTimeItemsNew
|
|
128
|
+
.map((item, idx) => (
|
|
129
|
+
<span
|
|
130
|
+
key={idx}
|
|
131
|
+
className={dateIndex === idx ? 'active' : undefined}
|
|
132
|
+
onClick={() => dateIndexSetter(idx)}
|
|
133
|
+
>
|
|
134
|
+
{item.startsAt
|
|
135
|
+
? `Цена после ${moment(item.startsAt).format('D MMMM')}`
|
|
136
|
+
: `Цена до ${moment(changeByTimeItemsNew[1].startsAt).format('D MMMM')}`}
|
|
137
|
+
</span>
|
|
138
|
+
))
|
|
139
|
+
}
|
|
140
140
|
</OrderButtonByDateSalesStyled>
|
|
141
141
|
)
|
|
142
|
-
}
|
|
142
|
+
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
// let oldPrice = item.oldPrice
|
|
@@ -156,8 +156,6 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
156
156
|
let canOrder = true
|
|
157
157
|
|
|
158
158
|
fieldsValueSelected.forEach((n) => {
|
|
159
|
-
// console.log('fieldsValueSelected n', n)
|
|
160
|
-
|
|
161
159
|
const { extraPay, extraPayOriginal, availableCount } = n
|
|
162
160
|
|
|
163
161
|
/**
|
|
@@ -236,8 +234,6 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
236
234
|
freeLabel = 'Бесплатный курс'; break;
|
|
237
235
|
}
|
|
238
236
|
|
|
239
|
-
const currStartDate = saleByTime?.priceDetails.changeByTime?.items[dateIndex].startsAt;
|
|
240
|
-
|
|
241
237
|
content.push(
|
|
242
238
|
<Container key="buy" variant="white" className="buy">
|
|
243
239
|
{oldPrice && oldPrice > price ? <OldPrice price={oldPrice} /> : null}
|
|
@@ -250,9 +246,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
250
246
|
|
|
251
247
|
<div className="buy">
|
|
252
248
|
<a href={uri.toString()} className="buy-link">
|
|
253
|
-
<Button
|
|
254
|
-
Boolean(currStartDate) && moment(currStartDate) > moment()
|
|
255
|
-
|
|
249
|
+
<Button
|
|
250
|
+
disabled={Boolean(currStartDate) && moment(currStartDate) > moment()}
|
|
251
|
+
>
|
|
256
252
|
{price ? (
|
|
257
253
|
<>
|
|
258
254
|
Купить за{' '}
|