diff --git a/frontend/src/Commons/Forms/InputModules/FieldsAndSoil/FieldsAndSoil.tsx b/frontend/src/Commons/Forms/InputModules/FieldsAndSoil/FieldsAndSoil.tsx index cff0a06c..b0a20fb6 100644 --- a/frontend/src/Commons/Forms/InputModules/FieldsAndSoil/FieldsAndSoil.tsx +++ b/frontend/src/Commons/Forms/InputModules/FieldsAndSoil/FieldsAndSoil.tsx @@ -46,26 +46,26 @@ const FieldsAndSoilComponent: React.FC = ({ farmDetails, updat Comments: Yup.string().max(200), }); const initialFieldValues = initialFarmDetails.Fields[fieldIndex]; - const submitData = () => { - const farmInfo: FarmDetailsInterface = { ...farmDetails }; - updateFarmDetails(farmInfo); - console.log('data submitted'); - setFieldIndex((prevIndex) => prevIndex + 1); - setSubmitted(true); - setFieldAdd(false); + const addFieldData = ( + values: FieldDetailInterface, + ): void => { + setTimeout(() => { + const farmInfo: FarmDetailsInterface = { ...farmDetails }; + farmInfo.Fields.push({ + id: fieldIndex, + FieldName: values.FieldName, + Area: values.Area, + Comments: values.Comments, + }); + setFieldsInfo(farmInfo); + setFieldIndex((prevIndex) => prevIndex + 1); + setSubmitted(true); + setFieldAdd(false); + }, 400); }; - const addFarmInfo = (values: FieldDetailInterface) => { + const submitFarmInfo = () => { const farmInfo: FarmDetailsInterface = { ...farmDetails }; - farmInfo.Fields.push({ - id: fieldIndex, - FieldName: values.FieldName, - Area: values.Area, - Comments: values.Comments, - }); - setFieldsInfo(farmInfo); - setFieldIndex((prevIndex) => prevIndex + 1); - setSubmitted(true); - setFieldAdd(false); + updateFarmDetails(farmInfo); }; const addNewField = () => { @@ -135,11 +135,11 @@ const FieldsAndSoilComponent: React.FC = ({ farmDetails, updat