@procraft/widget-order 2.22.11 → 2.23.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/OrderButton/index.js +3 -40
- package/dist/CourseItem/OrderButton/index.js.map +1 -1
- package/dist/CourseItem/Sales/Sale/index.js +3 -4
- package/dist/CourseItem/Sales/Sale/index.js.map +1 -1
- package/dist/CourseItem/index.js +3 -37
- package/dist/CourseItem/index.js.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/modules/gql/generated/types.d.ts +1 -0
- package/dist/modules/gql/generated/types.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +23 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/CourseItem/OrderButton/index.tsx +4 -49
- package/src/CourseItem/Sales/Sale/index.tsx +4 -2
- package/src/CourseItem/index.tsx +0 -107
- package/src/index.tsx +10 -22
- package/src/interfaces/index.ts +5 -0
- package/src/modules/gql/generated/types.ts +1 -0
- package/src/utils.ts +22 -0
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const roundByStep: (v: number, s?: number) => number;
|
|
2
2
|
export declare const roundStd: (num: number, decimalPlaces: number) => number;
|
|
3
|
+
export declare const getCurrencyPrefix: (currency: string) => "" | "$";
|
|
4
|
+
export declare const getCurrencySuffix: (currency: string) => "" | " ₽" | " ₸" | " ₴";
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundStd = exports.roundByStep = void 0;
|
|
3
|
+
exports.getCurrencySuffix = exports.getCurrencyPrefix = exports.roundStd = exports.roundByStep = void 0;
|
|
4
4
|
const roundByStep = (v, s = 1.0) => {
|
|
5
5
|
const inv = 1.0 / s;
|
|
6
6
|
return Math.round(v * inv) / inv;
|
|
@@ -12,4 +12,26 @@ const roundStd = (num, decimalPlaces) => {
|
|
|
12
12
|
return Math.round(num * p + e) / p;
|
|
13
13
|
};
|
|
14
14
|
exports.roundStd = roundStd;
|
|
15
|
+
const getCurrencyPrefix = (currency) => {
|
|
16
|
+
switch (currency) {
|
|
17
|
+
case 'RUB': return '';
|
|
18
|
+
case 'USD': return '$';
|
|
19
|
+
case 'KZT': return '';
|
|
20
|
+
case 'UAH': return '';
|
|
21
|
+
default: return '';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.getCurrencyPrefix = getCurrencyPrefix;
|
|
25
|
+
const getCurrencySuffix = (currency) => {
|
|
26
|
+
switch (currency) {
|
|
27
|
+
case 'RUB': return ' ₽';
|
|
28
|
+
case 'USD': return '';
|
|
29
|
+
case 'KZT': return ' ₸';
|
|
30
|
+
case 'UAH': return ' ₴';
|
|
31
|
+
default:
|
|
32
|
+
console.warn(`Unknown currency ${currency}`);
|
|
33
|
+
return ' ₽';
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.getCurrencySuffix = getCurrencySuffix;
|
|
15
37
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,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"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,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,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACrB,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAA;QACtB,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACrB,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACrB,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;KACnB;AACH,CAAC,CAAA;AARY,QAAA,iBAAiB,qBAQ7B;AAEM,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACpD,QAAQ,QAAQ,EAAE;QAChB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACrB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAA;QACvB;YACE,OAAO,CAAC,IAAI,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAA;YAC5C,OAAO,IAAI,CAAA;KACd;AACH,CAAC,CAAA;AAVY,QAAA,iBAAiB,qBAU7B"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import moment from 'moment'
|
|
2
|
-
// import Link from 'next/link';
|
|
3
2
|
import React, {
|
|
4
3
|
MouseEvent,
|
|
5
4
|
useCallback,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
} from '../../modules/gql/generated/types'
|
|
21
20
|
import { OrderButtonProps } from './interfaces'
|
|
22
21
|
import { OrderButtonByDateSalesStyled } from './styles'
|
|
22
|
+
import {getCurrencyPrefix, getCurrencySuffix} from "../../utils";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Кнопка заказа
|
|
@@ -73,22 +73,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
73
73
|
}, [])
|
|
74
74
|
|
|
75
75
|
return useMemo(() => {
|
|
76
|
-
// if (!global.location?.origin) {
|
|
77
|
-
// if (!loaded) {
|
|
78
|
-
// return null
|
|
79
|
-
// }
|
|
80
76
|
|
|
81
77
|
const content: JSX.Element[] = []
|
|
82
78
|
|
|
83
|
-
// const catalogItem = item.catalogItem
|
|
84
|
-
|
|
85
|
-
// const course = courses.find((n) => n.uid === catalogItem.course?.courseId)
|
|
86
|
-
|
|
87
|
-
// if (!course) {
|
|
88
|
-
// console.error('Can no get course')
|
|
89
|
-
// return null
|
|
90
|
-
// }
|
|
91
|
-
|
|
92
79
|
const saleByTime = course.tariffPerFlowDataItems?.find(
|
|
93
80
|
(n) =>
|
|
94
81
|
n.priceDetails.kind === CourseTariffPriceKind.CHANGESBYTIME &&
|
|
@@ -171,11 +158,6 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
171
158
|
}
|
|
172
159
|
}
|
|
173
160
|
|
|
174
|
-
// let oldPrice = item.oldPrice
|
|
175
|
-
// let price = item.price
|
|
176
|
-
|
|
177
|
-
// const fieldValuesQuery: string[] = [];
|
|
178
|
-
|
|
179
161
|
let oldPrice = 0
|
|
180
162
|
let price = 0
|
|
181
163
|
|
|
@@ -197,45 +179,17 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
197
179
|
|
|
198
180
|
price += extraPay
|
|
199
181
|
oldPrice += extraPayOriginal || extraPay
|
|
200
|
-
|
|
201
|
-
// fieldValuesQuery.push(n.uid)
|
|
202
|
-
|
|
203
|
-
// uri.searchParams.append('fieldValuesQuery', n.uid)
|
|
204
182
|
})
|
|
205
183
|
|
|
206
184
|
if (!canOrder) {
|
|
207
185
|
return null
|
|
208
186
|
}
|
|
209
187
|
|
|
210
|
-
// if(fieldValuesQuery.length) {
|
|
211
|
-
// uri.searchParams.append('fieldValuesQuery', fieldValuesQuery)
|
|
212
|
-
// }
|
|
213
|
-
|
|
214
188
|
if (saleDateItem) {
|
|
215
189
|
oldPrice = saleDateItem.priceMarketing
|
|
216
190
|
price = saleDateItem.priceReal
|
|
217
191
|
}
|
|
218
192
|
|
|
219
|
-
/**
|
|
220
|
-
* Если есть подписка, берем цены из нее
|
|
221
|
-
*/
|
|
222
|
-
// if (subscription) {
|
|
223
|
-
// oldPrice = subscription.priceMarketing || null
|
|
224
|
-
// price = subscription.priceReal
|
|
225
|
-
|
|
226
|
-
// uri.searchParams.append('subscription_unit', subscription.period.unit)
|
|
227
|
-
// uri.searchParams.append(
|
|
228
|
-
// 'subscription_amount',
|
|
229
|
-
// subscription.period.amount.toString()
|
|
230
|
-
// )
|
|
231
|
-
|
|
232
|
-
// // uri.search = {
|
|
233
|
-
// // ...uri.search,
|
|
234
|
-
// // subscription_unit: subscription.period.unit,
|
|
235
|
-
// // subscription_amount: subscription.period.amount,
|
|
236
|
-
// // }
|
|
237
|
-
// }
|
|
238
|
-
|
|
239
193
|
let freeLabel
|
|
240
194
|
|
|
241
195
|
switch (course.subKind) {
|
|
@@ -298,8 +252,9 @@ export const OrderButton: React.FC<OrderButtonProps> = ({
|
|
|
298
252
|
value={price}
|
|
299
253
|
displayType="text"
|
|
300
254
|
thousandSeparator={' '}
|
|
301
|
-
|
|
302
|
-
|
|
255
|
+
prefix={getCurrencyPrefix(catalogItem.master?.currency || '')}
|
|
256
|
+
suffix={getCurrencySuffix(catalogItem.master?.currency || '')}
|
|
257
|
+
/>
|
|
303
258
|
</>
|
|
304
259
|
) : (
|
|
305
260
|
'Зарегистрироваться'
|
|
@@ -8,6 +8,7 @@ import { CatalogItemSale } from '../../../interfaces'
|
|
|
8
8
|
import { CatalogFieldValue } from '../../../modules/gql/generated/types'
|
|
9
9
|
import { SaleProps } from './interfaces'
|
|
10
10
|
import { SaleStyled } from './styles'
|
|
11
|
+
import {getCurrencyPrefix, getCurrencySuffix} from "../../../utils";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Считаем стоимость с учетом скидки
|
|
@@ -291,8 +292,9 @@ const Sale: React.FC<SaleProps> = ({
|
|
|
291
292
|
displayType="text"
|
|
292
293
|
thousandSeparator={' '}
|
|
293
294
|
decimalScale={0}
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
prefix={getCurrencyPrefix(catalogItem.master?.currency || '')}
|
|
296
|
+
suffix={getCurrencySuffix(catalogItem.master?.currency || '')}
|
|
297
|
+
/>
|
|
296
298
|
</Button>
|
|
297
299
|
</a>
|
|
298
300
|
</div>
|
package/src/CourseItem/index.tsx
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react'
|
|
2
|
-
// import ReactDecliner from 'react-decliner'
|
|
3
2
|
import { BoxStyled, NavigationStyled, WidgetStyled } from './styles'
|
|
4
3
|
import Typography from '../components/Typography'
|
|
5
|
-
// import Container from '../components/Container'
|
|
6
4
|
import { CourseItemComponentProps } from './interfaces'
|
|
7
|
-
// import AltItem from './AltItem'
|
|
8
|
-
// import AltItemText from './AltItemText'
|
|
9
5
|
import Materials from './Materials'
|
|
10
6
|
import Sales from './Sales'
|
|
11
7
|
import { OrderButton } from './OrderButton'
|
|
@@ -14,14 +10,9 @@ import {
|
|
|
14
10
|
CourseTariffFlowBehaviour,
|
|
15
11
|
} from '../modules/gql/generated/types'
|
|
16
12
|
import { Reviews } from './Reviews'
|
|
17
|
-
// import { Subscriptions } from './Subscriptions'
|
|
18
|
-
// import { WidgetOrderCourseItem } from '../interfaces'
|
|
19
|
-
// import { FieldValues } from './FieldValues'
|
|
20
13
|
import { FieldValuesProps } from './FieldValues/interfaces'
|
|
21
|
-
// import { PlacesLeft } from './PlacesLeft'
|
|
22
14
|
import { usePrices } from '../hooks/usePrices'
|
|
23
15
|
import { FieldValuesByType } from './FieldValuesByType'
|
|
24
|
-
// import { useCatalogItemSubscription } from '../hooks/useCatalogItemSubscription'
|
|
25
16
|
|
|
26
17
|
const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
27
18
|
const {
|
|
@@ -41,18 +32,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
41
32
|
/**
|
|
42
33
|
* Текущий элемент
|
|
43
34
|
*/
|
|
44
|
-
// const item = useMemo(() => {
|
|
45
|
-
// // return items.find((n) => n.uid === currentItemId)
|
|
46
|
-
// return items.find((_n, index) => index === currentItemId)
|
|
47
|
-
// }, [currentItemId, items])
|
|
48
|
-
|
|
49
|
-
// const {
|
|
50
|
-
// subscription,
|
|
51
|
-
// // onChangeSubscription,
|
|
52
|
-
// } = useCatalogItemSubscription({
|
|
53
|
-
// item,
|
|
54
|
-
// })
|
|
55
|
-
|
|
56
35
|
const [fieldsValueSelected, fieldsValueSelectedSetter] = useState<
|
|
57
36
|
FieldValuesProps['fieldsValueSelected']
|
|
58
37
|
>([])
|
|
@@ -64,12 +43,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
64
43
|
fieldsValueSelected,
|
|
65
44
|
})
|
|
66
45
|
|
|
67
|
-
// useEffect(() => {
|
|
68
|
-
// if (item.fieldValues?.length) {
|
|
69
|
-
// fieldsValueSelectedSetter([item.fieldValues[0]])
|
|
70
|
-
// }
|
|
71
|
-
// }, [item.fieldValues])
|
|
72
|
-
|
|
73
46
|
/**
|
|
74
47
|
* При инициализации надо сразу задать дефолтные выбранные элементы
|
|
75
48
|
*/
|
|
@@ -93,10 +66,8 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
93
66
|
|
|
94
67
|
fieldsValueSelectedSetter(fieldsValueSelected)
|
|
95
68
|
|
|
96
|
-
// console.log('useEffect fieldsValueSelected 2', [...fieldsValueSelected]);
|
|
97
69
|
}, [item.fieldValues])
|
|
98
70
|
|
|
99
|
-
// console.log('fieldsValueSelected', [...fieldsValueSelected]);
|
|
100
71
|
|
|
101
72
|
const fieldValuesByType = useMemo(() => {
|
|
102
73
|
const content: JSX.Element[] = []
|
|
@@ -105,7 +76,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
105
76
|
content.push(
|
|
106
77
|
<FieldValuesByType
|
|
107
78
|
key={type}
|
|
108
|
-
// catalogItem={item}
|
|
109
79
|
fieldsValueSelected={fieldsValueSelected}
|
|
110
80
|
fieldsValueSelectedSetter={fieldsValueSelectedSetter}
|
|
111
81
|
fieldValuesInfo={fieldValuesInfo}
|
|
@@ -122,8 +92,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
122
92
|
return null
|
|
123
93
|
}
|
|
124
94
|
|
|
125
|
-
// const { tariff } = item.course
|
|
126
|
-
|
|
127
95
|
const tariff = course.tariffs?.find((n) => n.uid === item.course?.tariffId)
|
|
128
96
|
|
|
129
97
|
let flowBehaviourTitle: string | undefined
|
|
@@ -142,8 +110,6 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
142
110
|
break
|
|
143
111
|
}
|
|
144
112
|
|
|
145
|
-
// const items: WidgetOrderCourseItem[] = []
|
|
146
|
-
|
|
147
113
|
return (
|
|
148
114
|
<>
|
|
149
115
|
<WidgetStyled>
|
|
@@ -166,96 +132,23 @@ const CourseItem: React.FC<CourseItemComponentProps> = (props) => {
|
|
|
166
132
|
<Materials tariff={tariff} limit={materialsLimit} />
|
|
167
133
|
) : null}
|
|
168
134
|
|
|
169
|
-
{/* <Container className="items">
|
|
170
|
-
{items && items.length > 1 ? (
|
|
171
|
-
items.map(
|
|
172
|
-
(i, index) => (
|
|
173
|
-
<AltItem
|
|
174
|
-
// key={i.uid}
|
|
175
|
-
key={index}
|
|
176
|
-
item={i}
|
|
177
|
-
value={index}
|
|
178
|
-
// checked={i.uid === item.uid}
|
|
179
|
-
checked={index === currentItemId}
|
|
180
|
-
setCurrentItemId={setCurrentItemId}
|
|
181
|
-
/>
|
|
182
|
-
)
|
|
183
|
-
// renderAltItem(i, i.uid === item.uid, () => onItemChange(i))
|
|
184
|
-
)
|
|
185
|
-
) : (
|
|
186
|
-
// renderAltItemText(item)
|
|
187
|
-
<AltItemText item={item} />
|
|
188
|
-
)}
|
|
189
|
-
</Container> */}
|
|
190
|
-
|
|
191
|
-
{/* {typeof item.placesLeft === 'number' ? (
|
|
192
|
-
<Container variant="white" className="placesLeft">
|
|
193
|
-
{item.placesLeft > 0 ? (
|
|
194
|
-
<>
|
|
195
|
-
Осталось {item.placesLeft}{' '}
|
|
196
|
-
<ReactDecliner
|
|
197
|
-
num={item.placesLeft}
|
|
198
|
-
one="место"
|
|
199
|
-
two="места"
|
|
200
|
-
many="мест"
|
|
201
|
-
/>
|
|
202
|
-
!
|
|
203
|
-
</>
|
|
204
|
-
) : (
|
|
205
|
-
'Места закончились'
|
|
206
|
-
)}
|
|
207
|
-
</Container>
|
|
208
|
-
) : null} */}
|
|
209
|
-
|
|
210
135
|
{fieldValuesByType}
|
|
211
136
|
|
|
212
|
-
{/* <FieldValuesByType
|
|
213
|
-
// catalogItem={item}
|
|
214
|
-
fieldsValueSelected={fieldsValueSelected}
|
|
215
|
-
fieldsValueSelectedSetter={fieldsValueSelectedSetter}
|
|
216
|
-
fieldValuesInfo={fieldValuesInfo}
|
|
217
|
-
type={CatalogFieldValueType.COURSE}
|
|
218
|
-
/>
|
|
219
|
-
|
|
220
|
-
<PlacesLeft fieldsValueSelected={fieldsValueSelected} /> */}
|
|
221
|
-
|
|
222
|
-
{/* <Subscriptions
|
|
223
|
-
item={item}
|
|
224
|
-
// onChangeSubscription={onChangeSubscription}
|
|
225
|
-
// subscription={subscription}
|
|
226
|
-
/> */}
|
|
227
|
-
|
|
228
137
|
<div className="flex-1" />
|
|
229
138
|
|
|
230
|
-
{/* {priceDates} */}
|
|
231
|
-
|
|
232
|
-
{/* <FieldValuesByType
|
|
233
|
-
// catalogItem={item}
|
|
234
|
-
fieldsValueSelected={fieldsValueSelected}
|
|
235
|
-
fieldsValueSelectedSetter={fieldsValueSelectedSetter}
|
|
236
|
-
fieldValuesInfo={fieldValuesInfo}
|
|
237
|
-
type={CatalogFieldValueType.SUBSCRIPTION}
|
|
238
|
-
/> */}
|
|
239
|
-
|
|
240
|
-
{/* {typeof item.placesLeft !== 'number' || item.placesLeft > 0 ? ( */}
|
|
241
139
|
<OrderButton
|
|
242
|
-
// item={item}
|
|
243
140
|
catalogItem={item}
|
|
244
141
|
orderLink={orderLink}
|
|
245
142
|
course={course}
|
|
246
143
|
fieldsValueSelected={fieldsValueSelected}
|
|
247
|
-
// subscription={subscription}
|
|
248
144
|
/>
|
|
249
|
-
{/* ) : null} */}
|
|
250
145
|
</BoxStyled>
|
|
251
146
|
</WidgetStyled>
|
|
252
147
|
|
|
253
148
|
<Sales
|
|
254
|
-
// item={item}
|
|
255
149
|
catalogItem={item}
|
|
256
150
|
orderLink={orderLink}
|
|
257
151
|
fieldsValueSelected={fieldsValueSelected}
|
|
258
|
-
// course={course}
|
|
259
152
|
/>
|
|
260
153
|
</>
|
|
261
154
|
)
|
package/src/index.tsx
CHANGED
|
@@ -10,36 +10,24 @@ moment.locale('ru')
|
|
|
10
10
|
export * from './interfaces'
|
|
11
11
|
|
|
12
12
|
const WidgetOrder: React.FC<WidgetOrderProps> = ({
|
|
13
|
-
// items,
|
|
14
13
|
catalogItem,
|
|
15
14
|
orderLink,
|
|
16
15
|
materialsLimit,
|
|
17
|
-
// courses,
|
|
18
16
|
course,
|
|
19
17
|
...other
|
|
20
18
|
}) => {
|
|
21
19
|
return useMemo(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// if (!items.length || !currentItem) {
|
|
25
|
-
// return null;
|
|
26
|
-
// }
|
|
27
|
-
|
|
20
|
+
console.log('%cindex:', 'color: #6F9;', catalogItem)
|
|
28
21
|
return (
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
ratesVisible={other.ratesVisible}
|
|
39
|
-
course={course}
|
|
40
|
-
/>
|
|
41
|
-
</WidgetOrderStyled>
|
|
42
|
-
</>
|
|
22
|
+
<WidgetOrderStyled {...other}>
|
|
23
|
+
<CourseItem
|
|
24
|
+
catalogItem={catalogItem}
|
|
25
|
+
orderLink={orderLink}
|
|
26
|
+
materialsLimit={materialsLimit}
|
|
27
|
+
ratesVisible={other.ratesVisible}
|
|
28
|
+
course={course}
|
|
29
|
+
/>
|
|
30
|
+
</WidgetOrderStyled>
|
|
43
31
|
)
|
|
44
32
|
}, [other, catalogItem, orderLink, materialsLimit, course])
|
|
45
33
|
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -34,12 +34,17 @@ export type CatalogItemSale = {
|
|
|
34
34
|
}[]
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export type CatalogItemMaster = {
|
|
38
|
+
currency: string
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
export type CatalogItem = {
|
|
38
42
|
id: string
|
|
39
43
|
uid: number
|
|
40
44
|
name: string
|
|
41
45
|
sales?: CatalogItemSale[] | null
|
|
42
46
|
course?: CourseItem | null
|
|
47
|
+
master?: Maybe<CatalogItemMaster>
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/**
|
package/src/utils.ts
CHANGED
|
@@ -9,3 +9,25 @@ export const roundStd = (num: number, decimalPlaces: number) => {
|
|
|
9
9
|
|
|
10
10
|
return Math.round(num * p + e) / p
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
export const getCurrencyPrefix = (currency: string) => {
|
|
14
|
+
switch (currency) {
|
|
15
|
+
case 'RUB': return ''
|
|
16
|
+
case 'USD': return '$'
|
|
17
|
+
case 'KZT': return ''
|
|
18
|
+
case 'UAH': return ''
|
|
19
|
+
default: return ''
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const getCurrencySuffix = (currency: string) => {
|
|
24
|
+
switch (currency) {
|
|
25
|
+
case 'RUB': return ' ₽'
|
|
26
|
+
case 'USD': return ''
|
|
27
|
+
case 'KZT': return ' ₸'
|
|
28
|
+
case 'UAH': return ' ₴'
|
|
29
|
+
default:
|
|
30
|
+
console.warn(`Unknown currency ${currency}`)
|
|
31
|
+
return ' ₽'
|
|
32
|
+
}
|
|
33
|
+
}
|