diff --git a/src/components/auth/AuthModal.tsx b/src/components/auth/AuthModal.tsx index 3ec79c8..38b0528 100644 --- a/src/components/auth/AuthModal.tsx +++ b/src/components/auth/AuthModal.tsx @@ -3,7 +3,8 @@ import { XCircle, Sparkles, AlertCircle, CheckCircle, RefreshCw, Phone, Globe, Eye, EyeOff, LogIn, UserPlus } from 'lucide-react'; -import { COUNTRY_CODES, getCountryRuleByName } from '../../constants/countries'; +import { getCountryRuleByName } from '../../constants/countries'; +import { CountrySelect } from '../common/CountrySelect'; import { PhoneInput } from '../common/PhoneInput'; interface AuthModalProps { @@ -315,32 +316,23 @@ export const AuthModal: React.FC = ({ -
- -
- ▼ -
-
+ setAuthPhone(''); + } + }} + theme="dark" + size="md" + showCurrency={true} + showDialCode={true} + /> )} diff --git a/src/components/auth/ProfileDrawer.tsx b/src/components/auth/ProfileDrawer.tsx index b243f48..9ee04e9 100644 --- a/src/components/auth/ProfileDrawer.tsx +++ b/src/components/auth/ProfileDrawer.tsx @@ -4,9 +4,10 @@ import { Eye, EyeOff, RefreshCw, LogOut, Download } from 'lucide-react'; import type { UserProfile, ModuleItem, Currency } from '../../types'; -import { COUNTRY_CODES, getCountryRuleByName } from '../../constants/countries'; +import { getCountryRuleByName } from '../../constants/countries'; import { cleanPhoneInput, parsePhoneNumber, formatE164Phone, SPECIAL_CHAR_REGEX } from '../../utils/validation'; import { PhoneInput } from '../common/PhoneInput'; +import { CountrySelect } from '../common/CountrySelect'; interface ProfileDrawerProps { isOpen: boolean; @@ -198,17 +199,14 @@ export const ProfileDrawer: React.FC = ({
- + onChange={handleCountrySelectChange} + theme="light" + size="sm" + showDialCode={true} + showCurrency={false} + />
+ + {/* Dropdown Menu */} + {isOpen && ( +
+ {/* Search Box */} +
+
+ + setSearchQuery(e.target.value)} + placeholder="Search country name or code..." + className={`w-full rounded-xl pl-8 pr-8 py-1.5 text-xs font-semibold focus:outline-none transition-colors ${ + isDark + ? 'bg-slate-950 border border-slate-800 text-white placeholder:text-slate-600 focus:border-indigo-500' + : 'bg-white border border-slate-200 text-slate-800 placeholder:text-slate-400 focus:border-indigo-500' + }`} + /> + {searchQuery && ( + + )} +
+
+ + {/* Options List */} +
+ {filteredCountries.length === 0 ? ( +
+ No countries found matching “{searchQuery}” +
+ ) : ( + filteredCountries.map((c) => { + const isSelected = c.country.toLowerCase() === value.toLowerCase(); + return ( + + ); + }) + )} +
+
+ )} + + ); +}; diff --git a/src/constants/countries.ts b/src/constants/countries.ts index 52acd95..40eff4b 100644 --- a/src/constants/countries.ts +++ b/src/constants/countries.ts @@ -98,6 +98,11 @@ export const COUNTRY_CODES: CountryCode[] = [ { code: '+230', label: '🇲🇺 +230', country: 'Mauritius', currency: 'USD', minLength: 7, maxLength: 8, placeholder: '7 to 8 digits' }, ]; +// Alphabetically sorted list of countries (A-Z) +export const SORTED_COUNTRY_CODES: CountryCode[] = [...COUNTRY_CODES].sort((a, b) => + a.country.localeCompare(b.country) +); + export const DEFAULT_COUNTRY = COUNTRY_CODES[0]; // India (+91) export const getCountryRuleByDialCode = (dialCode: string): CountryCode => {