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

@@ -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>