import React, { useState } from 'react'; import { Text, View, TextInput, TouchableOpacity, KeyboardAvoidingView, Platform, ScrollView, } from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { useNavigation } from '@react-navigation/native'; import Icon from 'react-native-vector-icons/Ionicons'; import { getStyles } from './login.styles'; import { useTheme } from '../../theme'; export const LoginScreen = () => { const navigation = useNavigation(); const { theme: colors } = useTheme(); const styles = getStyles(colors); const [tenancy, setTenancy] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleLogin = async () => { setError(''); if (!tenancy.trim()) { setError('Tenancy name is required'); return; } if (!email.trim()) { setError('Email address is required'); return; } if (!password.trim()) { setError('Password is required'); return; } setLoading(true); try { const mockToken = 'dummy-jwt-token-for-crm'; await AsyncStorage.setItem('userToken', mockToken); await AsyncStorage.setItem('tenancyName', tenancy); setLoading(false); navigation.reset({ index: 0, routes: [{ name: 'DrawerStack' }], // root-level stack name stays as-is }); } catch { setLoading(false); setError('Failed to sign in. Please try again.'); } }; return ( Convex CRM Enter details to access your workspace {error ? ( {error} ) : null} {/* Tenancy Field */} Tenancy Name {/* Email Field */} Email Address {/* Password Field */} Password {/* Sign In Button */} {loading ? 'Signing In...' : 'Sign In'} Secure SSL encrypted workspace ); };