diff --git a/src/components/Main/Scenario/ScenarioCardPopulation.tsx b/src/components/Main/Scenario/ScenarioCardPopulation.tsx index be2e3eca5..aa0d50c71 100644 --- a/src/components/Main/Scenario/ScenarioCardPopulation.tsx +++ b/src/components/Main/Scenario/ScenarioCardPopulation.tsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next' import { caseCountsNames } from '../state/caseCountsData' import { ageDistributionNames } from '../state/countryAgeDistributionData' -import { CUSTOM_COUNTRY_NAME } from '../state/state' +import { CUSTOM_COUNTRY_NAME, NONE_COUNTRY_NAME } from '../state/state' import { CardWithoutDropdown } from '../../Form/CardWithoutDropdown' import { FormDatePicker } from '../../Form/FormDatePicker' @@ -19,7 +19,7 @@ const countryOptions = ageDistributionNames.map((country) => ({ value: country, countryOptions.push({ value: CUSTOM_COUNTRY_NAME, label: i18next.t(CUSTOM_COUNTRY_NAME) }) const caseCountOptions = caseCountsNames.map((country) => ({ value: country, label: country })) -caseCountOptions.push({ value: 'none', label: 'None' }) +caseCountOptions.push({ value: NONE_COUNTRY_NAME, label: i18next.t(NONE_COUNTRY_NAME) }) export interface ScenarioCardPopulationProps { errors?: FormikErrors diff --git a/src/components/Main/state/caseCountsData.ts b/src/components/Main/state/caseCountsData.ts index 488e613da..76953a4a3 100644 --- a/src/components/Main/state/caseCountsData.ts +++ b/src/components/Main/state/caseCountsData.ts @@ -1,6 +1,7 @@ import { CaseCounts, Convert } from '../../../.generated/types' import CaseCountsValidate, { errors } from '../../../.generated/CaseCountsValidate' import allCaseCountsRaw from '../../../assets/data/case_counts.json' +import { NONE_COUNTRY_NAME } from './state' function validate(): CaseCounts[] { const valid = CaseCountsValidate(allCaseCountsRaw) @@ -17,6 +18,10 @@ const caseCounts = validate() export const caseCountsNames = caseCounts.map((cc) => cc.country) export function getCaseCountsData(key: string) { + if (key === NONE_COUNTRY_NAME) { + return [] + } + const caseCountFound = caseCounts.find((cc) => cc.country === key) if (!caseCountFound) { throw new Error(`Error: case counts "${key}" not found in JSON`) diff --git a/src/components/Main/state/state.ts b/src/components/Main/state/state.ts index 632f62ec6..71d750532 100644 --- a/src/components/Main/state/state.ts +++ b/src/components/Main/state/state.ts @@ -14,6 +14,7 @@ export interface State { export const DEFAULT_OVERALL_SCENARIO_NAME = 'United States of America' export const CUSTOM_SCENARIO_NAME = i18next.t('Custom') export const CUSTOM_COUNTRY_NAME = 'Custom' +export const NONE_COUNTRY_NAME = 'None' export const defaultScenarioName = DEFAULT_OVERALL_SCENARIO_NAME diff --git a/src/components/Main/validation/schema.ts b/src/components/Main/validation/schema.ts index e30919db6..9028b7175 100644 --- a/src/components/Main/validation/schema.ts +++ b/src/components/Main/validation/schema.ts @@ -4,11 +4,11 @@ import i18next from 'i18next' import { caseCountsNames } from '../state/caseCountsData' import { ageDistributionNames } from '../state/countryAgeDistributionData' -import { CUSTOM_COUNTRY_NAME } from '../state/state' +import { CUSTOM_COUNTRY_NAME, NONE_COUNTRY_NAME } from '../state/state' const ageRegions = [...ageDistributionNames, CUSTOM_COUNTRY_NAME] -const caseRegions = [...caseCountsNames, CUSTOM_COUNTRY_NAME] +const caseRegions = [...caseCountsNames, CUSTOM_COUNTRY_NAME, NONE_COUNTRY_NAME] const MSG_REQUIRED = 'Required' const MSG_NON_NEGATIVE = 'Should be non-negative'