Skip to content
Merged
26 changes: 2 additions & 24 deletions packages/ui/src/FormWidgets/CountryPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React, { useCallback, useMemo } from "react";
import {
getFallbackTranslation,
getFlagClass,
getLabel,
sortByLabel,
} from "../../utils/country-picker";
import { Select, ISelectProperties } from "../Select";

Expand All @@ -14,30 +16,6 @@ import type {
} from "../../types/country-picker";
import type { GroupedOption as OptionGroup, Option } from "../Select";

const getLabel = (
code: string,
locale: string,
locales: Locales | undefined,
fallbackTranslation: Translation,
) => {
return locales?.[locale]?.[code] || fallbackTranslation[code] || code;
};

const sortByLabel = <T,>(
optionA: Option<T> | OptionGroup<T>,
optionB: Option<T> | OptionGroup<T>,
) => {
if (!optionA.label) {
return 1;
}

if (!optionB.label) {
return -1;
}

return optionA.label.localeCompare(optionB.label);
};

const getFavoriteOptions = <T,>(
favorites: string[],
locale: string,
Expand Down
Loading