From 401baa1cf4f0074ba8dc670b965ae370940ad671 Mon Sep 17 00:00:00 2001 From: kcaparas1630 Date: Thu, 20 Jun 2024 17:12:35 -0700 Subject: [PATCH] switched button types for add and next --- .../FieldsAndSoil/FieldsAndSoil.tsx | 127 +++++++++--------- .../MainPageHeader/MainPageHeader.styles.ts | 1 + 2 files changed, 63 insertions(+), 65 deletions(-) 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