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 { Colors } from '@/lib/colors'; export default function RegisterScreen() { const router = useRouter(); const { register } = useAuthStore(); const [nom, setNom] = useState(''); const [prenom, setPrenom] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [passwordConfirmation, setPasswordConfirmation] = useState(''); const [loading, setLoading] = useState(false); const handleRegister = async () => { if (!nom || !prenom || !email || !password || !passwordConfirmation) { Alert.alert('Erreur', 'Veuillez remplir tous les champs'); return; } if (password !== passwordConfirmation) { Alert.alert('Erreur', 'Les mots de passe ne correspondent pas'); return; } setLoading(true); try { await register({ nom, prenom, email, password, password_confirmation: passwordConfirmation }); router.replace('/(tabs)'); } catch (error: any) { Alert.alert('Erreur', error.response?.data?.message || 'Erreur lors de l\'inscription'); } finally { setLoading(false); } }; return ( CESIZen Creez votre compte Inscription Nom Prenom Email Mot de passe Confirmer le mot de passe {loading ? 'Inscription...' : 'S\'inscrire'} Deja un compte ? Se connecter ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: Colors.white }, scrollContent: { flexGrow: 1, justifyContent: 'center', padding: 24 }, header: { alignItems: 'center', marginBottom: 32 }, 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 }, row: { flexDirection: 'row' }, 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 }, footer: { flexDirection: 'row', justifyContent: 'center', marginTop: 20 }, footerText: { color: Colors.gray[500], fontSize: 14 }, link: { color: Colors.secondary, fontSize: 14, fontWeight: '600' }, });