mirror of
https://github.com/pezkuwichain/pezkuwi-mobile-app.git
synced 2026-07-19 21:15:40 +00:00
auto-commit for 9a0daff2-77de-4b48-8115-5afb14f33c7c
This commit is contained in:
@@ -9,10 +9,14 @@ import {
|
|||||||
ScrollView,
|
ScrollView,
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
|
Alert,
|
||||||
|
ActivityIndicator,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
|
import { useAuth } from '../contexts/AuthContext';
|
||||||
|
|
||||||
export default function AuthScreen({ navigation }: any) {
|
export default function AuthScreen({ navigation }: any) {
|
||||||
|
const { signIn, signUp } = useAuth();
|
||||||
const [isSignIn, setIsSignIn] = useState(true);
|
const [isSignIn, setIsSignIn] = useState(true);
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
@@ -20,10 +24,32 @@ export default function AuthScreen({ navigation }: any) {
|
|||||||
const [lastName, setLastName] = useState('');
|
const [lastName, setLastName] = useState('');
|
||||||
const [phone, setPhone] = useState('');
|
const [phone, setPhone] = useState('');
|
||||||
const [referralCode, setReferralCode] = useState('');
|
const [referralCode, setReferralCode] = useState('');
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleAuth = () => {
|
const handleAuth = async () => {
|
||||||
// TODO: Backend integration
|
if (!email || !password) {
|
||||||
navigation.navigate('Home');
|
Alert.alert('Error', 'Please fill in all required fields');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isSignIn && (!firstName || !lastName || !phone)) {
|
||||||
|
Alert.alert('Error', 'Please fill in all required fields');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
if (isSignIn) {
|
||||||
|
await signIn(email, password);
|
||||||
|
} else {
|
||||||
|
await signUp(email, password, firstName, lastName, phone, referralCode);
|
||||||
|
}
|
||||||
|
navigation.navigate('Home');
|
||||||
|
} catch (error: any) {
|
||||||
|
Alert.alert('Error', error.message || 'Authentication failed');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user