@eventlook/sdk 1.4.1 → 1.4.3
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/cjs/form/Payment.js +63 -40
- package/dist/cjs/form/Payment.js.map +1 -1
- package/dist/cjs/form/PaymentOverviewBox.js +2 -2
- package/dist/cjs/form/PaymentOverviewBox.js.map +1 -1
- package/dist/cjs/form/TicketForm.js +2 -1
- package/dist/cjs/form/TicketForm.js.map +1 -1
- package/dist/cjs/form/TicketSelection.js.map +1 -1
- package/dist/cjs/hooks/data/useAllowedPaymentMethods.js +1 -1
- package/dist/cjs/hooks/data/useAllowedPaymentMethods.js.map +1 -1
- package/dist/cjs/locales/cs.js +2 -0
- package/dist/cjs/locales/cs.js.map +1 -1
- package/dist/cjs/locales/en.js +2 -0
- package/dist/cjs/locales/en.js.map +1 -1
- package/dist/cjs/locales/es.js +2 -0
- package/dist/cjs/locales/es.js.map +1 -1
- package/dist/cjs/locales/pl.js +2 -0
- package/dist/cjs/locales/pl.js.map +1 -1
- package/dist/cjs/locales/sk.js +2 -0
- package/dist/cjs/locales/sk.js.map +1 -1
- package/dist/cjs/locales/uk.js +2 -0
- package/dist/cjs/locales/uk.js.map +1 -1
- package/dist/cjs/modules/order.js +1 -1
- package/dist/cjs/modules/order.js.map +1 -1
- package/dist/esm/form/Payment.js +65 -42
- package/dist/esm/form/Payment.js.map +1 -1
- package/dist/esm/form/PaymentOverviewBox.js +2 -2
- package/dist/esm/form/PaymentOverviewBox.js.map +1 -1
- package/dist/esm/form/TicketForm.js +2 -1
- package/dist/esm/form/TicketForm.js.map +1 -1
- package/dist/esm/form/TicketSelection.js.map +1 -1
- package/dist/esm/hooks/data/useAllowedPaymentMethods.js +1 -1
- package/dist/esm/hooks/data/useAllowedPaymentMethods.js.map +1 -1
- package/dist/esm/locales/cs.js +2 -0
- package/dist/esm/locales/cs.js.map +1 -1
- package/dist/esm/locales/en.js +2 -0
- package/dist/esm/locales/en.js.map +1 -1
- package/dist/esm/locales/es.js +2 -0
- package/dist/esm/locales/es.js.map +1 -1
- package/dist/esm/locales/pl.js +2 -0
- package/dist/esm/locales/pl.js.map +1 -1
- package/dist/esm/locales/sk.js +2 -0
- package/dist/esm/locales/sk.js.map +1 -1
- package/dist/esm/locales/uk.js +2 -0
- package/dist/esm/locales/uk.js.map +1 -1
- package/dist/esm/modules/order.js +1 -1
- package/dist/esm/modules/order.js.map +1 -1
- package/dist/types/locales/cs.d.ts +2 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/es.d.ts +2 -0
- package/dist/types/locales/pl.d.ts +2 -0
- package/dist/types/locales/sk.d.ts +2 -0
- package/dist/types/locales/uk.d.ts +2 -0
- package/dist/types/utils/types/ticket.type.d.ts +1 -0
- package/package.json +1 -1
- package/src/form/Payment.tsx +106 -79
- package/src/form/PaymentOverviewBox.tsx +2 -1
- package/src/form/TicketForm.tsx +7 -2
- package/src/form/TicketSelection.tsx +1 -2
- package/src/locales/cs.tsx +2 -0
- package/src/locales/en.tsx +2 -0
- package/src/locales/es.tsx +2 -0
- package/src/locales/pl.tsx +2 -0
- package/src/locales/sk.tsx +2 -0
- package/src/locales/uk.tsx +2 -0
- package/src/utils/types/ticket.type.ts +1 -0
package/src/form/Payment.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { KeyboardEvent, useEffect, useState } from 'react';
|
|
1
|
+
import React, { KeyboardEvent, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Button,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
Typography,
|
|
15
15
|
} from '@mui/material';
|
|
16
16
|
import useAllowedPaymentMethods from '@hooks/data/useAllowedPaymentMethods';
|
|
17
|
-
import { Controller, useFormContext } from 'react-hook-form';
|
|
17
|
+
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
|
18
18
|
import { PaymentItem, PaymentWrapper, PaymentSwiftWrapper } from '@form/style';
|
|
19
19
|
import Image from '@components/Image';
|
|
20
20
|
import Label from '@components/Label';
|
|
@@ -22,12 +22,13 @@ import PaymentSkeleton from '@form/payment/PaymentSkeleton';
|
|
|
22
22
|
import { RHFRadioGroup } from '@components/hook-form';
|
|
23
23
|
import { postPromoCodeApply } from '@modules/promo-code';
|
|
24
24
|
import { IEvent } from '@utils/types/event.type';
|
|
25
|
-
import { ITicketForm } from '@utils/types/ticket.type';
|
|
25
|
+
import { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type';
|
|
26
26
|
import useGlobal from '@hooks/useGlobal.ts';
|
|
27
27
|
import { IPromoCode } from '@utils/types/promo-code.type';
|
|
28
28
|
import { PromoCodeTypes } from '@utils/data/promo-code';
|
|
29
29
|
import { throttle } from 'lodash';
|
|
30
30
|
import { Iconify } from '@components';
|
|
31
|
+
import { IEventProductForm } from '@utils/types/product.type';
|
|
31
32
|
|
|
32
33
|
interface Props {
|
|
33
34
|
event: IEvent;
|
|
@@ -36,7 +37,7 @@ interface Props {
|
|
|
36
37
|
const Payment: React.FC<Props> = ({ event }) => {
|
|
37
38
|
const { t, lang } = useGlobal();
|
|
38
39
|
const { showSnackbar } = useGlobal();
|
|
39
|
-
const { data, isLoading } = useAllowedPaymentMethods(event.currency);
|
|
40
|
+
const { data, isLoading } = useAllowedPaymentMethods(event.currency, event.id);
|
|
40
41
|
const { control, watch, setValue } = useFormContext<ITicketForm>();
|
|
41
42
|
const paymentMethodId = watch('paymentMethodId');
|
|
42
43
|
const paymentMethodOptionId = watch('paymentMethodOptionId');
|
|
@@ -154,6 +155,36 @@ const Payment: React.FC<Props> = ({ event }) => {
|
|
|
154
155
|
}
|
|
155
156
|
}, [data, paymentMethodId, paymentMethodOptionId]);
|
|
156
157
|
|
|
158
|
+
const tickets: Record<string, ITicketFormTicket[]> = useWatch({
|
|
159
|
+
name: 'tickets',
|
|
160
|
+
defaultValue: {},
|
|
161
|
+
});
|
|
162
|
+
const products: Record<string, IEventProductForm[]> = useWatch({
|
|
163
|
+
name: 'products',
|
|
164
|
+
defaultValue: {},
|
|
165
|
+
});
|
|
166
|
+
const total: number = useWatch({ name: 'total' });
|
|
167
|
+
|
|
168
|
+
const paymentMethods = useMemo(() => {
|
|
169
|
+
if (!data) return [];
|
|
170
|
+
|
|
171
|
+
const hasTickets =
|
|
172
|
+
Object.values(tickets)
|
|
173
|
+
.flat()
|
|
174
|
+
.filter((t) => t.quantity).length > 0;
|
|
175
|
+
const hasProducts = Object.values(products).flat().length > 0;
|
|
176
|
+
|
|
177
|
+
if (total === 0 && (hasTickets || hasProducts)) {
|
|
178
|
+
setValue('isPaymentVerify', true);
|
|
179
|
+
return data.filter((payment) =>
|
|
180
|
+
['PAYMENT_CARD', 'APPLE_PAY', 'GPAY', 'CLICK_TO_PAY'].includes(payment.type)
|
|
181
|
+
);
|
|
182
|
+
} else {
|
|
183
|
+
setValue('isPaymentVerify', false);
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
}, [data, total, tickets, products]);
|
|
187
|
+
|
|
157
188
|
return (
|
|
158
189
|
<Box>
|
|
159
190
|
<Box className="payment__promo-code">
|
|
@@ -236,81 +267,77 @@ const Payment: React.FC<Props> = ({ event }) => {
|
|
|
236
267
|
render={({ field, fieldState: { error } }) => (
|
|
237
268
|
<FormControl component="fieldset">
|
|
238
269
|
<RadioGroup {...field}>
|
|
239
|
-
{
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
</PaymentSwiftWrapper>
|
|
311
|
-
)}
|
|
312
|
-
</PaymentItem>
|
|
313
|
-
))}
|
|
270
|
+
{paymentMethods.map((payment) => (
|
|
271
|
+
<PaymentItem
|
|
272
|
+
key={payment.type}
|
|
273
|
+
active={!!paymentMethodId && Number(paymentMethodId) === payment.id}
|
|
274
|
+
>
|
|
275
|
+
<FormControlLabel
|
|
276
|
+
value={payment.id}
|
|
277
|
+
control={<Radio />}
|
|
278
|
+
label={
|
|
279
|
+
<Stack direction="row" alignItems="center">
|
|
280
|
+
<Typography
|
|
281
|
+
sx={{
|
|
282
|
+
marginRight: 2,
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{payment.label[lang]}
|
|
286
|
+
</Typography>
|
|
287
|
+
<Image
|
|
288
|
+
src={payment.image.url}
|
|
289
|
+
sx={{
|
|
290
|
+
height: '20px',
|
|
291
|
+
'& .wrapper img': {
|
|
292
|
+
objectFit: 'contain',
|
|
293
|
+
},
|
|
294
|
+
}}
|
|
295
|
+
/>
|
|
296
|
+
</Stack>
|
|
297
|
+
}
|
|
298
|
+
sx={{
|
|
299
|
+
'&:not(:last-of-type)': {
|
|
300
|
+
mb: 0,
|
|
301
|
+
},
|
|
302
|
+
}}
|
|
303
|
+
/>
|
|
304
|
+
{!!payment.options.length &&
|
|
305
|
+
!!paymentMethodId &&
|
|
306
|
+
Number(paymentMethodId) === payment.id && (
|
|
307
|
+
<PaymentSwiftWrapper>
|
|
308
|
+
<Divider sx={{ mb: 2 }} />
|
|
309
|
+
<RHFRadioGroup
|
|
310
|
+
name="paymentMethodOptionId"
|
|
311
|
+
row
|
|
312
|
+
options={payment.options
|
|
313
|
+
.filter((item) => !item.label.en.includes('eshop.api.swifts'))
|
|
314
|
+
.map((option) => ({
|
|
315
|
+
label: (
|
|
316
|
+
<Stack direction="row" alignItems="center">
|
|
317
|
+
<Image
|
|
318
|
+
src={option.image.url}
|
|
319
|
+
sx={{
|
|
320
|
+
width: 'auto',
|
|
321
|
+
height: '15px',
|
|
322
|
+
maxWidth: '70px',
|
|
323
|
+
display: 'inline-block',
|
|
324
|
+
marginRight: 1,
|
|
325
|
+
'& .wrapper img': {
|
|
326
|
+
objectFit: 'contain',
|
|
327
|
+
objectPosition: 'left',
|
|
328
|
+
},
|
|
329
|
+
}}
|
|
330
|
+
/>
|
|
331
|
+
<Typography variant="body2">{option.label[lang]}</Typography>
|
|
332
|
+
</Stack>
|
|
333
|
+
),
|
|
334
|
+
value: option.id,
|
|
335
|
+
}))}
|
|
336
|
+
/>
|
|
337
|
+
</PaymentSwiftWrapper>
|
|
338
|
+
)}
|
|
339
|
+
</PaymentItem>
|
|
340
|
+
))}
|
|
314
341
|
</RadioGroup>
|
|
315
342
|
|
|
316
343
|
{!!error && (
|
|
@@ -56,6 +56,7 @@ const PaymentOverviewBox: React.FC<Props> = ({ event }) => {
|
|
|
56
56
|
promoCodes,
|
|
57
57
|
shipping,
|
|
58
58
|
totalFee,
|
|
59
|
+
isPaymentVerify,
|
|
59
60
|
} = values;
|
|
60
61
|
const tickets: Record<string, ITicketFormTicket[]> = useWatch({
|
|
61
62
|
name: 'tickets',
|
|
@@ -571,7 +572,7 @@ const PaymentOverviewBox: React.FC<Props> = ({ event }) => {
|
|
|
571
572
|
)}
|
|
572
573
|
<FeeBox event={event} />
|
|
573
574
|
<LoadingButton type="submit" variant="contained" size="large" fullWidth>
|
|
574
|
-
{t('buy')}
|
|
575
|
+
{t(isPaymentVerify ? 'verify' : 'buy')}
|
|
575
576
|
</LoadingButton>
|
|
576
577
|
</Stack>
|
|
577
578
|
</OverviewCard>
|
package/src/form/TicketForm.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Stepper,
|
|
14
14
|
Typography,
|
|
15
15
|
} from '@mui/material';
|
|
16
|
-
import dayjs
|
|
16
|
+
import dayjs from 'dayjs';
|
|
17
17
|
import TicketSelection from '@form/TicketSelection';
|
|
18
18
|
import ContactPerson from '@form/ContactPerson';
|
|
19
19
|
import Payment from '@form/Payment';
|
|
@@ -228,6 +228,7 @@ const TicketForm: React.FC<Props> = ({
|
|
|
228
228
|
})) || [],
|
|
229
229
|
selectedDate: null,
|
|
230
230
|
eventTimeslotId: null,
|
|
231
|
+
isPaymentVerify: false,
|
|
231
232
|
};
|
|
232
233
|
}, [user]);
|
|
233
234
|
|
|
@@ -551,7 +552,11 @@ const TicketForm: React.FC<Props> = ({
|
|
|
551
552
|
</Step>
|
|
552
553
|
)}
|
|
553
554
|
<Step active>
|
|
554
|
-
<StepLabel>
|
|
555
|
+
<StepLabel>
|
|
556
|
+
{t(
|
|
557
|
+
`event.tickets.stepper.3.${values.isPaymentVerify ? 'title_verify' : 'title'}`
|
|
558
|
+
)}
|
|
559
|
+
</StepLabel>
|
|
555
560
|
<StepContent>
|
|
556
561
|
<Payment event={event} />
|
|
557
562
|
</StepContent>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
@@ -23,7 +23,6 @@ import useResponsive from '@hooks/useResponsive';
|
|
|
23
23
|
import ReleaseExtraFields from '@form/extra-field/ReleaseExtraFields';
|
|
24
24
|
import { EventType } from '@utils/data/event';
|
|
25
25
|
import useGlobal from '@hooks/useGlobal.ts';
|
|
26
|
-
import { isEqual } from 'lodash';
|
|
27
26
|
|
|
28
27
|
interface Props {
|
|
29
28
|
event: IEvent;
|
package/src/locales/cs.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const cs = {
|
|
|
3
3
|
choose: 'Vyberte',
|
|
4
4
|
apply: 'Použít',
|
|
5
5
|
buy: 'Zakoupit',
|
|
6
|
+
verify: 'Ověřit',
|
|
6
7
|
add: 'Přidat',
|
|
7
8
|
confirm: 'Potvrdit',
|
|
8
9
|
cancel: 'Zrušit',
|
|
@@ -79,6 +80,7 @@ const cs = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Způsoby platby',
|
|
83
|
+
title_verify: 'Způsoby ověření',
|
|
82
84
|
subtitle: 'Platební metody',
|
|
83
85
|
},
|
|
84
86
|
4: {
|
package/src/locales/en.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const en = {
|
|
|
3
3
|
choose: 'Choose',
|
|
4
4
|
apply: 'Apply',
|
|
5
5
|
buy: 'Buy',
|
|
6
|
+
verify: 'Verify',
|
|
6
7
|
add: 'Add',
|
|
7
8
|
confirm: 'Confirm',
|
|
8
9
|
cancel: 'Cancel',
|
|
@@ -79,6 +80,7 @@ const en = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Payment methods',
|
|
83
|
+
title_verify: 'Verification methods',
|
|
82
84
|
subtitle: 'Payment methods',
|
|
83
85
|
},
|
|
84
86
|
4: {
|
package/src/locales/es.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const es = {
|
|
|
3
3
|
choose: 'Elegir',
|
|
4
4
|
apply: 'Aplicar',
|
|
5
5
|
buy: 'Comprar',
|
|
6
|
+
verify: 'Verificar',
|
|
6
7
|
add: 'Añadir',
|
|
7
8
|
confirm: 'Confirmar',
|
|
8
9
|
cancel: 'Cancelar',
|
|
@@ -79,6 +80,7 @@ const es = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Métodos de pago',
|
|
83
|
+
title_verify: 'Métodos de verificación',
|
|
82
84
|
subtitle: 'Métodos de pago',
|
|
83
85
|
},
|
|
84
86
|
4: {
|
package/src/locales/pl.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const pl = {
|
|
|
3
3
|
choose: 'Wybierz',
|
|
4
4
|
apply: 'Zastosuj',
|
|
5
5
|
buy: 'Kup',
|
|
6
|
+
verify: 'Zweryfikuj',
|
|
6
7
|
add: 'Dodaj',
|
|
7
8
|
confirm: 'Potwierdź',
|
|
8
9
|
cancel: 'Anuluj',
|
|
@@ -79,6 +80,7 @@ const pl = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Metody płatności',
|
|
83
|
+
title_verify: 'Metody weryfikacji',
|
|
82
84
|
subtitle: 'Metody płatności',
|
|
83
85
|
},
|
|
84
86
|
4: {
|
package/src/locales/sk.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const sk = {
|
|
|
3
3
|
choose: 'Vybrať',
|
|
4
4
|
apply: 'Použiť',
|
|
5
5
|
buy: 'Kúpiť',
|
|
6
|
+
verify: 'Overiť',
|
|
6
7
|
add: 'Pridať',
|
|
7
8
|
confirm: 'Potvrdiť',
|
|
8
9
|
cancel: 'Zrušiť',
|
|
@@ -79,6 +80,7 @@ const sk = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Spôsoby platby',
|
|
83
|
+
title_verify: 'Spôsoby overenia',
|
|
82
84
|
subtitle: 'Spôsoby platby',
|
|
83
85
|
},
|
|
84
86
|
4: {
|
package/src/locales/uk.tsx
CHANGED
|
@@ -3,6 +3,7 @@ const uk = {
|
|
|
3
3
|
choose: 'Вибрати',
|
|
4
4
|
apply: 'Застосувати',
|
|
5
5
|
buy: 'Купити',
|
|
6
|
+
verify: 'Підтвердити',
|
|
6
7
|
add: 'Додати',
|
|
7
8
|
confirm: 'Підтвердити',
|
|
8
9
|
cancel: 'Скасувати',
|
|
@@ -79,6 +80,7 @@ const uk = {
|
|
|
79
80
|
},
|
|
80
81
|
3: {
|
|
81
82
|
title: 'Способи оплати',
|
|
83
|
+
title_verify: 'Способи підтвердження',
|
|
82
84
|
subtitle: 'Способи оплати',
|
|
83
85
|
},
|
|
84
86
|
4: {
|