import { router, useLocalSearchParams } from 'expo-router'; import { ScrollView, Text } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { usePart } from '@/api/ressources'; import { usePermissions } from '@/auth/use-permissions'; import { BoutonTel, Carte, EnteteFiche, LigneInfo } from '@/composants/ui'; import { useTokens } from '@/theme/tokens'; const fmt = new Intl.NumberFormat('fr-FR'); const fmtMAD = new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'MAD' }); /** Fiche pièce — R6.3. Consultation + une action courante (D4) : commander, * pré-rempli depuis cette fiche, comme la maquette (écran 6). Les * mouvements de stock (entrée manuelle, ajustement) restent au web. */ export default function PageFichePiece() { const t = useTokens(); const { id } = useLocalSearchParams<{ id: string }>(); const { data: piece } = usePart(id); const { can } = usePermissions(); if (!piece) return null; const peutCommander = can('PURCHASE_ORDERS', 'create') && !!piece.supplierId; return ( {fmt.format(piece.stock)} } /> {piece.compatible ? : null} {peutCommander ? ( router.push(`/stock/${piece.id}/commander`)} /> ) : null} {!piece.supplierId && can('PURCHASE_ORDERS', 'create') ? ( Aucun fournisseur associé — commande depuis le web. ) : null} ); }