diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json index 8789c4f6e..d5da2e4a0 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json @@ -84,6 +84,7 @@ "revertChangesContentQuestion": "Are you sure you want to have these changes revert in this project?", "confirmChangesModalHeading": "Confirm the Changes", "confirmChangesContentQuestion": "Are you sure you want to have these changes in this local unit?", + "newLocalUnitDescription": "New local unit", "latitude": "Latitude", "longitude": "Longitude" } diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx index 4967c1786..d5bd83387 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx @@ -37,6 +37,7 @@ import { _cs, isDefined, isNotDefined, + isObject, } from '@togglecorp/fujs'; import { createSubmitHandler, @@ -646,7 +647,7 @@ function LocalUnitsForm(props: Props) { revertChanges(formValues as LocalUnitsRevertRequestPostBody); setShowRevertChangesModalFalse(); }, - [revertChanges], + [revertChanges, setShowRevertChangesModalFalse], ); const latestChangesFormFields = useMemo(() => { @@ -692,6 +693,8 @@ function LocalUnitsForm(props: Props) { setShowChangesModalTrue(); }, [ + setError, + validate, setShowChangesModalTrue, localUnitDetailsResponse, value, @@ -733,6 +736,15 @@ function LocalUnitsForm(props: Props) { }; }, []); + const isNewLocalUnit = useMemo(() => { + if (isObject(previousData)) { + if (Object.keys(previousData).length <= 0) { + return true; + } + } + return false; + }, [previousData]); + return (