import React, { useState } from 'react' import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert } from 'react-native' import { useRouter } from 'expo-router' import axios from 'axios' import { API_BASE_URL, API_ENDPOINTS } from '../config/api' export default function RegisterScreen() { const [formData, setFormData] = useState({ email: '', password: '', firstName: '', lastName: '', phone: '', }) const [loading, setLoading] = useState(false) const router = useRouter() const handleRegister = async () => { if (!formData.email || !formData.password || !formData.firstName || !formData.lastName) { Alert.alert('Error', 'Please fill in all required fields') return } setLoading(true) try { const response = await axios.post(`${API_BASE_URL}${API_ENDPOINTS.AUTH.REGISTER}`, formData) if (response.status === 201) { Alert.alert('Success', 'Registration successful! Please login.', [ { text: 'OK', onPress: () => router.push('/login') } ]) } } catch (error: any) { Alert.alert('Error', error.response?.data?.error || 'Registration failed') } finally { setLoading(false) } } return ( Create Account Join FitAI today setFormData({ ...formData, firstName: text })} autoCapitalize="words" /> setFormData({ ...formData, lastName: text })} autoCapitalize="words" /> setFormData({ ...formData, email: text })} keyboardType="email-address" autoCapitalize="none" /> setFormData({ ...formData, phone: text })} keyboardType="phone-pad" /> setFormData({ ...formData, password: text })} secureTextEntry /> {loading ? 'Creating Account...' : 'Create Account'} router.push('/login')} > Already have an account? Login ) } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f5f5f5', padding: 20, }, title: { fontSize: 32, fontWeight: 'bold', marginBottom: 8, color: '#333', }, subtitle: { fontSize: 16, color: '#666', marginBottom: 32, }, form: { width: '100%', maxWidth: 400, }, input: { backgroundColor: 'white', paddingHorizontal: 16, paddingVertical: 12, borderRadius: 8, marginBottom: 16, borderWidth: 1, borderColor: '#ddd', }, button: { backgroundColor: '#3b82f6', paddingVertical: 14, borderRadius: 8, alignItems: 'center', marginBottom: 16, }, buttonDisabled: { backgroundColor: '#9ca3af', }, buttonText: { color: 'white', fontSize: 16, fontWeight: '600', }, linkButton: { alignItems: 'center', }, linkText: { color: '#3b82f6', fontSize: 14, }, })