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:
BOHA
2026-06-09 19:39:43 +02:00
parent 11b71501ee
commit 753c16423c
3 changed files with 163 additions and 4 deletions

View File

@@ -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();