import React from 'react'; import dayjs from 'dayjs'; import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'; import { useTranslation } from 'react-i18next'; import { isEmpty } from 'lodash-es'; import { Tile } from '@carbon/react'; import styles from './metrics-card.scss'; dayjs.extend(isSameOrBefore); interface MetricsCardProps { label: string; value: number; headerLabel: string; children?: React.ReactNode; count?: { expiry6months: Array }; outOfStockCount?: { itemsBelowMin: Array; itemsAboveMax: Array }; disposedCount?: { expired: Array; poorQuality: Array }; } const MetricsCard: React.FC = ({ label, value, headerLabel, children, count, outOfStockCount, disposedCount, }) => { const { t } = useTranslation(); return (
{children}

{value}

{!isEmpty(count) && (
{t('in6Months', 'In 6 months')}

{count.expiry6months?.length}

)} {!isEmpty(outOfStockCount) && (
{t('understockedItems', 'Understocked items')} {t('overstockedItems', 'Overstocked items')}

{outOfStockCount.itemsBelowMin?.length}

{outOfStockCount.itemsAboveMax?.length}

)} {!isEmpty(disposedCount) && (
{t('expired', 'Expired')} {t('poorQuality', 'Poor Quality')}

{disposedCount.expired?.length}

{disposedCount.poorQuality?.length}

)}
); }; export default MetricsCard;