Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
98b0d779b3
commit
4032fcf24e
@@ -32,6 +32,7 @@ const schema = z.object({
|
||||
postal_code: z.string().trim().max(20).optional().or(z.literal("")),
|
||||
management_company: z.string().trim().max(200).optional().or(z.literal("")),
|
||||
num_units: z.coerce.number().int().min(0).max(100000).optional().or(z.literal("").transform(() => undefined)),
|
||||
annual_interest_rate: z.coerce.number().min(0).max(100).optional().or(z.literal("").transform(() => undefined)),
|
||||
board_members: z.array(boardMember),
|
||||
notes: z.string().trim().max(5000).optional().or(z.literal("")),
|
||||
});
|
||||
@@ -66,6 +67,7 @@ export function ClientFormDialog({
|
||||
postal_code: "",
|
||||
management_company: "",
|
||||
num_units: undefined as any,
|
||||
annual_interest_rate: undefined as any,
|
||||
board_members: [],
|
||||
notes: "",
|
||||
},
|
||||
@@ -85,6 +87,7 @@ export function ClientFormDialog({
|
||||
postal_code: client?.postal_code ?? "",
|
||||
management_company: client?.management_company ?? "",
|
||||
num_units: client?.num_units ?? (undefined as any),
|
||||
annual_interest_rate: client?.annual_interest_rate ?? (undefined as any),
|
||||
board_members: client?.board_members ?? [],
|
||||
notes: client?.notes ?? "",
|
||||
});
|
||||
@@ -106,6 +109,12 @@ export function ClientFormDialog({
|
||||
const payload: any = {
|
||||
...values,
|
||||
num_units: values.num_units || null,
|
||||
annual_interest_rate:
|
||||
values.annual_interest_rate === undefined ||
|
||||
values.annual_interest_rate === null ||
|
||||
(values.annual_interest_rate as any) === ""
|
||||
? null
|
||||
: values.annual_interest_rate,
|
||||
// strip empty strings to nulls
|
||||
...Object.fromEntries(
|
||||
Object.entries(values).map(([k, v]) => [k, v === "" ? null : v]),
|
||||
|
||||
Reference in New Issue
Block a user