2022-07-13 09:40:02 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { COUNTRY_CODES, CountryCode } from 'soapbox/utils/phone';
|
|
|
|
|
|
|
|
interface ICountryCodeDropdown {
|
2023-02-15 13:26:27 -08:00
|
|
|
countryCode: CountryCode
|
|
|
|
onChange(countryCode: CountryCode): void
|
2022-07-13 09:40:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Dropdown menu to select a country code. */
|
|
|
|
const CountryCodeDropdown: React.FC<ICountryCodeDropdown> = ({ countryCode, onChange }) => {
|
|
|
|
return (
|
2022-07-14 08:55:00 -07:00
|
|
|
<select
|
|
|
|
value={countryCode}
|
2023-02-01 14:13:42 -08:00
|
|
|
className='h-full rounded-md border-transparent bg-transparent py-0 pl-3 pr-7 text-base focus:outline-none focus:ring-primary-500 dark:text-white sm:text-sm'
|
2022-07-14 08:55:00 -07:00
|
|
|
onChange={(event) => onChange(event.target.value as any)}
|
|
|
|
>
|
|
|
|
{COUNTRY_CODES.map((code) => (
|
|
|
|
<option value={code} key={code}>+{code}</option>
|
|
|
|
))}
|
|
|
|
</select>
|
2022-07-13 09:40:02 -07:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CountryCodeDropdown;
|