BasketItem.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import styles from "styles/BasketItem.module.scss";
  2. import Title from "components/Title";
  3. import GetIcon from "components/GetIcon";
  4. import Quantity from "components/Quantity";
  5. import cartStore from 'stores/cartStore';
  6. import {observer} from 'mobx-react';
  7. import {IMAGES_URL} from 'config';
  8. const BasketItem = ({ data }) => {
  9. const {product} = data;
  10. return (
  11. <div className={styles.item}>
  12. <div className={styles.img}>
  13. {product.images[0] ? <img src={IMAGES_URL + product.images[0].url} alt="" /> : null}
  14. </div>
  15. <div className={styles.detail}>
  16. <div className={styles.title}>
  17. <Title txt={product.name} size={16} />
  18. </div>
  19. <div className={styles.priceContainer}>
  20. <small className={styles.singlePrice}>{product.price.toFixed(2)}</small>
  21. <small className={styles.quantityN}>{data.quantity}</small>
  22. <small className={styles.totalPrice}> {`${(product.price * data.quantity).toFixed(2)}`} UAH</small>
  23. </div>
  24. <Quantity data={data} />
  25. </div>
  26. <div className={styles.removeItem}>
  27. <button type="button" onClick={() => cartStore.removeProduct(data.product)}>
  28. <GetIcon icon="BsDash" size={17} />
  29. </button>
  30. </div>
  31. </div>
  32. );
  33. };
  34. export default observer(BasketItem);