import { Box, Button, FormLabel, IconButton, Input, Modal, ModalDialog, Typography, } from '@mui/joy' import { useEffect, useState } from 'react' function RedeemPointsModal({ config }) { useEffect(() => { setPoints(0) }, [config]) const [points, setPoints] = useState(0) const predefinedPoints = [1, 5, 10, 25] return ( Redeem Points Points to Redeem ({config.available ? config.available : 0} points available) { if (e.target.value > config.available) { setPoints(config.available) return } setPoints(e.target.value) }} /> Or select from predefined points: {predefinedPoints.map(point => ( { const newPoints = points + point if (newPoints > config.available) { setPoints(config.available) return } setPoints(newPoints) }} > {point} ))} {/* 3 button save , cancel and delete */} ) } export default RedeemPointsModal