import { useLocalSearchParams } from 'expo-router'; import { Alert, Pressable, ScrollView, Text, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useCocheChecklist, useWorkOrder } from '@/api/exploitation'; import { useHorsLigne } from '@/auth/session'; import { EnteteFiche } from '@/composants/ui'; import { prochainEtat, progression } from '@/lib/checklist'; import { useTokens } from '@/theme/tokens'; /** Écran 6 de la maquette R4 : la grille au pouce. Appui simple = coche, * appui long = non-applicable. En R4.2 chaque coche part immédiatement à * l'API (hors-ligne : lecture seule — la file individuelle arrive en R4.3). */ export default function PageGrille() { const t = useTokens(); const horsLigne = useHorsLigne(); const { id } = useLocalSearchParams<{ id: string }>(); const { data: ot } = useWorkOrder(id); const coche = useCocheChecklist(id); if (!ot) return null; const { faits, total, pct } = progression(ot.checklist); const basculer = (itemId: string, etat: Parameters[0], versNA = false) => { if (horsLigne) return; coche.mutate( { itemId, state: versNA ? (etat === 'NA' ? 'PENDING' : 'NA') : prochainEtat(etat) }, { onError: (e) => Alert.alert('Coche refusée', e.message) }, ); }; return ( {faits}/{total} } /> {horsLigne ? ( ⚠ Hors-ligne — les coches en file arrivent en R4.3 ; pour l’instant la grille est en lecture. ) : null} {ot.checklist.map((item) => ( basculer(item.id, item.state)} onLongPress={() => basculer(item.id, item.state, true)} style={{ flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: t.surface, borderColor: t.bordure, borderWidth: 1, borderRadius: 10, paddingHorizontal: 12, paddingVertical: 11, }} > {item.state === 'DONE' ? ( ) : item.state === 'NA' ? ( NA ) : null} {item.label} {item.doneBy ? ( {item.doneBy.displayName.split(' ')[0]} ) : null} ))} Appui simple : cocher / décocher · appui long : non-applicable. ); }