feat: update mq field handling in AnnuncioEditForm for improved data parsing

This commit is contained in:
Marco Pedone 2025-12-03 14:51:39 +01:00
parent 8ac1c1da3d
commit c459da5d23

View file

@ -161,6 +161,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
const defaultValues: FormValues = { const defaultValues: FormValues = {
...data, ...data,
mq: Number(data.mq) || null,
email: data.email || undefined, email: data.email || undefined,
}; };
@ -1261,6 +1262,8 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
name="mq" name="mq"
render={({ field }) => { render={({ field }) => {
const { value, onChange, ...rest } = field; const { value, onChange, ...rest } = field;
const mqValue =
typeof value === "string" ? parseFloat(value) : value;
return ( return (
<FormItem> <FormItem>
<div className="flex flex-wrap items-center gap-x-2"> <div className="flex flex-wrap items-center gap-x-2">
@ -1273,7 +1276,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => {
decimalScale={2} decimalScale={2}
{...rest} {...rest}
decimalSeparator="," decimalSeparator=","
defaultValue={value || undefined} defaultValue={mqValue || undefined}
fixedDecimalScale fixedDecimalScale
id="mq" id="mq"
min={0} min={0}