import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Media } from 'reactstrap'; import Flex from '../common/Flex'; import AppContext from '../../context/Context'; import { Link } from 'react-router-dom'; import FalconProgress from '../common/FalconProgress'; const getProductItemCalculatedData = (unit, price, totalPrice) => { const productTotalPrice = unit * price; const percentage = ((productTotalPrice * 100) / totalPrice).toFixed(0); return { productTotalPrice, percentage }; }; const BestSellingProduct = ({ product, totalPrice, isLast }) => { const { currency } = useContext(AppContext); const { img, title, type, unit, price } = product; const { productTotalPrice, percentage } = getProductItemCalculatedData(unit, price, totalPrice); return (
{type}