/** * Login Screen * * Handles employee authentication. */ import { useState } from 'react'; import { View, Text, TextInput, TouchableOpacity, StyleSheet, KeyboardAvoidingView, Platform, Alert, ActivityIndicator, Image, } from 'react-native'; import { useRouter } from 'expo-router'; import { useAuth } from '../src/hooks/useAuth'; export default function LoginScreen() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const { login } = useAuth(); const router = useRouter(); const handleLogin = async () => { if (!email.trim()) { Alert.alert('Error', 'Please enter your email'); return; } if (!password) { Alert.alert('Error', 'Please enter your password'); return; } setIsSubmitting(true); try { await login({ email: email.trim().toLowerCase(), password }); router.replace('/(auth)/jobs'); } catch (error: any) { const message = error?.response?.data?.error || error?.message || 'Login failed. Please try again.'; Alert.alert('Login Failed', message); } finally { setIsSubmitting(false); } }; return ( SmoothSchedule Field Employee App Email Password {isSubmitting ? ( ) : ( Sign In )} Contact your manager if you need account access {/* Dev Quick Login */} {__DEV__ && ( { setEmail('timm50@hotmail.com'); setPassword('starry12'); }} > Dev: Fill Test Credentials )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f9fafb', }, content: { flex: 1, justifyContent: 'center', paddingHorizontal: 24, }, header: { alignItems: 'center', marginBottom: 48, }, logo: { width: 80, height: 80, marginBottom: 16, }, title: { fontSize: 32, fontWeight: 'bold', color: '#2563eb', }, subtitle: { fontSize: 16, color: '#6b7280', marginTop: 8, }, form: { backgroundColor: '#fff', borderRadius: 12, padding: 24, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, inputContainer: { marginBottom: 16, }, label: { fontSize: 14, fontWeight: '600', color: '#374151', marginBottom: 8, }, input: { backgroundColor: '#f9fafb', borderWidth: 1, borderColor: '#e5e7eb', borderRadius: 8, paddingHorizontal: 16, paddingVertical: 12, fontSize: 16, color: '#111827', }, button: { backgroundColor: '#2563eb', borderRadius: 8, paddingVertical: 14, alignItems: 'center', marginTop: 8, }, buttonDisabled: { backgroundColor: '#93c5fd', }, buttonText: { color: '#fff', fontSize: 16, fontWeight: '600', }, footer: { marginTop: 32, alignItems: 'center', }, footerText: { color: '#9ca3af', fontSize: 14, textAlign: 'center', }, devButton: { marginTop: 24, backgroundColor: '#fbbf24', paddingVertical: 12, paddingHorizontal: 20, borderRadius: 8, alignSelf: 'center', }, devButtonText: { color: '#78350f', fontSize: 14, fontWeight: '600', }, });