SetCount.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. import {Box, Button} from "@mui/material";
  2. import {useEffect, useState} from "react";
  3. export const SetCount = ({onCount}) => {
  4. let [count, setCount] = useState(1)
  5. useEffect(() => {
  6. onCount(count)
  7. }, [count, onCount])
  8. return (
  9. <Box sx={{display: 'flex', flexWrap: 'no-wrap'}}>
  10. <Button
  11. sx={{height: '55px', width: '50px', borderRadius: '0', color: '#000', borderColor: '#000', fontSize: '30px', fontWeight: '300'}}
  12. variant="outlined"
  13. color={"inherit"}
  14. onClick={() => setCount(count === 1 ? count : count-1)}
  15. >
  16. -
  17. </Button>
  18. <input disabled value={count} style={{boxSizing: 'border-box', height: '55px', width: '60px', textAlign: 'center', border: '0', backgroundColor: '#eaeaea'}}/>
  19. <Button
  20. sx={{height: '55px', width: '50px', borderRadius: '0', color: '#000', borderColor: '#000', fontSize: '30px', fontWeight: '300'}}
  21. variant="outlined"
  22. color={"inherit"}
  23. onClick={() => setCount(count === 100 ? count : count+1)}
  24. >
  25. +
  26. </Button>
  27. </Box>
  28. )
  29. }