import { router } from 'expo-router'; import { FlatList, Pressable, Text, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useWorkOrders } from '@/api/exploitation'; import { ChipStatut } from '@/composants/ui'; import { useTokens } from '@/theme/tokens'; /** Onglet Préventif : mes grilles du moment — chaque tuile mène à la * checklist cochable (écran 6). Les OT viennent déjà scopés par l'API. */ export default function PagePreventif() { const t = useTokens(); const { data: workOrders } = useWorkOrders(); const grilles = (workOrders ?? []) .filter((w) => w.type === 'PREVENTIVE' && w.status !== 'DONE' && w.status !== 'CANCELLED') .sort((a, b) => (a.dueDate ?? '9999').localeCompare(b.dueDate ?? '9999')); return ( Préventif w.id} contentContainerStyle={{ gap: 8, paddingBottom: 12 }} ListEmptyComponent={ Aucune grille préventive en cours pour vous. } renderItem={({ item: w }) => ( router.push(`/ot/${w.id}/grille`)} style={{ backgroundColor: t.surface, borderColor: t.bordure, borderWidth: 1, borderRadius: 12, padding: 12, gap: 2, }} > {w.reference} {w.title} Asc. {w.assetReference} — {w.siteName} {w.dueDate ? ` · pour le ${new Intl.DateTimeFormat('fr-FR', { day: 'numeric', month: 'short' }).format(new Date(w.dueDate))}` : ''} )} /> ); }