Compare commits
1 Commits
a2c9d613c6
...
aebcdccc8a
| Author | SHA1 | Date |
|---|---|---|
|
|
aebcdccc8a |
|
|
@ -123,7 +123,9 @@ android {
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
signingConfig (keystorePropertiesFile.exists() ? signingConfigs.release : signingConfigs.debug)
|
// Caution! In production, you need to generate your own keystore file.
|
||||||
|
// see https://reactnative.dev/docs/signed-apk-android.
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
|
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
|
||||||
shrinkResources enableShrinkResources.toBoolean()
|
shrinkResources enableShrinkResources.toBoolean()
|
||||||
minifyEnabled enableMinifyInReleaseBuilds
|
minifyEnabled enableMinifyInReleaseBuilds
|
||||||
|
|
|
||||||
|
|
@ -6,38 +6,26 @@ import android.content.res.Configuration
|
||||||
import com.facebook.react.PackageList
|
import com.facebook.react.PackageList
|
||||||
import com.facebook.react.ReactApplication
|
import com.facebook.react.ReactApplication
|
||||||
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
||||||
import com.facebook.react.ReactNativeHost
|
|
||||||
import com.facebook.react.ReactPackage
|
import com.facebook.react.ReactPackage
|
||||||
import com.facebook.react.ReactHost
|
import com.facebook.react.ReactHost
|
||||||
import com.facebook.react.common.ReleaseLevel
|
import com.facebook.react.common.ReleaseLevel
|
||||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
|
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
|
||||||
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
||||||
|
|
||||||
import expo.modules.ApplicationLifecycleDispatcher
|
import expo.modules.ApplicationLifecycleDispatcher
|
||||||
import expo.modules.ReactNativeHostWrapper
|
import expo.modules.ExpoReactHostFactory
|
||||||
|
|
||||||
class MainApplication : Application(), ReactApplication {
|
class MainApplication : Application(), ReactApplication {
|
||||||
|
|
||||||
override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
|
override val reactHost: ReactHost by lazy {
|
||||||
this,
|
ExpoReactHostFactory.getDefaultReactHost(
|
||||||
object : DefaultReactNativeHost(this) {
|
context = applicationContext,
|
||||||
override fun getPackages(): List<ReactPackage> =
|
packageList =
|
||||||
PackageList(this).packages.apply {
|
PackageList(this).packages.apply {
|
||||||
// Packages that cannot be autolinked yet can be added manually here, for example:
|
// Packages that cannot be autolinked yet can be added manually here, for example:
|
||||||
// add(MyReactNativePackage())
|
// add(MyReactNativePackage())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
|
|
||||||
|
|
||||||
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
||||||
|
|
||||||
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
||||||
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
override val reactHost: ReactHost
|
|
||||||
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,6 @@ export default function ChangePasswordScreen() {
|
||||||
if (!newPassword) {
|
if (!newPassword) {
|
||||||
setNewError("New password is required");
|
setNewError("New password is required");
|
||||||
hasError = true;
|
hasError = true;
|
||||||
} else if (currentPassword && newPassword === currentPassword) {
|
|
||||||
setNewError("New password cannot be the same as current password");
|
|
||||||
hasError = true;
|
|
||||||
} else if (newPassword.length < 8) {
|
} else if (newPassword.length < 8) {
|
||||||
setNewError("New password must be at least 8 characters");
|
setNewError("New password must be at least 8 characters");
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -92,14 +89,7 @@ export default function ChangePasswordScreen() {
|
||||||
const errMsg =
|
const errMsg =
|
||||||
err?.response?.data?.detail ||
|
err?.response?.data?.detail ||
|
||||||
"Failed to update password. Please check your current password.";
|
"Failed to update password. Please check your current password.";
|
||||||
if (
|
|
||||||
typeof errMsg === "string" &&
|
|
||||||
errMsg.toLowerCase().includes("same")
|
|
||||||
) {
|
|
||||||
setNewError(errMsg);
|
|
||||||
} else {
|
|
||||||
setCurrentError(errMsg);
|
setCurrentError(errMsg);
|
||||||
}
|
|
||||||
if (Platform.OS === "web") {
|
if (Platform.OS === "web") {
|
||||||
window.alert(errMsg);
|
window.alert(errMsg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
export interface CountryCode {
|
|
||||||
code: string;
|
|
||||||
label: string;
|
|
||||||
country: string;
|
|
||||||
currency: string;
|
|
||||||
minLength: number;
|
|
||||||
maxLength: number;
|
|
||||||
placeholder: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const COUNTRY_CODES: CountryCode[] = [
|
|
||||||
// South Asia
|
|
||||||
{ code: "+91", label: "🇮🇳 +91", country: "India", currency: "INR", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+92", label: "🇵🇰 +92", country: "Pakistan", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+880", label: "🇧🇩 +880", country: "Bangladesh", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+94", label: "🇱🇰 +94", country: "Sri Lanka", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+977", label: "🇳🇵 +977", country: "Nepal", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+975", label: "🇧🇹 +975", country: "Bhutan", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+960", label: "🇲🇻 +960", country: "Maldives", currency: "USD", minLength: 7, maxLength: 7, placeholder: "7-digit mobile number" },
|
|
||||||
|
|
||||||
// North America
|
|
||||||
{ code: "+1", label: "🇺🇸 +1", country: "United States", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit phone number" },
|
|
||||||
{ code: "+1", label: "🇨🇦 +1", country: "Canada", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit phone number" },
|
|
||||||
{ code: "+52", label: "🇲🇽 +52", country: "Mexico", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
|
|
||||||
// Europe & UK
|
|
||||||
{ code: "+44", label: "🇬🇧 +44", country: "United Kingdom", currency: "USD", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+49", label: "🇩🇪 +49", country: "Germany", currency: "EUR", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+33", label: "🇫🇷 +33", country: "France", currency: "EUR", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+39", label: "🇮🇹 +39", country: "Italy", currency: "EUR", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+34", label: "🇪🇸 +34", country: "Spain", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+31", label: "🇳🇱 +31", country: "Netherlands", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+41", label: "🇨🇭 +41", country: "Switzerland", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+32", label: "🇧🇪 +32", country: "Belgium", currency: "EUR", minLength: 8, maxLength: 9, placeholder: "8 to 9 digits" },
|
|
||||||
{ code: "+43", label: "🇦🇹 +43", country: "Austria", currency: "EUR", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+353", label: "🇮🇪 +353", country: "Ireland", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+46", label: "🇸🇪 +46", country: "Sweden", currency: "EUR", minLength: 7, maxLength: 10, placeholder: "7 to 10 digits" },
|
|
||||||
{ code: "+47", label: "🇳🇴 +47", country: "Norway", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+45", label: "🇩🇰 +45", country: "Denmark", currency: "EUR", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+358", label: "🇫🇮 +358", country: "Finland", currency: "EUR", minLength: 6, maxLength: 10, placeholder: "6 to 10 digits" },
|
|
||||||
{ code: "+351", label: "🇵🇹 +351", country: "Portugal", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+30", label: "🇬🇷 +30", country: "Greece", currency: "EUR", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+48", label: "🇵🇱 +48", country: "Poland", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+420", label: "🇨🇿 +420", country: "Czech Republic", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+36", label: "🇭🇺 +36", country: "Hungary", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+40", label: "🇷🇴 +40", country: "Romania", currency: "EUR", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+380", label: "🇺🇦 +380", country: "Ukraine", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+354", label: "🇮🇸 +354", country: "Iceland", currency: "EUR", minLength: 7, maxLength: 9, placeholder: "7 to 9 digits" },
|
|
||||||
{ code: "+352", label: "🇱🇺 +352", country: "Luxembourg", currency: "EUR", minLength: 8, maxLength: 10, placeholder: "8 to 10 digits" },
|
|
||||||
{ code: "+385", label: "🇭🇷 +385", country: "Croatia", currency: "EUR", minLength: 8, maxLength: 9, placeholder: "8 to 9 digits" },
|
|
||||||
{ code: "+421", label: "🇸🇰 +421", country: "Slovakia", currency: "EUR", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+359", label: "🇧🇬 +359", country: "Bulgaria", currency: "EUR", minLength: 8, maxLength: 9, placeholder: "8 to 9 digits" },
|
|
||||||
{ code: "+7", label: "🇷🇺 +7", country: "Russia", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+90", label: "🇹🇷 +90", country: "Turkey", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
|
|
||||||
// Asia-Pacific
|
|
||||||
{ code: "+61", label: "🇦🇺 +61", country: "Australia", currency: "USD", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+64", label: "🇳🇿 +64", country: "New Zealand", currency: "USD", minLength: 8, maxLength: 10, placeholder: "8 to 10 digits" },
|
|
||||||
{ code: "+81", label: "🇯🇵 +81", country: "Japan", currency: "USD", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+86", label: "🇨🇳 +86", country: "China", currency: "USD", minLength: 11, maxLength: 11, placeholder: "11-digit mobile number" },
|
|
||||||
{ code: "+82", label: "🇰🇷 +82", country: "South Korea", currency: "USD", minLength: 9, maxLength: 11, placeholder: "9 to 11 digits" },
|
|
||||||
{ code: "+852", label: "🇭🇰 +852", country: "Hong Kong", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+886", label: "🇹🇼 +886", country: "Taiwan", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+65", label: "🇸🇬 +65", country: "Singapore", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+60", label: "🇲🇾 +60", country: "Malaysia", currency: "USD", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+62", label: "🇮🇩 +62", country: "Indonesia", currency: "USD", minLength: 9, maxLength: 12, placeholder: "9 to 12 digits" },
|
|
||||||
{ code: "+63", label: "🇵🇭 +63", country: "Philippines", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+66", label: "🇹🇭 +66", country: "Thailand", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+84", label: "🇻🇳 +84", country: "Vietnam", currency: "USD", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
|
|
||||||
// Middle East
|
|
||||||
{ code: "+971", label: "🇦🇪 +971", country: "UAE", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+966", label: "🇸🇦 +966", country: "Saudi Arabia", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+974", label: "🇶🇦 +974", country: "Qatar", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+965", label: "🇰🇼 +965", country: "Kuwait", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+968", label: "🇴🇲 +968", country: "Oman", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+973", label: "🇧🇭 +973", country: "Bahrain", currency: "USD", minLength: 8, maxLength: 8, placeholder: "8-digit mobile number" },
|
|
||||||
{ code: "+972", label: "🇮🇱 +972", country: "Israel", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+962", label: "🇯🇴 +962", country: "Jordan", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+961", label: "🇱🇧 +961", country: "Lebanon", currency: "USD", minLength: 7, maxLength: 8, placeholder: "7 to 8 digits" },
|
|
||||||
|
|
||||||
// Latin America
|
|
||||||
{ code: "+55", label: "🇧🇷 +55", country: "Brazil", currency: "USD", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+54", label: "🇦🇷 +54", country: "Argentina", currency: "USD", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+56", label: "🇨🇱 +56", country: "Chile", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+57", label: "🇨🇴 +57", country: "Colombia", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+51", label: "🇵🇪 +51", country: "Peru", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
|
|
||||||
// Africa
|
|
||||||
{ code: "+27", label: "🇿🇦 +27", country: "South Africa", currency: "USD", minLength: 9, maxLength: 10, placeholder: "9 to 10 digits" },
|
|
||||||
{ code: "+234", label: "🇳🇬 +234", country: "Nigeria", currency: "USD", minLength: 10, maxLength: 11, placeholder: "10 to 11 digits" },
|
|
||||||
{ code: "+254", label: "🇰🇪 +254", country: "Kenya", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+233", label: "🇬🇭 +233", country: "Ghana", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+20", label: "🇪🇬 +20", country: "Egypt", currency: "USD", minLength: 10, maxLength: 10, placeholder: "10-digit mobile number" },
|
|
||||||
{ code: "+212", label: "🇲🇦 +212", country: "Morocco", currency: "USD", minLength: 9, maxLength: 9, placeholder: "9-digit mobile number" },
|
|
||||||
{ code: "+230", label: "🇲🇺 +230", country: "Mauritius", currency: "USD", minLength: 7, maxLength: 8, placeholder: "7 to 8 digits" },
|
|
||||||
];
|
|
||||||
|
|
||||||
export const DEFAULT_COUNTRY = COUNTRY_CODES[0]; // India (+91)
|
|
||||||
|
|
||||||
export const getCountryRuleByDialCode = (dialCode: string): CountryCode => {
|
|
||||||
return (
|
|
||||||
COUNTRY_CODES.find((c) => c.code === dialCode) || {
|
|
||||||
code: dialCode,
|
|
||||||
label: dialCode,
|
|
||||||
country: "Other",
|
|
||||||
currency: "USD",
|
|
||||||
minLength: 6,
|
|
||||||
maxLength: 15,
|
|
||||||
placeholder: "Phone number",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCountryRuleByName = (countryName: string): CountryCode => {
|
|
||||||
if (!countryName) return DEFAULT_COUNTRY;
|
|
||||||
const normalized = countryName.toLowerCase().trim();
|
|
||||||
return (
|
|
||||||
COUNTRY_CODES.find(
|
|
||||||
(c) =>
|
|
||||||
c.country.toLowerCase() === normalized ||
|
|
||||||
normalized.includes(c.country.toLowerCase())
|
|
||||||
) || {
|
|
||||||
code: "+91",
|
|
||||||
label: "🇮🇳 +91",
|
|
||||||
country: countryName,
|
|
||||||
currency: normalized === "india" ? "INR" : "USD",
|
|
||||||
minLength: 6,
|
|
||||||
maxLength: 15,
|
|
||||||
placeholder: "Phone number",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const validatePhoneNumber = (
|
|
||||||
val?: string | null,
|
|
||||||
dialCode?: string,
|
|
||||||
country?: string
|
|
||||||
): string | null => {
|
|
||||||
if (!val || !val.trim()) return null;
|
|
||||||
const trimmed = val.trim();
|
|
||||||
|
|
||||||
if (/[a-zA-Z]/.test(trimmed)) {
|
|
||||||
return "Phone number cannot contain alphabetic characters.";
|
|
||||||
}
|
|
||||||
|
|
||||||
const allDigits = trimmed.replace(/\D/g, "");
|
|
||||||
if (allDigits.length === 0) {
|
|
||||||
return "Please enter a valid phone number with numeric digits.";
|
|
||||||
}
|
|
||||||
|
|
||||||
let rule = dialCode ? getCountryRuleByDialCode(dialCode) : undefined;
|
|
||||||
if ((!rule || rule.country === "Other") && country) {
|
|
||||||
rule = getCountryRuleByName(country);
|
|
||||||
}
|
|
||||||
if (!rule || rule.country === "Other") {
|
|
||||||
if (dialCode === "+91" || (country && country.toLowerCase() === "india")) {
|
|
||||||
rule = getCountryRuleByDialCode("+91");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule && rule.country !== "Other") {
|
|
||||||
if (rule.minLength === rule.maxLength) {
|
|
||||||
if (allDigits.length !== rule.minLength) {
|
|
||||||
return `${rule.country} phone number must be exactly ${rule.minLength} digits.`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (allDigits.length < rule.minLength) {
|
|
||||||
return `${rule.country} phone number must be at least ${rule.minLength} digits.`;
|
|
||||||
}
|
|
||||||
if (allDigits.length > rule.maxLength) {
|
|
||||||
return `${rule.country} phone number cannot exceed ${rule.maxLength} digits.`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allDigits.length < 6) {
|
|
||||||
return "Phone number must contain at least 6 digits.";
|
|
||||||
}
|
|
||||||
if (allDigits.length > 15) {
|
|
||||||
return "Phone number cannot exceed 15 digits.";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
@ -1,34 +1,12 @@
|
||||||
import React, { useState, useMemo } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import { Alert, StyleSheet, View } from "react-native";
|
||||||
KeyboardAvoidingView,
|
|
||||||
Modal,
|
|
||||||
Platform,
|
|
||||||
Pressable,
|
|
||||||
ScrollView,
|
|
||||||
StyleSheet,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
View,
|
|
||||||
} from "react-native";
|
|
||||||
import { useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { verticalScale } from "react-native-size-matters";
|
||||||
import {
|
|
||||||
moderateScale,
|
|
||||||
scale,
|
|
||||||
verticalScale,
|
|
||||||
} from "react-native-size-matters";
|
|
||||||
|
|
||||||
import BaseTextInput from "@/components/forms/BaseTextInput";
|
import BaseTextInput from "@/components/forms/BaseTextInput";
|
||||||
import PasswordInput from "@/components/forms/PasswordInput";
|
import PasswordInput from "@/components/forms/PasswordInput";
|
||||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
import { AuthColors } from "../constants/colors";
|
|
||||||
import { Colors } from "@/theme";
|
|
||||||
import {
|
|
||||||
COUNTRY_CODES,
|
|
||||||
CountryCode,
|
|
||||||
DEFAULT_COUNTRY,
|
|
||||||
validatePhoneNumber,
|
|
||||||
} from "@/constants/countries";
|
|
||||||
import { useAuthStore } from "@/store/auth.store";
|
import { useAuthStore } from "@/store/auth.store";
|
||||||
import { register } from "@/features/auth/api/auth.api";
|
import { register } from "@/features/auth/api/auth.api";
|
||||||
|
|
||||||
|
|
@ -38,13 +16,9 @@ export default function SignUpForm() {
|
||||||
|
|
||||||
const [fullName, setFullName] = useState("");
|
const [fullName, setFullName] = useState("");
|
||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [selectedCountry, setSelectedCountry] = useState<CountryCode>(DEFAULT_COUNTRY);
|
|
||||||
const [phone, setPhone] = useState("");
|
const [phone, setPhone] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [confirmPassword, setConfirmPassword] = useState("");
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||||||
const [showCountryModal, setShowCountryModal] = useState(false);
|
|
||||||
const [countrySearch, setCountrySearch] = useState("");
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
|
|
||||||
const [fullNameError, setFullNameError] = useState("");
|
const [fullNameError, setFullNameError] = useState("");
|
||||||
const [emailError, setEmailError] = useState("");
|
const [emailError, setEmailError] = useState("");
|
||||||
|
|
@ -52,33 +26,12 @@ export default function SignUpForm() {
|
||||||
const [passwordError, setPasswordError] = useState("");
|
const [passwordError, setPasswordError] = useState("");
|
||||||
const [confirmPasswordError, setConfirmPasswordError] = useState("");
|
const [confirmPasswordError, setConfirmPasswordError] = useState("");
|
||||||
|
|
||||||
const filteredCountries = useMemo(() => {
|
|
||||||
const q = countrySearch.trim().toLowerCase();
|
|
||||||
if (!q) return COUNTRY_CODES;
|
|
||||||
return COUNTRY_CODES.filter(
|
|
||||||
(c) =>
|
|
||||||
c.country.toLowerCase().includes(q) ||
|
|
||||||
c.code.includes(q) ||
|
|
||||||
c.label.toLowerCase().includes(q)
|
|
||||||
);
|
|
||||||
}, [countrySearch]);
|
|
||||||
|
|
||||||
const handlePhoneChange = (text: string) => {
|
const handlePhoneChange = (text: string) => {
|
||||||
const digits = text.replace(/\D/g, "");
|
const digits = text.replace(/\D/g, "");
|
||||||
setPhone(digits.slice(0, 15));
|
setPhone(digits.slice(0, 15));
|
||||||
if (phoneError) setPhoneError("");
|
if (phoneError) setPhoneError("");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCountrySelect = (c: CountryCode) => {
|
|
||||||
setSelectedCountry(c);
|
|
||||||
setShowCountryModal(false);
|
|
||||||
setCountrySearch("");
|
|
||||||
if (phone.length > 15) {
|
|
||||||
setPhone(phone.slice(0, 15));
|
|
||||||
}
|
|
||||||
if (phoneError) setPhoneError("");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSignUp = async () => {
|
const handleSignUp = async () => {
|
||||||
let hasError = false;
|
let hasError = false;
|
||||||
setFullNameError("");
|
setFullNameError("");
|
||||||
|
|
@ -138,28 +91,20 @@ export default function SignUpForm() {
|
||||||
|
|
||||||
if (hasError) return;
|
if (hasError) return;
|
||||||
|
|
||||||
setIsLoading(true);
|
|
||||||
try {
|
try {
|
||||||
const formattedPhone = phone.trim()
|
|
||||||
? `${selectedCountry.code}${phone.trim()}`
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const response = await register({
|
const response = await register({
|
||||||
email: email.trim().toLowerCase(),
|
email: email.trim().toLowerCase(),
|
||||||
password,
|
password,
|
||||||
full_name: fullName.trim(),
|
full_name: fullName.trim(),
|
||||||
phone_number: formattedPhone,
|
phone_number: phone.trim() ? phone.trim() : undefined,
|
||||||
country: selectedCountry.country,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { user } = response;
|
const { user } = response;
|
||||||
|
|
||||||
setRegisteredUser({
|
setRegisteredUser({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.display_name ?? fullName.trim(),
|
name: user.display_name,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
phone_number: user.phone_number ?? formattedPhone,
|
|
||||||
country: user.country ?? selectedCountry.country,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Redirect directly to login screen without alert block
|
// Redirect directly to login screen without alert block
|
||||||
|
|
@ -173,8 +118,6 @@ export default function SignUpForm() {
|
||||||
errMsg = detail[0].msg || JSON.stringify(detail[0]);
|
errMsg = detail[0].msg || JSON.stringify(detail[0]);
|
||||||
}
|
}
|
||||||
alert("Registration Failed: " + errMsg);
|
alert("Registration Failed: " + errMsg);
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -202,43 +145,18 @@ export default function SignUpForm() {
|
||||||
error={emailError}
|
error={emailError}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Phone Number Field with Country Dial Code */}
|
<BaseTextInput
|
||||||
<View style={styles.phoneFieldWrapper}>
|
|
||||||
<View style={[styles.phoneContainer, phoneError ? styles.errorBorder : null]}>
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel="Select Country and Dial Code"
|
|
||||||
onPress={() => setShowCountryModal(true)}
|
|
||||||
style={styles.dialCodeButton}
|
|
||||||
>
|
|
||||||
<Text style={styles.dialCodeText}>{selectedCountry.label}</Text>
|
|
||||||
<Ionicons
|
|
||||||
name="chevron-down"
|
|
||||||
size={moderateScale(14)}
|
|
||||||
color={AuthColors.textSecondary}
|
|
||||||
style={{ marginLeft: scale(5) }}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
|
|
||||||
<View style={styles.phoneDivider} />
|
|
||||||
|
|
||||||
<TextInput
|
|
||||||
value={phone}
|
value={phone}
|
||||||
onChangeText={handlePhoneChange}
|
onChangeText={handlePhoneChange}
|
||||||
placeholder={selectedCountry.placeholder || "Phone Number (Optional)"}
|
placeholder="Phone Number (Optional)"
|
||||||
placeholderTextColor={AuthColors.textSecondary}
|
|
||||||
keyboardType="number-pad"
|
keyboardType="number-pad"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
textContentType="telephoneNumber"
|
textContentType="telephoneNumber"
|
||||||
maxLength={15}
|
maxLength={15}
|
||||||
style={styles.phoneInput}
|
leftIcon="call-outline"
|
||||||
|
error={phoneError}
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
{phoneError ? (
|
|
||||||
<Text style={styles.errorText}>{phoneError}</Text>
|
|
||||||
) : null}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
value={password}
|
value={password}
|
||||||
|
|
@ -257,128 +175,9 @@ export default function SignUpForm() {
|
||||||
<View style={styles.buttonSpacing}>
|
<View style={styles.buttonSpacing}>
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
title="Sign Up"
|
title="Sign Up"
|
||||||
loading={isLoading}
|
|
||||||
onPress={handleSignUp}
|
onPress={handleSignUp}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Country Selection Modal */}
|
|
||||||
<Modal
|
|
||||||
visible={showCountryModal}
|
|
||||||
transparent
|
|
||||||
animationType="slide"
|
|
||||||
onRequestClose={() => {
|
|
||||||
setShowCountryModal(false);
|
|
||||||
setCountrySearch("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<KeyboardAvoidingView
|
|
||||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
||||||
style={styles.modalOverlay}
|
|
||||||
>
|
|
||||||
<Pressable
|
|
||||||
style={StyleSheet.absoluteFill}
|
|
||||||
onPress={() => {
|
|
||||||
setShowCountryModal(false);
|
|
||||||
setCountrySearch("");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<View style={styles.modalSheet}>
|
|
||||||
<View style={styles.modalHeader}>
|
|
||||||
<Text style={styles.modalTitle}>Select Country</Text>
|
|
||||||
<Pressable
|
|
||||||
hitSlop={8}
|
|
||||||
onPress={() => {
|
|
||||||
setShowCountryModal(false);
|
|
||||||
setCountrySearch("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="close"
|
|
||||||
size={moderateScale(22)}
|
|
||||||
color={AuthColors.textSecondary}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* Country Search Bar */}
|
|
||||||
<View style={styles.modalSearchContainer}>
|
|
||||||
<Ionicons
|
|
||||||
name="search-outline"
|
|
||||||
size={moderateScale(17)}
|
|
||||||
color={AuthColors.textSecondary}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
value={countrySearch}
|
|
||||||
onChangeText={setCountrySearch}
|
|
||||||
placeholder="Search country or code..."
|
|
||||||
placeholderTextColor={AuthColors.textSecondary}
|
|
||||||
style={styles.modalSearchInput}
|
|
||||||
autoCapitalize="none"
|
|
||||||
autoCorrect={false}
|
|
||||||
/>
|
|
||||||
{countrySearch.length > 0 && (
|
|
||||||
<Pressable
|
|
||||||
hitSlop={8}
|
|
||||||
onPress={() => setCountrySearch("")}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="close-circle"
|
|
||||||
size={moderateScale(17)}
|
|
||||||
color={AuthColors.textSecondary}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
showsVerticalScrollIndicator={false}
|
|
||||||
contentContainerStyle={styles.countryList}
|
|
||||||
keyboardShouldPersistTaps="handled"
|
|
||||||
>
|
|
||||||
{filteredCountries.length === 0 ? (
|
|
||||||
<View style={styles.emptyContainer}>
|
|
||||||
<Text style={styles.emptyText}>No countries found</Text>
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
filteredCountries.map((c) => {
|
|
||||||
const isSelected = selectedCountry.country === c.country;
|
|
||||||
return (
|
|
||||||
<Pressable
|
|
||||||
key={c.code + c.country}
|
|
||||||
style={({ pressed }) => [
|
|
||||||
styles.countryItem,
|
|
||||||
isSelected && styles.countryItemSelected,
|
|
||||||
pressed && styles.countryItemPressed,
|
|
||||||
]}
|
|
||||||
onPress={() => handleCountrySelect(c)}
|
|
||||||
>
|
|
||||||
<View style={styles.countryRow}>
|
|
||||||
<Text style={styles.countryLabel}>{c.label}</Text>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
styles.countryName,
|
|
||||||
isSelected && styles.countryNameSelected,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{c.country}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
{isSelected && (
|
|
||||||
<Ionicons
|
|
||||||
name="checkmark"
|
|
||||||
size={moderateScale(18)}
|
|
||||||
color={Colors.primary}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Pressable>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</ScrollView>
|
|
||||||
</View>
|
|
||||||
</KeyboardAvoidingView>
|
|
||||||
</Modal>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -390,148 +189,4 @@ const styles = StyleSheet.create({
|
||||||
buttonSpacing: {
|
buttonSpacing: {
|
||||||
marginTop: verticalScale(10),
|
marginTop: verticalScale(10),
|
||||||
},
|
},
|
||||||
|
|
||||||
phoneFieldWrapper: {
|
|
||||||
marginBottom: verticalScale(18),
|
|
||||||
},
|
|
||||||
phoneContainer: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
backgroundColor: AuthColors.inputBackground,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: AuthColors.border,
|
|
||||||
borderRadius: moderateScale(16),
|
|
||||||
paddingHorizontal: scale(12),
|
|
||||||
height: verticalScale(56),
|
|
||||||
},
|
|
||||||
dialCodeButton: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
paddingVertical: verticalScale(8),
|
|
||||||
paddingHorizontal: scale(4),
|
|
||||||
},
|
|
||||||
dialCodeText: {
|
|
||||||
fontSize: moderateScale(14),
|
|
||||||
fontWeight: "700",
|
|
||||||
color: AuthColors.textPrimary,
|
|
||||||
},
|
|
||||||
phoneDivider: {
|
|
||||||
width: 1,
|
|
||||||
height: verticalScale(28),
|
|
||||||
backgroundColor: AuthColors.border,
|
|
||||||
marginHorizontal: scale(10),
|
|
||||||
},
|
|
||||||
phoneInput: {
|
|
||||||
flex: 1,
|
|
||||||
fontSize: moderateScale(15),
|
|
||||||
color: AuthColors.textPrimary,
|
|
||||||
paddingVertical: 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
errorBorder: {
|
|
||||||
borderColor: AuthColors.danger,
|
|
||||||
},
|
|
||||||
errorText: {
|
|
||||||
color: AuthColors.danger,
|
|
||||||
fontSize: moderateScale(12),
|
|
||||||
marginTop: verticalScale(6),
|
|
||||||
marginLeft: scale(6),
|
|
||||||
},
|
|
||||||
|
|
||||||
modalOverlay: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: "rgba(0, 0, 0, 0.45)",
|
|
||||||
justifyContent: "flex-end",
|
|
||||||
},
|
|
||||||
modalSheet: {
|
|
||||||
backgroundColor: "#FFFFFF",
|
|
||||||
borderTopLeftRadius: moderateScale(20),
|
|
||||||
borderTopRightRadius: moderateScale(20),
|
|
||||||
maxHeight: "75%",
|
|
||||||
paddingTop: verticalScale(16),
|
|
||||||
paddingBottom: verticalScale(32),
|
|
||||||
},
|
|
||||||
modalHeader: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
paddingHorizontal: scale(20),
|
|
||||||
paddingBottom: verticalScale(12),
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: "#F1F5F9",
|
|
||||||
},
|
|
||||||
modalTitle: {
|
|
||||||
fontSize: moderateScale(17),
|
|
||||||
fontWeight: "700",
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
},
|
|
||||||
countryList: {
|
|
||||||
paddingHorizontal: scale(16),
|
|
||||||
paddingTop: verticalScale(8),
|
|
||||||
},
|
|
||||||
countryItem: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
paddingVertical: verticalScale(12),
|
|
||||||
paddingHorizontal: scale(12),
|
|
||||||
borderRadius: moderateScale(10),
|
|
||||||
},
|
|
||||||
countryItemSelected: {
|
|
||||||
backgroundColor: "#DCFCE7",
|
|
||||||
},
|
|
||||||
countryItemPressed: {
|
|
||||||
backgroundColor: "#F1F5F9",
|
|
||||||
},
|
|
||||||
countryRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: scale(10),
|
|
||||||
},
|
|
||||||
countryLabel: {
|
|
||||||
fontSize: moderateScale(15),
|
|
||||||
fontWeight: "600",
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
minWidth: scale(65),
|
|
||||||
},
|
|
||||||
countryName: {
|
|
||||||
fontSize: moderateScale(14),
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
fontWeight: "500",
|
|
||||||
},
|
|
||||||
countryNameSelected: {
|
|
||||||
fontWeight: "700",
|
|
||||||
color: "#15803D",
|
|
||||||
},
|
|
||||||
modalSearchContainer: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
backgroundColor: "#F8FAFC",
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: "#E2E8F0",
|
|
||||||
borderRadius: moderateScale(12),
|
|
||||||
marginHorizontal: scale(16),
|
|
||||||
marginTop: verticalScale(12),
|
|
||||||
marginBottom: verticalScale(4),
|
|
||||||
paddingHorizontal: scale(12),
|
|
||||||
height: verticalScale(42),
|
|
||||||
gap: scale(8),
|
|
||||||
},
|
|
||||||
modalSearchInput: {
|
|
||||||
flex: 1,
|
|
||||||
fontSize: moderateScale(14),
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
paddingVertical: 0,
|
|
||||||
},
|
|
||||||
emptyContainer: {
|
|
||||||
paddingVertical: verticalScale(32),
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
},
|
|
||||||
emptyText: {
|
|
||||||
fontSize: moderateScale(14),
|
|
||||||
color: AuthColors.textSecondary,
|
|
||||||
fontWeight: "500",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ const RESERVED_KEYS = new Set([
|
||||||
"title",
|
"title",
|
||||||
"sub_title",
|
"sub_title",
|
||||||
"subtitle",
|
"subtitle",
|
||||||
"alt_name",
|
|
||||||
"alternative_names",
|
|
||||||
"code",
|
"code",
|
||||||
"sort_order",
|
"sort_order",
|
||||||
"link",
|
"link",
|
||||||
|
|
@ -63,9 +61,7 @@ export function ExtraOrdinaryVesselsDetailRenderer({
|
||||||
const subtitle =
|
const subtitle =
|
||||||
asString(data.sub_title) ||
|
asString(data.sub_title) ||
|
||||||
asString(data.subtitle) ||
|
asString(data.subtitle) ||
|
||||||
(asStringArray(data.alt_name).length > 0
|
undefined;
|
||||||
? asStringArray(data.alt_name).join(", ")
|
|
||||||
: undefined);
|
|
||||||
|
|
||||||
const mediaValue = data.images ?? data.media ?? data.point_images;
|
const mediaValue = data.images ?? data.media ?? data.point_images;
|
||||||
const media = Array.isArray(mediaValue)
|
const media = Array.isArray(mediaValue)
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ export default function LoginScreen() {
|
||||||
<ScrollView
|
<ScrollView
|
||||||
contentContainerStyle={styles.contentContainer}
|
contentContainerStyle={styles.contentContainer}
|
||||||
keyboardShouldPersistTaps="handled"
|
keyboardShouldPersistTaps="handled"
|
||||||
keyboardDismissMode="on-drag"
|
|
||||||
automaticallyAdjustKeyboardInsets={true}
|
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
>
|
>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ export default function SignUpScreen() {
|
||||||
<ScrollView
|
<ScrollView
|
||||||
contentContainerStyle={styles.contentContainer}
|
contentContainerStyle={styles.contentContainer}
|
||||||
keyboardShouldPersistTaps="handled"
|
keyboardShouldPersistTaps="handled"
|
||||||
keyboardDismissMode="on-drag"
|
|
||||||
automaticallyAdjustKeyboardInsets={true}
|
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
>
|
>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
|
@ -62,7 +60,6 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
contentContainer: {
|
contentContainer: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
paddingBottom: verticalScale(32),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue