diff --git a/src/assets/countries.json b/src/assets/countries.json index 4987938ec..91e69b3d6 100644 --- a/src/assets/countries.json +++ b/src/assets/countries.json @@ -1485,7 +1485,7 @@ "id": "en:world", "label": "World", "languageCode": "en", - "countryCode": "world" + "countryCode": "" }, { "id": "en:yemen", diff --git a/src/components/ResponsiveAppBar.jsx b/src/components/ResponsiveAppBar.jsx index d991f7385..07da99c1c 100644 --- a/src/components/ResponsiveAppBar.jsx +++ b/src/components/ResponsiveAppBar.jsx @@ -413,21 +413,22 @@ const ResponsiveAppBar = () => { }} > c.countryCode)); export function CountryProvider({ children }) { - const [country, setCountry] = useLocalStorageState("country", "world"); + const [country, setCountry] = useLocalStorageState("country", ""); const [searchParams, setSearchParams] = useSearchParams(); const searchParamsCountry = searchParams.get("country")?.toLowerCase(); @@ -26,9 +26,16 @@ export function CountryProvider({ children }) { ); const value = React.useMemo(() => { - const lowercasedCountry = ( - ValidCountryCodes.has(searchParamsCountry) ? searchParamsCountry : country - )?.toLocaleLowerCase(); + // Try from: + // - searchParams + // - localStorage + // - empty + + const lowercasedCountry = ValidCountryCodes.has(searchParamsCountry) + ? searchParamsCountry + : ValidCountryCodes.has(country?.toLocaleLowerCase()) + ? country?.toLocaleLowerCase() + : ""; return { country: lowercasedCountry, diff --git a/src/pages/nutrition/NutrimentCell.tsx b/src/pages/nutrition/NutrimentCell.tsx index 696a37261..06b26697b 100644 --- a/src/pages/nutrition/NutrimentCell.tsx +++ b/src/pages/nutrition/NutrimentCell.tsx @@ -74,7 +74,7 @@ export const NutrimentCell = (props: NutrimentCellProps) => { {isValidUnit(unit) ? (