tf-checkout-react 1.7.18 → 1.7.20
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/tf-checkout-react.cjs.development.js +27 -3
- 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 +27 -3
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/addonsContainer/AddonComponent.tsx +7 -1
- package/src/components/addonsContainer/SimpleAddonsContainer.tsx +1 -0
- package/src/components/addonsContainer/index.tsx +1 -0
- package/src/components/billing-info-container/index.tsx +4 -0
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ interface IAddonComponentProps {
|
|
|
23
23
|
values: any;
|
|
24
24
|
errors: any;
|
|
25
25
|
useStepperQty?: boolean;
|
|
26
|
+
siblingIds?: string[];
|
|
26
27
|
onCustomFieldChange?: (
|
|
27
28
|
addon: any,
|
|
28
29
|
groupId: string | number,
|
|
@@ -31,12 +32,15 @@ interface IAddonComponentProps {
|
|
|
31
32
|
) => void;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
const AddonStepper = ({ id, selectOptions, handleAddonChange, classNamePrefix }: any) => {
|
|
35
|
+
const AddonStepper = ({ id, selectOptions, handleAddonChange, classNamePrefix, siblingIds = [] }: any) => {
|
|
35
36
|
const { values, setFieldValue } = useFormikContext<any>()
|
|
36
37
|
const qty = Number(values[id] ?? 0)
|
|
37
38
|
const max = selectOptions?.length > 0 ? selectOptions[selectOptions.length - 1].value : 0
|
|
38
39
|
|
|
39
40
|
const change = (next: number) => {
|
|
41
|
+
if (next > 0) {
|
|
42
|
+
siblingIds.forEach((siblingId: string) => setFieldValue(siblingId, 0))
|
|
43
|
+
}
|
|
40
44
|
setFieldValue(id, next)
|
|
41
45
|
handleAddonChange(id, next)
|
|
42
46
|
}
|
|
@@ -76,6 +80,7 @@ const AddonComponent = ({
|
|
|
76
80
|
values,
|
|
77
81
|
errors,
|
|
78
82
|
useStepperQty = false,
|
|
83
|
+
siblingIds = [],
|
|
79
84
|
onCustomFieldChange = _identity,
|
|
80
85
|
}: IAddonComponentProps) => {
|
|
81
86
|
const { id, name, active, stock } = data
|
|
@@ -101,6 +106,7 @@ const AddonComponent = ({
|
|
|
101
106
|
selectOptions={selectOptions}
|
|
102
107
|
handleAddonChange={handleAddonChange}
|
|
103
108
|
classNamePrefix={classNamePrefix}
|
|
109
|
+
siblingIds={siblingIds}
|
|
104
110
|
/>
|
|
105
111
|
</div>
|
|
106
112
|
) : (
|
|
@@ -361,6 +361,7 @@ export const SimpleAddonsContainer = ({
|
|
|
361
361
|
data={variant}
|
|
362
362
|
selectOptions={addonsOptions[variant.id]}
|
|
363
363
|
classNamePrefix={classNamePrefix}
|
|
364
|
+
siblingIds={addon.variants.filter((v: any) => v.id !== variant.id).map((v: any) => v.id)}
|
|
364
365
|
handleAddonChange={(id, value) => {
|
|
365
366
|
console.log('handleAddonChange', id, value)
|
|
366
367
|
onFieldChange(id, value, addon)
|
|
@@ -279,6 +279,7 @@ export const AddonsContainter = ({
|
|
|
279
279
|
data={variant}
|
|
280
280
|
selectOptions={addonsOptions[variant.id]}
|
|
281
281
|
classNamePrefix={classNamePrefix}
|
|
282
|
+
siblingIds={addon.variants.map((v: any) => v.id).filter((vid: string) => vid !== variant.id)}
|
|
282
283
|
handleAddonChange={(id, value) => {
|
|
283
284
|
onAddOnSelect(id, value, addon)
|
|
284
285
|
onFieldChange(id, value, addon)
|
|
@@ -906,6 +906,10 @@ const BillingInfoContainer = React.memo(
|
|
|
906
906
|
)
|
|
907
907
|
setCheckoutData(checkoutDataObj)
|
|
908
908
|
setSingleCheckoutAddOns(mergedAddOns)
|
|
909
|
+
const updatedAttributes = _get(checkoutResponse, 'data.attributes', {})
|
|
910
|
+
if (updatedAttributes.additional_payment_information) {
|
|
911
|
+
setCheckoutUpdateData(updatedAttributes)
|
|
912
|
+
}
|
|
909
913
|
}
|
|
910
914
|
} catch (error) {
|
|
911
915
|
const errorMessage = _get(
|