fix(GRO-628): implement frontend error handling and code quality fixes #313
@@ -211,6 +211,15 @@ function InvoiceDetailModal({
|
|||||||
setSaving(true);
|
setSaving(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
const tipCents = Math.round(parseFloat(tipStr) * 100) || 0;
|
const tipCents = Math.round(parseFloat(tipStr) * 100) || 0;
|
||||||
|
// Real-time validation: prevent submit if tip splits don't sum to 100%
|
||||||
|
if (showSplits && tipCents > 0 && tipSplits.length > 0) {
|
||||||
|
const totalPct = tipSplits.reduce((s, r) => s + r.pct, 0);
|
||||||
|
if (Math.abs(totalPct - 100) >= 0.01) {
|
||||||
|
setError("Tip split percentages must sum to 100%");
|
||||||
|
setSaving(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/invoices/${invoice.id}`, {
|
const res = await fetch(`/api/invoices/${invoice.id}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
|
|||||||
Reference in New Issue
Block a user