import React, { useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
import ShowImage from './ShowImage';
import moment from 'moment';
// eslint-disable-next-line
import ModalVideo from 'react-modal-video';
import { addItem, updateItem, removeItem } from './cartHelpers';
import StarRating from './StarRating';
import './../../node_modules/react-modal-video/scss/modal-video.scss';
const Card = ({
product,
showViewProductButton = true,
showAddToCartButton = true,
cartUpdate = false,
showRemoveProductButton = false,
setRun = f => f,
run = undefined
// changeCartSize
}) => {
const [redirect, setRedirect] = useState(false);
const [count, setCount] = useState(product.count);
const showViewButton = showViewProductButton => {
return (
showViewProductButton && (
)
);
};
const addToCart = () => {
// console.log('added');
addItem(product, setRedirect(true));
};
const shouldRedirect = redirect => {
if (redirect) {
return
Price : ₹ {product.price}
{product.description.substring(0, 400)}
{showViewButton(showViewProductButton)} {showAddToCartBtn(showAddToCartButton)} {showRemoveButton(showRemoveProductButton)} {showCartUpdateOptions(cartUpdate)}Added on {moment(product.createdAt).fromNow()}
Category: {product.category && product.category.name}