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 './theme/themed-text'; import { ThemedButton } from './theme/themed-button'; type RessourcesQte = [Ressources, number]; type Props = { machine:Ressources; qte:number; sendMachine: (machine: RessourcesQte) => void; style?: StyleProp; }; export default function MachineSummary({machine,qte,style,sendMachine, ...otherProps }: Props) { const [count,setCount] = useState(qte); function onPressAdd(machine: Ressources): void { if(count0){ setCount(count-1); sendMachine([machine, count-1]); } } return( {machine.id} {machine.name} {machine.quantity} {machine.type} onPressAdd(machine)}> + {count}/{machine.quantity} onPressSub(machine)}> - ) } const styles = StyleSheet.create({ button:{ padding:5, marginHorizontal:10, alignItems:"center", borderRadius: 20, width: 40, height: 40, }, });