feat: Implement alert system and network connectivity handling, refactor error handling across screens
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
import React, { useState, useContext } from 'react';
|
||||
import { Eye, EyeOff, Lock, LogIn, Mail } from 'lucide-react-native';
|
||||
import { KeyboardAvoidingView, Platform, ScrollView, Text, TextInput, TouchableOpacity, View, Image, Alert } from 'react-native';
|
||||
import { AuthContext } from '@/utils/authContext';
|
||||
import { useAlert } from '@/components/AlertComponent';
|
||||
import api from '@/utils/api';
|
||||
import { AuthContext } from '@/utils/authContext';
|
||||
import { Eye, EyeOff, Lock, LogIn, Mail } from 'lucide-react-native';
|
||||
import React, { useContext, useState } from 'react';
|
||||
import { Image, KeyboardAvoidingView, Platform, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
export default function LoginScreen() {
|
||||
const alert = useAlert();
|
||||
const authContext = useContext(AuthContext);
|
||||
const [username, setUsername] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
@ -14,8 +16,8 @@ export default function LoginScreen() {
|
||||
// TODO: Riscrivere funzione per migliorare leggibilità e gestione errori
|
||||
const handleLogin = async () => {
|
||||
// TODO: Implementa toast o messaggio di errore più user-friendly
|
||||
if (!username || !password) {
|
||||
Alert.alert("Attenzione", "Inserisci username e password");
|
||||
if (!username || !password) {
|
||||
alert.showAlert('error', 'Attenzione', 'Inserisci username e password');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,7 +57,7 @@ export default function LoginScreen() {
|
||||
message = "Impossibile contattare il server. Controlla la connessione.";
|
||||
}
|
||||
|
||||
Alert.alert("Login Fallito", message);
|
||||
alert.showAlert('error', "Login Fallito", message);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user