import React, { useState } from 'react'; import { View, Text, StyleSheet, TextInput, KeyboardAvoidingView, Platform, Alert, TouchableOpacity, useWindowDimensions } from 'react-native'; import { router } from 'expo-router'; import Animated, { FadeInDown, FadeInUp } from 'react-native-reanimated'; import { COLORS, SPACING, TYPOGRAPHY, BORDER_RADIUS, SHADOWS } from '../../constants/theme'; import { useLanguage } from '../../stores/LanguageContext'; import { useBarbearia } from '../../stores/BarbeariaContext'; import { Button } from '../../components/ui/Button'; import { Card } from '../../components/ui/Card'; import { Mail, Lock, User, ChevronLeft } from 'lucide-react-native'; import * as Haptics from 'expo-haptics'; export default function BarberLogin() { const { t } = useLanguage(); const { barbearia, loginBarber } = useBarbearia(); const { width } = useWindowDimensions(); const isMobile = width < 768; const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const themeColors = barbearia?.colors || COLORS; const primaryColor = themeColors.primary; const handleLogin = async () => { if (!email || !password) { if (Platform.OS === 'web') { window.alert('Preencha seu e-mail e senha'); } else { Alert.alert('Erro', 'Preencha seu e-mail e senha'); } return; } setIsLoading(true); Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium); setTimeout(() => { setIsLoading(false); // Busca o barbeiro na lista const foundBarber = barbearia?.barbers?.find(b => b.email === email && b.password === password); if (foundBarber) { loginBarber(foundBarber.id); router.replace('/admin/dashboard'); } else { if (Platform.OS === 'web') { window.alert('Credenciais inválidas'); } else { Alert.alert('Erro', 'Credenciais inválidas'); } } }, 1200); }; return ( router.back()} > {t('admin.config.back')} Área do Barbeiro Gerencie sua agenda e horários {t('admin.email')} {t('admin.password')}