@ticketboothapp/booking 1.2.91 → 1.2.92
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/package.json
CHANGED
|
@@ -33,19 +33,28 @@ export function useEditableSummaryLines(
|
|
|
33
33
|
|
|
34
34
|
const editableSummaryLineAmountInputs = useMemo(() => {
|
|
35
35
|
const out: Record<string, string> = {};
|
|
36
|
-
for (
|
|
37
|
-
|
|
36
|
+
for (let i = 0; i < checkoutPriceSummaryLinesForCheckout.length; i += 1) {
|
|
37
|
+
const line = checkoutPriceSummaryLinesForCheckout[i];
|
|
38
|
+
const lineKey = getEditableSummaryLineKey(line, i);
|
|
39
|
+
const state = editableSummaryInputsByKey[lineKey];
|
|
40
|
+
const baselineAmount =
|
|
41
|
+
line.kind === 'ticket' ? String(roundMoney(line.itemTotal)) : String(roundMoney(line.amount));
|
|
42
|
+
out[lineKey] = state?.amountDirty ? state.amountInput : baselineAmount;
|
|
38
43
|
}
|
|
39
44
|
return out;
|
|
40
|
-
}, [editableSummaryInputsByKey]);
|
|
45
|
+
}, [checkoutPriceSummaryLinesForCheckout, editableSummaryInputsByKey]);
|
|
41
46
|
|
|
42
47
|
const editableSummaryLineLabelInputs = useMemo(() => {
|
|
43
48
|
const out: Record<string, string> = {};
|
|
44
|
-
for (
|
|
45
|
-
|
|
49
|
+
for (let i = 0; i < checkoutPriceSummaryLinesForCheckout.length; i += 1) {
|
|
50
|
+
const line = checkoutPriceSummaryLinesForCheckout[i];
|
|
51
|
+
const lineKey = getEditableSummaryLineKey(line, i);
|
|
52
|
+
const state = editableSummaryInputsByKey[lineKey];
|
|
53
|
+
const baselineLabel = line.kind === 'ticket' ? line.category : line.label;
|
|
54
|
+
out[lineKey] = state?.labelDirty ? state.labelInput : baselineLabel;
|
|
46
55
|
}
|
|
47
56
|
return out;
|
|
48
|
-
}, [editableSummaryInputsByKey]);
|
|
57
|
+
}, [checkoutPriceSummaryLinesForCheckout, editableSummaryInputsByKey]);
|
|
49
58
|
|
|
50
59
|
const editableCheckoutPriceSummaryLines = useMemo((): PriceSummaryLine[] => {
|
|
51
60
|
const firstTaxLineIndex = checkoutPriceSummaryLinesForCheckout.findIndex(
|
|
@@ -56,23 +65,23 @@ export function useEditableSummaryLines(
|
|
|
56
65
|
const lineKey = getEditableSummaryLineKey(line, index);
|
|
57
66
|
const lineInputState = editableSummaryInputsByKey[lineKey];
|
|
58
67
|
if (line.kind === 'ticket') {
|
|
59
|
-
const amountInput = lineInputState?.amountInput;
|
|
68
|
+
const amountInput = lineInputState?.amountDirty ? lineInputState.amountInput : undefined;
|
|
60
69
|
const parsedAmount = amountInput == null || amountInput.trim() === '' ? line.itemTotal : Number(amountInput);
|
|
61
70
|
return {
|
|
62
71
|
...line,
|
|
63
72
|
lineKey,
|
|
64
73
|
editable: isBeforeSubtotal,
|
|
65
|
-
category: lineInputState?.labelInput
|
|
74
|
+
category: lineInputState?.labelDirty ? lineInputState.labelInput : line.category,
|
|
66
75
|
itemTotal: Number.isFinite(parsedAmount) ? roundMoney(parsedAmount) : line.itemTotal,
|
|
67
76
|
};
|
|
68
77
|
}
|
|
69
|
-
const amountInput = lineInputState?.amountInput;
|
|
78
|
+
const amountInput = lineInputState?.amountDirty ? lineInputState.amountInput : undefined;
|
|
70
79
|
const parsedAmount = amountInput == null || amountInput.trim() === '' ? line.amount : Number(amountInput);
|
|
71
80
|
return {
|
|
72
81
|
...line,
|
|
73
82
|
lineKey,
|
|
74
83
|
editable: isBeforeSubtotal,
|
|
75
|
-
label: lineInputState?.labelInput
|
|
84
|
+
label: lineInputState?.labelDirty ? lineInputState.labelInput : line.label,
|
|
76
85
|
amount: Number.isFinite(parsedAmount) ? roundMoney(parsedAmount) : line.amount,
|
|
77
86
|
};
|
|
78
87
|
});
|