- Refactor Profile and Login screens to use AuthContext for user data

- Enhance RequestPermitModal with multiple time-off types and validation
- Implement CalendarWidget for visualizing time-off requests
- Improve API error handling and token management
- Add utility functions for consistent date and time formatting
- Clean up unused mock data and update types
This commit is contained in:
2025-12-10 18:21:08 +01:00
parent 49b6ecadb2
commit b9807f6cc2
13 changed files with 503 additions and 343 deletions

View File

@ -1,11 +1,13 @@
import { useRouter } from 'expo-router';
import { AlertTriangle, Bell, CheckCircle2, FileText, QrCode, User } from 'lucide-react-native';
import React from 'react';
import { AlertTriangle, CheckCircle2, FileText, QrCode, User } from 'lucide-react-native';
import React, { useContext } from 'react';
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
import { ATTENDANCE_DATA, DOCUMENTS_DATA, MOCK_USER } from '../../data/data';
import { ATTENDANCE_DATA, DOCUMENTS_DATA } from '@/data/data';
import { AuthContext } from '@/utils/authContext';
export default function HomeScreen() {
const router = useRouter();
const { user } = useContext(AuthContext);
const incompleteTasks = ATTENDANCE_DATA.filter(item => item.status === 'incomplete');
return (
@ -16,15 +18,11 @@ export default function HomeScreen() {
<View className="flex-row items-center gap-4">
<View>
<Text className="text-teal-100 text-lg font-medium uppercase tracking-wider mb-1">Benvenuto</Text>
<Text className="text-white text-3xl font-bold">{MOCK_USER.name} {MOCK_USER.surname}</Text>
<Text className="text-teal-200">{MOCK_USER.role}</Text>
<Text className="text-white text-3xl font-bold">{user?.name} {user?.surname}</Text>
<Text className="text-xl text-teal-200">{user?.role}</Text>
</View>
</View>
<View className="flex-row gap-4">
<TouchableOpacity className="relative p-3 bg-white/10 rounded-full active:bg-white/20">
<Bell size={28} color="white" />
<View className="absolute top-2.5 right-3 w-3 h-3 bg-red-500 rounded-full border-2 border-[#099499]" />
</TouchableOpacity>
<TouchableOpacity className="p-3 bg-white/10 rounded-full active:bg-white/20" onPress={() => router.push('/profile')}>
<User size={28} color="white" />
</TouchableOpacity>