feat: enhance configuration management, add update checks, and improve UI components

This commit is contained in:
2026-03-02 12:13:01 +01:00
parent ed25c5299d
commit e8e76cdf8b
12 changed files with 239 additions and 46 deletions

View File

@@ -2,7 +2,7 @@ import { Redirect, Tabs } from 'expo-router';
import { Home, Clock, Zap, CalendarIcon, Building } from 'lucide-react-native';
import { useContext } from 'react';
import { AuthContext } from '@/utils/authContext';
import {useSafeAreaInsets} from "react-native-safe-area-context";
import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function ProtectedLayout() {
const authState = useContext(AuthContext);
@@ -32,9 +32,9 @@ export default function ProtectedLayout() {
tabBarActiveTintColor: '#099499',
tabBarInactiveTintColor: '#9ca3af',
tabBarLabelStyle: {
fontSize: 12,
fontWeight: '600',
marginTop: 4
fontSize: 12,
fontWeight: '600',
marginTop: 4
}
}}
backBehavior='history'

View File

@@ -83,7 +83,7 @@ export default function PermitsScreen() {
const deletePermitRequest = async (id: number, itemRef?: React.ElementRef<typeof Swipeable> | null) => {
try {
itemRef?.close();
await api.post(`/time-off-request/delete-request`, {id: id});
await api.post(`/time-off-request/delete-request`, { id: id });
// Optimistic update
setPermits(prevPermits => prevPermits.filter(p => p.id !== id));
alert.showAlert('success', 'Richiesta eliminata', 'La richiesta è stata eliminata con successo.');
@@ -136,7 +136,7 @@ export default function PermitsScreen() {
onPress={() => confirmDelete(item, swipeableRef.current)}
className="bg-red-500 justify-center items-center px-6 rounded-3xl ml-3"
activeOpacity={0.7}
style={{margin: 2}}
style={{ margin: 2 }}
>
<View className="items-center gap-1">
<Trash2 size={24} color="white" strokeWidth={2.5} pointerEvents="none" />
@@ -196,23 +196,28 @@ export default function PermitsScreen() {
<View className={`p-4 rounded-2xl`} style={{ backgroundColor: item.timeOffRequestType.color ? `${item.timeOffRequestType.color}25` : '#E5E7EB' }}>
{typeIcons[item.timeOffRequestType.name]?.(item.timeOffRequestType.color)}
</View>
<View>
<Text className="font-bold text-gray-800 text-lg">{item.timeOffRequestType.name}</Text>
<View className='flex-1'>
<View className="flex-row justify-between items-center">
<Text className="font-bold text-gray-800 text-lg">{item.timeOffRequestType.name}</Text>
<View className={`px-3 py-1.5 rounded-lg ${item.status === 1 ? 'bg-green-100' : item.status === 0 ? 'bg-red-100' : 'bg-yellow-100'}`}>
<Text className={`text-xs font-bold uppercase tracking-wide ${item.status === 1 ? 'text-green-700' : item.status === 0 ? 'text-red-700' : 'text-yellow-700'}`}>
{item.status === 1 ? 'Approvata' : item.status === 0 ? 'Rifiutata' : 'In Attesa'}
</Text>
</View>
</View>
<Text className="text-sm text-gray-600 mt-0.5 leading-tight">{item.message}</Text>
<Text className="text-base text-gray-500 mt-0.5">
{formatDate(item.start_date?.toLocaleString())} {item.end_date ? `- ${formatDate(item.end_date.toLocaleString())}` : ''}
</Text>
{item.timeOffRequestType.name === 'Permesso' && (
<Text className="text-sm text-orange-600 font-bold mt-1">
<Text className="text-sm text-orange-600 font-bold mt-0.5">
{formatTime(item.start_time)} - {formatTime(item.end_time)}
</Text>
)}
</View>
</View>
<View className={`px-3 py-1.5 rounded-lg ${item.status===1 ? 'bg-green-100' : item.status===0 ? 'bg-red-100' : 'bg-yellow-100'}`}>
<Text className={`text-xs font-bold uppercase tracking-wide ${item.status===1 ? 'text-green-700' : item.status===0 ? 'text-red-700' : 'text-yellow-700'}`}>
{item.status===1 ? 'Approvata' : item.status===0 ? 'Rifiutata' : 'In Attesa'}
</Text>
</View>
</View>
);
@@ -228,7 +233,7 @@ export default function PermitsScreen() {
rightThreshold={40}
friction={2}
overshootFriction={8}
containerStyle={{padding: 2}}
containerStyle={{ padding: 2 }}
>
{cardContent}
</Swipeable>

View File

@@ -4,7 +4,7 @@ export default function ProfileLayout() {
return (
<Stack screenOptions={{headerShown: false}}>
<Stack.Screen name="index" />
<Stack.Screen name="documents" />
<Stack.Screen name="documents" options={{ animation: 'slide_from_right' }} />
</Stack>
);
}

View File

@@ -5,7 +5,8 @@ import { AlertProvider } from '@/components/AlertComponent';
import { NetworkProvider } from '@/utils/networkProvider';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { KeyboardProvider } from "react-native-keyboard-controller";
import {GestureHandlerRootView} from "react-native-gesture-handler";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { ConfigProvider } from '@/utils/configProvider';
export default function AppLayout() {
return (
@@ -13,14 +14,16 @@ export default function AppLayout() {
<GestureHandlerRootView>
<KeyboardProvider>
<NetworkProvider>
<AuthProvider>
<AlertProvider>
<Stack screenOptions={{ headerShown: false, animation: 'flip' }}>
<Stack.Screen name="(protected)" />
<Stack.Screen name="login" />
</Stack>
</AlertProvider>
</AuthProvider>
<ConfigProvider>
<AuthProvider>
<AlertProvider>
<Stack screenOptions={{ headerShown: false, animation: 'flip' }}>
<Stack.Screen name="(protected)" />
<Stack.Screen name="login" />
</Stack>
</AlertProvider>
</AuthProvider>
</ConfigProvider>
</NetworkProvider>
</KeyboardProvider>
</GestureHandlerRootView>