Compare commits

..

2 Commits

Author SHA1 Message Date
Amit Salunke 7706937b54 Merge pull request 'feat(auth): sort country selection alphabetically in registration and profile (issue #110)' (#118) from issue-110 into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/118
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-11-12 04:34:56 +00:00
ShivaniKhaire 52fc209274 feat(auth): sort country selection alphabetically in registration and profile (issue #110)
- Export SORTED_COUNTRY_CODES sorted by country name in constants/countries.ts
- Use SORTED_COUNTRY_CODES in SignUpForm to sort countries alphabetically in the Select Country modal
- Sort COMMON_COUNTRIES in EditProfileForm alphabetically for consistent UX
2026-11-07 17:18:00 +05:30
3 changed files with 20 additions and 16 deletions

View File

@ -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) || {

View File

@ -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) ||

View File

@ -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 => {