mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
🐛 fix(subscribe): Handle optional values in price and discount calculations
This commit is contained in:
parent
fa56eb8293
commit
5939763b57
@ -564,7 +564,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
||||
return {
|
||||
...data,
|
||||
price: evaluateWithPrecision(
|
||||
`${unit_price} * ${data.quantity} * ${data.discount} / 100`,
|
||||
`${unit_price || 0} * ${data.quantity || 0} * ${data.discount || 0} / 100`,
|
||||
),
|
||||
};
|
||||
},
|
||||
@ -581,7 +581,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
||||
return {
|
||||
...data,
|
||||
discount: evaluateWithPrecision(
|
||||
`${data.price} / ${data.quantity} / ${unit_price} * 100`,
|
||||
`${data.price || 0} / ${data.quantity || 0} / ${unit_price || 0} * 100`,
|
||||
),
|
||||
};
|
||||
},
|
||||
@ -589,7 +589,6 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
||||
]}
|
||||
value={field.value}
|
||||
onChange={(value) => {
|
||||
console.log(value);
|
||||
form.setValue(field.name, value);
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -36,7 +36,7 @@ export function ObjectInput<T extends Record<string, any>>({
|
||||
let updatedState = { ...internalState, ...value };
|
||||
|
||||
fields.forEach((field) => {
|
||||
if (field.calculateValue) {
|
||||
if (field?.calculateValue) {
|
||||
updatedState = field.calculateValue(updatedState);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user