@procraft/widget-order 2.22.10 → 2.23.1

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/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) => 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,22 @@ 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 'USD': return '$';
18
+ default: return '';
19
+ }
20
+ };
21
+ exports.getCurrencyPrefix = getCurrencyPrefix;
22
+ const getCurrencySuffix = (currency) => {
23
+ switch (currency) {
24
+ case 'RUB': return ' ₽';
25
+ case 'USD': return '';
26
+ case 'KZT': return ' ₸';
27
+ case 'UAH': return ' ₴';
28
+ default:
29
+ return ` ${currency}`;
30
+ }
31
+ };
32
+ exports.getCurrencySuffix = getCurrencySuffix;
15
33
  //# 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;IACn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OAAO,GAAG,CAAA;QACtB,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;KACnB;AACH,CAAC,CAAA;AALY,QAAA,iBAAiB,qBAK7B;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,IAAI,QAAQ,EAAE,CAAA;KACxB;AACH,CAAC,CAAA;AATY,QAAA,iBAAiB,qBAS7B"}
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.22.10",
4
+ "version": "2.23.1",
5
5
  "private": false,
6
6
  "main": "dist",
7
7
  "scripts": {
@@ -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>
@@ -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
- // const currentItem = items.find(n => n.uid === currentItemId);
23
-
24
- // if (!items.length || !currentItem) {
25
- // return null;
26
- // }
27
-
20
+ console.log('%cindex:', 'color: #6F9;', catalogItem)
28
21
  return (
29
- <>
30
- <WidgetOrderStyled {...other}>
31
- <CourseItem
32
- // item={item}
33
- // items={items}
34
- catalogItem={catalogItem}
35
- orderLink={orderLink}
36
- materialsLimit={materialsLimit}
37
- // courses={courses}
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
  }
@@ -39,6 +39,7 @@ export type CourseFragment = {
39
39
  position: number
40
40
  isActive: boolean
41
41
  flowBehaviour: CourseTariffFlowBehaviour
42
+ withClientForm: boolean
42
43
  marketingBenefits: Array<string>
43
44
  // flowDetails: Array<{
44
45
  // __typename?: 'CourseTariffPerFlowDetailsCustom'
@@ -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
  /**
@@ -347,6 +347,12 @@
347
347
  "description": null,
348
348
  "isDeprecated": false,
349
349
  "deprecationReason": null
350
+ },
351
+ {
352
+ "name": "AcceptAgreementByDefault",
353
+ "description": null,
354
+ "isDeprecated": false,
355
+ "deprecationReason": null
350
356
  }
351
357
  ],
352
358
  "possibleTypes": null
@@ -2078,6 +2084,12 @@
2078
2084
  "isDeprecated": false,
2079
2085
  "deprecationReason": null
2080
2086
  },
2087
+ {
2088
+ "name": "Forum",
2089
+ "description": null,
2090
+ "isDeprecated": false,
2091
+ "deprecationReason": null
2092
+ },
2081
2093
  {
2082
2094
  "name": "Workshop",
2083
2095
  "description": null,
@@ -7723,6 +7735,18 @@
7723
7735
  "description": null,
7724
7736
  "fields": null,
7725
7737
  "inputFields": [
7738
+ {
7739
+ "name": "id",
7740
+ "description": null,
7741
+ "type": {
7742
+ "kind": "SCALAR",
7743
+ "name": "String",
7744
+ "ofType": null
7745
+ },
7746
+ "defaultValue": null,
7747
+ "isDeprecated": false,
7748
+ "deprecationReason": null
7749
+ },
7726
7750
  {
7727
7751
  "name": "uri",
7728
7752
  "description": "УРЛ шаблона",
@@ -59,7 +59,8 @@ export enum CardFieldName {
59
59
  MESSENGERFACEBOOK = 'MessengerFacebook',
60
60
  ATTACHMENTS = 'Attachments',
61
61
  EMAIL = 'Email',
62
- MIDDLENAME = 'MiddleName'
62
+ MIDDLENAME = 'MiddleName',
63
+ ACCEPTAGREEMENTBYDEFAULT = 'AcceptAgreementByDefault'
63
64
  }
64
65
 
65
66
  export enum CardFieldState {
@@ -249,6 +250,7 @@ export enum CourseSubKind {
249
250
  ABONNEMENT = 'Abonnement',
250
251
  CLUB = 'Club',
251
252
  SUBSCRIPTION = 'Subscription',
253
+ FORUM = 'Forum',
252
254
  WORKSHOP = 'Workshop',
253
255
  MASTERCLASS = 'MasterClass',
254
256
  WEBINAR = 'Webinar',
@@ -621,6 +623,7 @@ export interface OrderCatalogItemMaster {
621
623
  __typename?: 'OrderCatalogItemMaster';
622
624
  id: Scalars['ID'];
623
625
  uid: Scalars['Int'];
626
+ currency: Scalars['String'];
624
627
  }
625
628
 
626
629
  export interface OrderCatalogItemFragment {
@@ -990,6 +993,7 @@ export interface TemplateWhereInput {
990
993
  }
991
994
 
992
995
  export interface TemplateWhereUniqueInput {
996
+ id?: Maybe<Scalars['String']>;
993
997
  /** УРЛ шаблона */
994
998
  uri?: Maybe<Scalars['String']>;
995
999
  }
package/src/utils.ts CHANGED
@@ -9,3 +9,21 @@ 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 'USD': return '$'
16
+ default: return ''
17
+ }
18
+ }
19
+
20
+ export const getCurrencySuffix = (currency: string) => {
21
+ switch (currency) {
22
+ case 'RUB': return ' ₽'
23
+ case 'USD': return ''
24
+ case 'KZT': return ' ₸'
25
+ case 'UAH': return ' ₴'
26
+ default:
27
+ return ` ${currency}`
28
+ }
29
+ }