25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

  1. import React from 'react'
  2. import { useDispatch } from 'react-redux'
  3. import * as Icon from 'react-feather'
  4. const QtyForm = ({ id, quantity}) => {
  5. const dispatch = useDispatch()
  6. const addQuantity = (pId) => {
  7. dispatch({
  8. type: 'ADD_QUANTITY',
  9. id: pId
  10. })
  11. }
  12. const subQuantity = (pId) => {
  13. dispatch({
  14. type: 'SUB_QUANTITY',
  15. id: pId
  16. })
  17. }
  18. return (
  19. <div className="input-counter">
  20. <span
  21. className="minus-btn"
  22. onClick={e => {
  23. e.preventDefault();
  24. subQuantity(id);
  25. }}
  26. >
  27. <Icon.Minus />
  28. </span>
  29. <input
  30. type="text"
  31. min="1"
  32. value={quantity}
  33. readOnly={true}
  34. onChange={e => (e)}
  35. />
  36. <span className="plus-btn" onClick={e => {
  37. e.preventDefault();
  38. addQuantity(id);
  39. }}>
  40. <Icon.Plus />
  41. </span>
  42. </div>
  43. )
  44. }
  45. export default QtyForm