import { Chantier, Ressources } from '@/class/class'; import { ThemedView, } from '@/components/theme/themed-view'; import React, { useState } from 'react'; import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { ThemedText } from '@/components/theme/themed-text'; import { ThemedButton } from '@/components/theme/themed-button'; type RessourcesQte = [Ressources, number]; type Props = { ressource:Ressources; qte:number; sendRessource: (ressource: RessourcesQte) => void; style?: StyleProp; }; export default function RessourceSummary({ressource: ressource,qte,style,sendRessource: sendRessource, ...otherProps }: Props) { const [count,setCount] = useState(qte); function onPressAdd(ressource: Ressources): void { if(count0){ setCount(count-1); sendRessource([ressource, count-1]); } } return( {ressource.id} {ressource.name} {ressource.quantity} {ressource.type} onPressAdd(ressource)}> + {count}/{ressource.quantity} onPressSub(ressource)}> - ) } const styles = StyleSheet.create({ button:{ padding:5, marginHorizontal:10, alignItems:"center", borderRadius: 20, width: 40, height: 40, }, });