Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions components/forms/CountrySelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ import { Check, ChevronsUpDown } from 'lucide-react';
import { cn } from '@/lib/utils';
import countryList from 'react-select-country-list';

const COUNTRY_LABEL_OVERRIDES: Record<string, string> = {
TW: 'Taiwan',
};

const COUNTRY_OPTIONS = countryList().getData().map((country) => ({
...country,
label: COUNTRY_LABEL_OVERRIDES[country.value] ?? country.label,
}));

type CountrySelectProps = {
name: string;
label: string;
Expand All @@ -39,9 +48,6 @@ const CountrySelect = ({
}) => {
const [open, setOpen] = useState(false);

// Get country options with flags
const countries = countryList().getData();

// Helper function to get flag emoji
const getFlagEmoji = (countryCode: string) => {
const codePoints = countryCode
Expand All @@ -63,7 +69,7 @@ const CountrySelect = ({
{value ? (
<span className='flex items-center gap-2'>
<span>{getFlagEmoji(value)}</span>
<span>{countries.find((c) => c.value === value)?.label}</span>
<span>{COUNTRY_OPTIONS.find((c) => c.value === value)?.label}</span>
</span>
) : (
'Select your country...'
Expand All @@ -85,7 +91,7 @@ const CountrySelect = ({
</CommandEmpty>
<CommandList className='max-h-60 bg-gray-800 scrollbar-hide-default'>
<CommandGroup className='bg-gray-800'>
{countries.map((country) => (
{COUNTRY_OPTIONS.map((country) => (
<CommandItem
key={country.value}
value={`${country.label} ${country.value}`}
Expand Down Expand Up @@ -143,4 +149,4 @@ export const CountrySelectField = ({
</p>
</div>
);
};
};