import { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, KeyboardAvoidingView, Platform, ScrollView } from 'react-native'; import { Link, useRouter } from 'expo-router'; import { useAuthStore } from '@/lib/auth-store'; import { getApiError } from '@/lib/api'; import { Colors } from '@/lib/colors'; export default function LoginScreen() { const router = useRouter(); const { login } = useAuthStore(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const handleLogin = async () => { if (!email || !password) { Alert.alert('Erreur', 'Veuillez remplir tous les champs'); return; } setLoading(true); try { await login(email, password); router.replace('/(tabs)'); } catch (error) { Alert.alert('Erreur', getApiError(error).message || 'Identifiants incorrects'); } finally { setLoading(false); } }; return ( CESIZen Votre compagnon de sante mentale Connexion Email Mot de passe {loading ? 'Connexion...' : 'Se connecter'} Mot de passe oubliƩ ? Pas encore de compte ? S'inscrire ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: Colors.white }, scrollContent: { flexGrow: 1, justifyContent: 'center', padding: 24 }, header: { alignItems: 'center', marginBottom: 40 }, logo: { fontSize: 36, fontWeight: '800', color: Colors.black }, subtitle: { fontSize: 16, color: Colors.gray[500], marginTop: 8 }, form: { backgroundColor: Colors.gray[50], borderRadius: 24, padding: 24 }, title: { fontSize: 24, fontWeight: '700', color: Colors.black, marginBottom: 24 }, inputGroup: { marginBottom: 16 }, label: { fontSize: 14, fontWeight: '600', color: Colors.gray[700], marginBottom: 6 }, input: { backgroundColor: Colors.white, borderWidth: 1, borderColor: Colors.gray[300], borderRadius: 12, paddingHorizontal: 16, paddingVertical: 14, fontSize: 16, color: Colors.black, }, button: { backgroundColor: Colors.primary, borderRadius: 12, paddingVertical: 16, alignItems: 'center', marginTop: 8, }, buttonDisabled: { opacity: 0.6 }, buttonText: { fontSize: 16, fontWeight: '700', color: Colors.black }, forgotLink: { alignItems: 'center', marginTop: 12 }, footer: { flexDirection: 'row', justifyContent: 'center', marginTop: 16 }, footerText: { color: Colors.gray[500], fontSize: 14 }, link: { color: Colors.secondary, fontSize: 14, fontWeight: '600' }, });