feat: Implement alert system and network connectivity handling, refactor error handling across screens
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
import { useAlert } from '@/components/AlertComponent';
|
||||
import { ArrowLeft, Download, FileText, MapPin, Plus, Search, CalendarIcon } from 'lucide-react-native';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useRouter } from 'expo-router';
|
||||
import { RangePickerModal } from '@/components/RangePickerModal';
|
||||
import { Alert, RefreshControl, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { RefreshControl, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { DocumentItem } from '@/types/types';
|
||||
import api from '@/utils/api';
|
||||
import dayjs from 'dayjs';
|
||||
@ -13,6 +14,7 @@ import { downloadAndShareDocument, uploadDocument } from '@/utils/documentUtils'
|
||||
|
||||
export default function DocumentsScreen() {
|
||||
const router = useRouter();
|
||||
const alert = useAlert();
|
||||
const [documents, setDocuments] = useState<DocumentItem[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
@ -35,7 +37,7 @@ export default function DocumentsScreen() {
|
||||
setDocuments(response.data);
|
||||
} catch (error) {
|
||||
console.error('Errore nel recupero dei documenti utente:', error);
|
||||
Alert.alert('Errore', 'Impossibile recuperare i documenti. Riprova più tardi.');
|
||||
alert.showAlert('error', 'Errore', 'Impossibile recuperare i documenti. Riprova più tardi.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setRefreshing(false);
|
||||
@ -83,12 +85,12 @@ export default function DocumentsScreen() {
|
||||
setIsUploading(true);
|
||||
try {
|
||||
await uploadDocument(file, null, customTitle);
|
||||
Alert.alert('Successo', 'Documento caricato con successo!');
|
||||
alert.showAlert('success', 'Successo', 'Documento caricato con successo!');
|
||||
setShowUploadModal(false);
|
||||
fetchUserDocuments();
|
||||
} catch (error) {
|
||||
console.error('Errore nel caricamento del documento:', error);
|
||||
Alert.alert('Errore', 'Impossibile caricare il documento. Riprova più tardi.');
|
||||
alert.showAlert('error', 'Errore', 'Impossibile caricare il documento. Riprova più tardi.');
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user