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>
This commit is contained in:
commit
7706937b54
|
|
@ -98,6 +98,10 @@ export const COUNTRY_CODES: CountryCode[] = [
|
||||||
|
|
||||||
export const DEFAULT_COUNTRY = COUNTRY_CODES[0]; // India (+91)
|
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 => {
|
export const getCountryRuleByDialCode = (dialCode: string): CountryCode => {
|
||||||
return (
|
return (
|
||||||
COUNTRY_CODES.find((c) => c.code === dialCode) || {
|
COUNTRY_CODES.find((c) => c.code === dialCode) || {
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
import { AuthColors } from "../constants/colors";
|
import { AuthColors } from "../constants/colors";
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
import {
|
import {
|
||||||
COUNTRY_CODES,
|
|
||||||
CountryCode,
|
CountryCode,
|
||||||
DEFAULT_COUNTRY,
|
DEFAULT_COUNTRY,
|
||||||
|
SORTED_COUNTRY_CODES,
|
||||||
validatePhoneNumber,
|
validatePhoneNumber,
|
||||||
validateEmail,
|
validateEmail,
|
||||||
} from "@/constants/countries";
|
} from "@/constants/countries";
|
||||||
|
|
@ -55,8 +55,8 @@ export default function SignUpForm() {
|
||||||
|
|
||||||
const filteredCountries = useMemo(() => {
|
const filteredCountries = useMemo(() => {
|
||||||
const q = countrySearch.trim().toLowerCase();
|
const q = countrySearch.trim().toLowerCase();
|
||||||
if (!q) return COUNTRY_CODES;
|
if (!q) return SORTED_COUNTRY_CODES;
|
||||||
return COUNTRY_CODES.filter(
|
return SORTED_COUNTRY_CODES.filter(
|
||||||
(c) =>
|
(c) =>
|
||||||
c.country.toLowerCase().includes(q) ||
|
c.country.toLowerCase().includes(q) ||
|
||||||
c.code.includes(q) ||
|
c.code.includes(q) ||
|
||||||
|
|
|
||||||
|
|
@ -35,22 +35,22 @@ interface EditProfileFormProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const COMMON_COUNTRIES = [
|
const COMMON_COUNTRIES = [
|
||||||
"India",
|
|
||||||
"United States",
|
|
||||||
"United Kingdom",
|
|
||||||
"Canada",
|
|
||||||
"Australia",
|
"Australia",
|
||||||
"Germany",
|
"Canada",
|
||||||
"Singapore",
|
|
||||||
"Malaysia",
|
|
||||||
"New Zealand",
|
|
||||||
"United Arab Emirates",
|
|
||||||
"South Africa",
|
|
||||||
"Ireland",
|
|
||||||
"Netherlands",
|
|
||||||
"Switzerland",
|
|
||||||
"France",
|
"France",
|
||||||
|
"Germany",
|
||||||
|
"India",
|
||||||
|
"Ireland",
|
||||||
|
"Malaysia",
|
||||||
|
"Netherlands",
|
||||||
|
"New Zealand",
|
||||||
|
"Singapore",
|
||||||
|
"South Africa",
|
||||||
"Spain",
|
"Spain",
|
||||||
|
"Switzerland",
|
||||||
|
"United Arab Emirates",
|
||||||
|
"United Kingdom",
|
||||||
|
"United States",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const isValidPhoneNumber = (val?: string, country?: string): boolean => {
|
export const isValidPhoneNumber = (val?: string, country?: string): boolean => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue