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