From 1295725debef132ffea793beab74d2aa348518a6 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 15 Dec 2025 16:20:00 +0330 Subject: [PATCH] fix update product --- src/pages/products/components/Step1Form.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pages/products/components/Step1Form.tsx b/src/pages/products/components/Step1Form.tsx index 875621a..a9b3a25 100644 --- a/src/pages/products/components/Step1Form.tsx +++ b/src/pages/products/components/Step1Form.tsx @@ -1,4 +1,4 @@ -import { type FC, useState, useMemo, useEffect } from 'react'; +import { type FC, useState, useMemo, useEffect, useRef } from 'react'; import Button from '../../../components/Button'; import Input from '../../../components/Input'; import Select from '../../../components/Select'; @@ -48,8 +48,17 @@ const Step1Form: FC = ({ onSubmit, brands, categories, loading, isFake: false }); + const isInitializedRef = useRef(false); + useEffect(() => { - if (initialData) { + if (!initialData || isInitializedRef.current) return; + + const hasRealData = Object.values(initialData).some( + (value) => value !== undefined && value !== '' + ); + + if (hasRealData) { + isInitializedRef.current = true; setFormData(prev => ({ ...prev, ...initialData })); } }, [initialData]);