diff --git a/src/components/form/household.tsx b/src/components/form/household.tsx index 2ba4deec..3bb1a326 100644 --- a/src/components/form/household.tsx +++ b/src/components/form/household.tsx @@ -28,12 +28,8 @@ const HouseholdField = ({ DEFAULT_MULTPLE_OPTION_DELIMITER ); if (hasExistingMultipleValues) { - return [ - true, - changeValue?.split(DEFAULT_MULTPLE_OPTION_DELIMITER).map((value) => { - return options.find((option) => option.value === value); - }) - ]; + // if there are existing multiple values after switching from multiselect to single select, clear the value in the dropdown + return [isMultiselect, []]; } return [ diff --git a/src/components/table/admin.tsx b/src/components/table/admin.tsx index b6e8a8b0..7fcca8d7 100644 --- a/src/components/table/admin.tsx +++ b/src/components/table/admin.tsx @@ -119,7 +119,6 @@ const AdminTable = ({ status={detailsElement.status} nhcount={detailsElement.nhcount} defaultOption={policy?.defaultType} - optionMultiSelect={policy?.isMultiselect} /> ))} diff --git a/src/components/table/privatetable.tsx b/src/components/table/privatetable.tsx index d9982c7f..36ebc7bd 100644 --- a/src/components/table/privatetable.tsx +++ b/src/components/table/privatetable.tsx @@ -49,7 +49,6 @@ const PrivateTerritoryTable = ({ status={element.status} nhcount={element.nhcount} defaultOption={hhpolicy?.defaultType} - optionMultiSelect={hhpolicy?.isMultiselect} /> diff --git a/src/components/table/publictable.tsx b/src/components/table/publictable.tsx index 2040fbb4..edbbffc2 100644 --- a/src/components/table/publictable.tsx +++ b/src/components/table/publictable.tsx @@ -42,7 +42,6 @@ const PublicTerritoryTable = ({ status={element.status} nhcount={element.nhcount} defaultOption={hhPolicy?.defaultType} - optionMultiSelect={hhPolicy?.isMultiselect} /> ))} diff --git a/src/components/table/unit.tsx b/src/components/table/unit.tsx index b7977e4a..69b3f5a4 100644 --- a/src/components/table/unit.tsx +++ b/src/components/table/unit.tsx @@ -1,10 +1,6 @@ import { memo } from "react"; import { Badge } from "react-bootstrap"; -import { - DEFAULT_CONGREGATION_OPTION_IS_MULTIPLE, - DEFAULT_MULTPLE_OPTION_DELIMITER, - STATUS_CODES -} from "../../utils/constants"; +import { STATUS_CODES } from "../../utils/constants"; import { unitProps } from "../../utils/interface"; import NotHomeIcon from "./nothome"; @@ -14,8 +10,6 @@ const UnitStatus = memo((props: unitProps) => { const currentStatus = props.status; const nhcount = props.nhcount; const defaultOption = props.defaultOption || ""; - const isMultiSelect = - props.optionMultiSelect || DEFAULT_CONGREGATION_OPTION_IS_MULTIPLE; let status = ""; if (currentStatus === STATUS_CODES.INVALID) { @@ -29,22 +23,7 @@ const UnitStatus = memo((props: unitProps) => { status = "🚫 "; } - const getHouseholdBadge = ( - householdType: string, - isMultiSelect: boolean, - defaultOption: string - ) => { - if (isMultiSelect) { - const multHouseholdTypes = householdType - .split(DEFAULT_MULTPLE_OPTION_DELIMITER) - .filter((type) => type !== defaultOption) - .join(DEFAULT_MULTPLE_OPTION_DELIMITER); - return ( - - {multHouseholdTypes} - - ); - } + const getHouseholdBadge = (householdType: string, defaultOption: string) => { if (householdType === defaultOption) { return <>; } @@ -62,7 +41,7 @@ const UnitStatus = memo((props: unitProps) => { )} {note && <>🗒️ } - {getHouseholdBadge(householdType, isMultiSelect, defaultOption)} + {getHouseholdBadge(householdType, defaultOption)} ); }); diff --git a/src/utils/constants.tsx b/src/utils/constants.tsx index 8381eab7..77b7de00 100644 --- a/src/utils/constants.tsx +++ b/src/utils/constants.tsx @@ -56,7 +56,7 @@ const FIREBASE_FUNCTION_TIMEOUT = 3000; const DEFAULT_CONGREGATION_MAX_TRIES = 2; const DEFAULT_CONGREGATION_OPTION_IS_MULTIPLE = false; -const DEFAULT_MULTPLE_OPTION_DELIMITER = ","; +const DEFAULT_MULTPLE_OPTION_DELIMITER = ", "; const COUNTABLE_HOUSEHOLD_STATUS = [ STATUS_CODES.DONE, diff --git a/src/utils/interface.tsx b/src/utils/interface.tsx index 015fe11c..0a3b79c4 100644 --- a/src/utils/interface.tsx +++ b/src/utils/interface.tsx @@ -28,7 +28,6 @@ export interface unitProps { status: string; nhcount?: string; defaultOption?: string; - optionMultiSelect?: boolean; } export interface valuesDetails {