tf-checkout-react 1.7.14 → 1.7.16
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/components/addonsContainer/AddonComponent.d.ts +2 -1
- package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +2 -1
- package/dist/components/addonsContainer/index.d.ts +2 -1
- package/dist/tf-checkout-react.cjs.development.js +73 -22
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +74 -23
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/addonsContainer/AddonComponent.tsx +56 -14
- package/src/components/addonsContainer/SimpleAddonsContainer.tsx +4 -0
- package/src/components/addonsContainer/index.tsx +3 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Field } from 'formik'
|
|
2
|
+
import { Field, useFormikContext } from 'formik'
|
|
3
3
|
import _identity from 'lodash/identity'
|
|
4
4
|
import _isEmpty from 'lodash/isEmpty'
|
|
5
5
|
import _isNull from 'lodash/isNull'
|
|
@@ -13,10 +13,6 @@ import {
|
|
|
13
13
|
} from '../billing-info-container/utils'
|
|
14
14
|
import { NativeSelectField } from '../common'
|
|
15
15
|
|
|
16
|
-
// TO DO:
|
|
17
|
-
// - Need to add custom fields validations
|
|
18
|
-
// - Need to apply correct styles
|
|
19
|
-
|
|
20
16
|
interface IAddonComponentProps {
|
|
21
17
|
classNamePrefix: string;
|
|
22
18
|
data: any;
|
|
@@ -26,6 +22,7 @@ interface IAddonComponentProps {
|
|
|
26
22
|
configs: any;
|
|
27
23
|
values: any;
|
|
28
24
|
errors: any;
|
|
25
|
+
useStepperQty?: boolean;
|
|
29
26
|
onCustomFieldChange?: (
|
|
30
27
|
addon: any,
|
|
31
28
|
groupId: string | number,
|
|
@@ -34,6 +31,41 @@ interface IAddonComponentProps {
|
|
|
34
31
|
) => void;
|
|
35
32
|
}
|
|
36
33
|
|
|
34
|
+
const AddonStepper = ({ id, selectOptions, handleAddonChange, classNamePrefix }: any) => {
|
|
35
|
+
const { values, setFieldValue } = useFormikContext<any>()
|
|
36
|
+
const qty = Number(values[id] ?? 0)
|
|
37
|
+
const max = selectOptions?.length > 0 ? selectOptions[selectOptions.length - 1].value : 0
|
|
38
|
+
|
|
39
|
+
const change = (next: number) => {
|
|
40
|
+
setFieldValue(id, next)
|
|
41
|
+
handleAddonChange(id, next)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className={`${classNamePrefix}_stepper`}>
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
className={`${classNamePrefix}_stepper__btn`}
|
|
49
|
+
onClick={() => change(qty - 1)}
|
|
50
|
+
disabled={qty <= 0}
|
|
51
|
+
aria-label="Decrease quantity"
|
|
52
|
+
>
|
|
53
|
+
−
|
|
54
|
+
</button>
|
|
55
|
+
<span className={`${classNamePrefix}_stepper__count`}>{qty}</span>
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
className={`${classNamePrefix}_stepper__btn`}
|
|
59
|
+
onClick={() => change(qty + 1)}
|
|
60
|
+
disabled={qty >= max}
|
|
61
|
+
aria-label="Increase quantity"
|
|
62
|
+
>
|
|
63
|
+
+
|
|
64
|
+
</button>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
37
69
|
const AddonComponent = ({
|
|
38
70
|
classNamePrefix = '',
|
|
39
71
|
data,
|
|
@@ -43,6 +75,7 @@ const AddonComponent = ({
|
|
|
43
75
|
configs,
|
|
44
76
|
values,
|
|
45
77
|
errors,
|
|
78
|
+
useStepperQty = false,
|
|
46
79
|
onCustomFieldChange = _identity,
|
|
47
80
|
}: IAddonComponentProps) => {
|
|
48
81
|
const { id, name, active, stock } = data
|
|
@@ -57,15 +90,24 @@ const AddonComponent = ({
|
|
|
57
90
|
) : (
|
|
58
91
|
<>
|
|
59
92
|
<div className={`${classNamePrefix}_product_qty_select`}>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
93
|
+
{useStepperQty ? (
|
|
94
|
+
<AddonStepper
|
|
95
|
+
id={id}
|
|
96
|
+
selectOptions={selectOptions}
|
|
97
|
+
handleAddonChange={handleAddonChange}
|
|
98
|
+
classNamePrefix={classNamePrefix}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
<Field
|
|
102
|
+
name={id}
|
|
103
|
+
selectOptions={selectOptions}
|
|
104
|
+
component={NativeSelectField}
|
|
105
|
+
onChange={(e: any) => {
|
|
106
|
+
const { value } = e.target
|
|
107
|
+
handleAddonChange(id, value)
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
69
111
|
</div>
|
|
70
112
|
{!_isEmpty(addOnDataWithCustomFields?.fields) && values[id] > 0 && (
|
|
71
113
|
<div className="add-on-fields">
|
|
@@ -30,6 +30,7 @@ export interface ISimpleAddonContainerProps {
|
|
|
30
30
|
addOnDataWithCustomFields: any;
|
|
31
31
|
configs: any;
|
|
32
32
|
eventId: string;
|
|
33
|
+
useStepperQty?: boolean;
|
|
33
34
|
onAddOnSelect?: (id: string, value: string, addon: any, fieldUpdates: any) => void;
|
|
34
35
|
handleConfirm?: (values: any) => void;
|
|
35
36
|
}
|
|
@@ -46,6 +47,7 @@ export const SimpleAddonsContainer = ({
|
|
|
46
47
|
addOnDataWithCustomFields,
|
|
47
48
|
configs,
|
|
48
49
|
eventId,
|
|
50
|
+
useStepperQty = false,
|
|
49
51
|
onAddOnSelect = _identity,
|
|
50
52
|
handleConfirm = _identity,
|
|
51
53
|
}: ISimpleAddonContainerProps) => {
|
|
@@ -373,6 +375,7 @@ export const SimpleAddonsContainer = ({
|
|
|
373
375
|
configs={configs}
|
|
374
376
|
values={values}
|
|
375
377
|
errors={errors}
|
|
378
|
+
useStepperQty={useStepperQty}
|
|
376
379
|
/>
|
|
377
380
|
))
|
|
378
381
|
) : (
|
|
@@ -402,6 +405,7 @@ export const SimpleAddonsContainer = ({
|
|
|
402
405
|
configs={configs}
|
|
403
406
|
values={values}
|
|
404
407
|
errors={errors}
|
|
408
|
+
useStepperQty={useStepperQty}
|
|
405
409
|
/>
|
|
406
410
|
)}
|
|
407
411
|
</div>
|
|
@@ -37,6 +37,7 @@ export interface IAddonContainterProps {
|
|
|
37
37
|
configs: any;
|
|
38
38
|
|
|
39
39
|
onAddOnSelect?: (id: string, value: string, addon: any) => void;
|
|
40
|
+
useStepperQty?: boolean;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
|
|
@@ -57,6 +58,7 @@ export const AddonsContainter = ({
|
|
|
57
58
|
addOnDataWithCustomFields,
|
|
58
59
|
configs,
|
|
59
60
|
onAddOnSelect = _identity,
|
|
61
|
+
useStepperQty = false,
|
|
60
62
|
}: IAddonContainterProps) => {
|
|
61
63
|
const eventId = getQueryVariable('event_id') || null
|
|
62
64
|
|
|
@@ -285,6 +287,7 @@ export const AddonsContainter = ({
|
|
|
285
287
|
configs={configs}
|
|
286
288
|
values={values}
|
|
287
289
|
errors={errors}
|
|
290
|
+
useStepperQty={useStepperQty}
|
|
288
291
|
/>
|
|
289
292
|
))
|
|
290
293
|
) : (
|