feat(auth): sort country selection alphabetically in registration and profile (issue #110) #118
|
|
@ -98,6 +98,10 @@ export const COUNTRY_CODES: CountryCode[] = [
|
|||
|
||||
export const DEFAULT_COUNTRY = COUNTRY_CODES[0]; // India (+91)
|
||||
|
||||
export const SORTED_COUNTRY_CODES: CountryCode[] = [...COUNTRY_CODES].sort((a, b) =>
|
||||
a.country.localeCompare(b.country)
|
||||
);
|
||||
|
||||
export const getCountryRuleByDialCode = (dialCode: string): CountryCode => {
|
||||
return (
|
||||
COUNTRY_CODES.find((c) => c.code === dialCode) || {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import PrimaryButton from "@/components/buttons/PrimaryButton";
|
|||
import { AuthColors } from "../constants/colors";
|
||||
import { Colors } from "@/theme";
|
||||
import {
|
||||
COUNTRY_CODES,
|
||||
CountryCode,
|
||||
DEFAULT_COUNTRY,
|
||||
SORTED_COUNTRY_CODES,
|
||||
validatePhoneNumber,
|
||||
validateEmail,
|
||||
} from "@/constants/countries";
|
||||
|
|
@ -55,8 +55,8 @@ export default function SignUpForm() {
|
|||
|
||||
const filteredCountries = useMemo(() => {
|
||||
const q = countrySearch.trim().toLowerCase();
|
||||
if (!q) return COUNTRY_CODES;
|
||||
return COUNTRY_CODES.filter(
|
||||
if (!q) return SORTED_COUNTRY_CODES;
|
||||
return SORTED_COUNTRY_CODES.filter(
|
||||
(c) =>
|
||||
c.country.toLowerCase().includes(q) ||
|
||||
c.code.includes(q) ||
|
||||
|
|
|
|||
|
|
@ -35,22 +35,22 @@ interface EditProfileFormProps {
|
|||
}
|
||||
|
||||
const COMMON_COUNTRIES = [
|
||||
"India",
|
||||
"United States",
|
||||
"United Kingdom",
|
||||
"Canada",
|
||||
"Australia",
|
||||
"Germany",
|
||||
"Singapore",
|
||||
"Malaysia",
|
||||
"New Zealand",
|
||||
"United Arab Emirates",
|
||||
"South Africa",
|
||||
"Ireland",
|
||||
"Netherlands",
|
||||
"Switzerland",
|
||||
"Canada",
|
||||
"France",
|
||||
"Germany",
|
||||
"India",
|
||||
"Ireland",
|
||||
"Malaysia",
|
||||
"Netherlands",
|
||||
"New Zealand",
|
||||
"Singapore",
|
||||
"South Africa",
|
||||
"Spain",
|
||||
"Switzerland",
|
||||
"United Arab Emirates",
|
||||
"United Kingdom",
|
||||
"United States",
|
||||
];
|
||||
|
||||
export const isValidPhoneNumber = (val?: string, country?: string): boolean => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue