feat: Implement alert system and network connectivity handling, refactor error handling across screens
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import { Building2, ChevronRight, MapPin, Search } from 'lucide-react-native';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Alert, RefreshControl, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { RefreshControl, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { useRouter } from 'expo-router';
|
||||
import api from '@/utils/api';
|
||||
import LoadingScreen from '@/components/LoadingScreen';
|
||||
import { ConstructionSite } from '@/types/types';
|
||||
import { useAlert } from '@/components/AlertComponent';
|
||||
|
||||
export default function SitesScreen() {
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
@ -12,6 +13,7 @@ export default function SitesScreen() {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const router = useRouter();
|
||||
const alert = useAlert();
|
||||
|
||||
// Fetch cantieri e documenti
|
||||
const fetchConstructionSites = async () => {
|
||||
@ -23,7 +25,7 @@ export default function SitesScreen() {
|
||||
setConstructionSites(response.data);
|
||||
} catch (error) {
|
||||
console.error('Errore nel recupero dei cantieri:', error);
|
||||
Alert.alert('Errore', 'Impossibile recuperare i cantieri. Riprova più tardi.');
|
||||
alert.showAlert('error', 'Errore', 'Impossibile recuperare i cantieri. Riprova più tardi.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setRefreshing(false);
|
||||
|
||||
Reference in New Issue
Block a user