feat: Update assets and improve code comments across multiple components
- Updated favicon and various image assets. - Enhanced comments. - Adjusted styles and functionality in several components for improved user experience. - Updated package-lock.json to reflect dependency updates.
This commit is contained in:
@@ -8,13 +8,14 @@ import CalendarWidget from '@/components/CalendarWidget';
|
||||
import LoadingScreen from '@/components/LoadingScreen';
|
||||
import api from '@/utils/api';
|
||||
import { formatDate, formatTime } from '@/utils/dateTime';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
|
||||
// Icon Mapping
|
||||
const typeIcons: Record<string, (color: string) => JSX.Element> = {
|
||||
Ferie: (color) => <CalendarIcon size={24} color={color} />,
|
||||
Permesso: (color) => <Clock size={24} color={color} />,
|
||||
Malattia: (color) => <Thermometer size={24} color={color} />,
|
||||
Assenza: (color) => <CalendarX size={24} color={color} />,
|
||||
Ferie: (color) => <CalendarIcon size={24} color={color} />,
|
||||
Permesso: (color) => <Clock size={24} color={color} />,
|
||||
Malattia: (color) => <Thermometer size={24} color={color} />,
|
||||
Assenza: (color) => <CalendarX size={24} color={color} />,
|
||||
};
|
||||
|
||||
export default function PermitsScreen() {
|
||||
@@ -33,7 +34,7 @@ export default function PermitsScreen() {
|
||||
// Fetch Permits
|
||||
const response = await api.get('/time-off-request/list');
|
||||
setPermits(response.data);
|
||||
|
||||
|
||||
// Fetch Types
|
||||
const typesResponse = await api.get('/time-off-request/get-types');
|
||||
setTypes(typesResponse.data);
|
||||
@@ -49,22 +50,21 @@ export default function PermitsScreen() {
|
||||
const filteredPermits = useMemo(() => {
|
||||
if (!permits.length) return [];
|
||||
|
||||
// Calcoliamo inizio e fine del mese visualizzato
|
||||
// Calculate start and end of the current month
|
||||
const year = currentMonthDate.getFullYear();
|
||||
const month = currentMonthDate.getMonth();
|
||||
|
||||
|
||||
const startOfMonth = new Date(year, month, 1);
|
||||
// Trucco JS: giorno 0 del mese successivo = ultimo giorno del mese corrente
|
||||
const endOfMonth = new Date(year, month + 1, 0, 23, 59, 59);
|
||||
// Day 0 of the next month = last day of the current month
|
||||
const endOfMonth = new Date(year, month + 1, 0, 23, 59, 59);
|
||||
|
||||
return permits.filter(item => {
|
||||
const itemStart = new Date(item.start_date?.toString() ?? '');
|
||||
// Se non c'è end_date, assumiamo sia un giorno singolo (quindi end = start)
|
||||
// If there's no end_date, assume it's a single day (so end = start)
|
||||
const itemEnd = item.end_date ? new Date(item.end_date?.toString() ?? '') : new Date(item.start_date?.toString() ?? '');
|
||||
|
||||
// FORMULA OVERLAP:
|
||||
// Il permesso è visibile se inizia prima della fine del mese
|
||||
// E finisce dopo l'inizio del mese.
|
||||
// The permit is visible if it starts before the end of the month
|
||||
// And ends after the start of the month.
|
||||
return itemStart <= endOfMonth && itemEnd >= startOfMonth;
|
||||
});
|
||||
}, [permits, currentMonthDate]);
|
||||
@@ -92,11 +92,13 @@ export default function PermitsScreen() {
|
||||
/>
|
||||
|
||||
{/* Header */}
|
||||
<View className="bg-white p-6 pt-16 shadow-sm border-b border-gray-100 flex-row justify-between items-center">
|
||||
<View>
|
||||
<Text className="text-3xl font-bold text-gray-800 mb-1">Ferie e Permessi</Text>
|
||||
<Text className="text-base text-gray-500">Gestisci le tue assenze</Text>
|
||||
</View>
|
||||
<View className="bg-white px-6 pb-6 shadow-sm border-b border-gray-100 flex-row justify-between items-center">
|
||||
<SafeAreaView edges={['top']} className='pt-4'>
|
||||
<View>
|
||||
<Text className="text-3xl font-bold text-gray-800 mb-1">Ferie e Permessi</Text>
|
||||
<Text className="text-base text-gray-500">Gestisci le tue assenze</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
@@ -110,7 +112,7 @@ export default function PermitsScreen() {
|
||||
{/* Calendar Widget */}
|
||||
<CalendarWidget events={permits} types={types} onMonthChange={(date) => setCurrentMonthDate(date)} />
|
||||
|
||||
{/* Lista Richieste Recenti */}
|
||||
{/* Recent Requests List */}
|
||||
<View>
|
||||
{filteredPermits.length === 0 ? (
|
||||
<Text className="text-center text-gray-500 mt-8">Nessuna richiesta di permesso questo mese</Text>
|
||||
@@ -135,7 +137,7 @@ export default function PermitsScreen() {
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
{/* TODO: Aggiungere funzionalità per modificare/eliminare la richiesta? */}
|
||||
{/* TODO: Add functionality to edit/remove the request */}
|
||||
<View className={`px-3 py-1.5 rounded-lg ${item.status ? 'bg-green-100' : 'bg-yellow-100'}`}>
|
||||
<Text className={`text-xs font-bold uppercase tracking-wide ${item.status ? 'text-green-700' : 'text-yellow-700'}`}>
|
||||
{item.status ? 'Approvato' : 'In Attesa'}
|
||||
|
||||
Reference in New Issue
Block a user