fix(settings): bank accounts saved blank — flatten payload + harden schema to strictObject
The bank form posted {id, bank:{...}} (nested) but the route/schema read fields
at the top level; lenient z.object silently stripped the wrapper, so every field
saved as null while returning success. Flatten the payload to top level and switch
the create/update schemas to strictObject so a future nesting 400s loudly instead
of saving a blank record. Affects both create and edit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -241,7 +241,7 @@ export default function CompanySettings({
|
||||
});
|
||||
|
||||
const bankMutation = useApiMutation<
|
||||
{ id?: number; bank: BankForm },
|
||||
BankForm & { id?: number },
|
||||
{ message?: string }
|
||||
>({
|
||||
url: (input) =>
|
||||
@@ -432,8 +432,8 @@ export default function CompanySettings({
|
||||
setBankSaving(true);
|
||||
try {
|
||||
const result = await bankMutation.mutateAsync({
|
||||
...bankForm,
|
||||
id: editingBank ?? undefined,
|
||||
bank: bankForm,
|
||||
});
|
||||
alert.success(result?.message || "Uloženo");
|
||||
resetBankForm();
|
||||
|
||||
Reference in New Issue
Block a user