All files / src/components/OverviewBoxes index.tsx

100% Statements 84/84
83.33% Branches 5/6
100% Functions 1/1
100% Lines 84/84

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122  1x                 1x                 1x 3x 3x 3x 3x 3x 3x 3x   3x 2x 2x 2x   2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x       3x 2x 2x 2x               2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x 2x   3x   3x  
import { ChartMode, Stats } from '@/types';
import { formatDateByMode } from '@/utils';
import {
  ChartIcon,
  DislikedIcon,
  FoodCoverIcon,
  LikedIcon,
  MaximumIcon,
  MinimumIcon,
} from '../icons/reacts';
import { StatRow } from '../StatRow';
 
interface Props {
  stat: Stats;
  chartMode: ChartMode;
  showLunch?: boolean;
  showReactions?: boolean;
}
 
export const OverviewBoxes = ({
  stat,
  chartMode,
  showLunch = true,
  showReactions = true,
}: Props) => {
  return (
    <>
      {/* Lunch Registrations */}
      {showLunch && stat?.lunchRegistrations && (
        <StatRow
          items={[
            {
              // icon: <FoodCoverIcon className="text-secondary-150" />,
              title: 'Total:',
              result: stat.lunchRegistrations.total,
              titleClassName: 'text-secondary-150',
              containerClassName: 'border border-secondary-150',
            },
            {
              // icon: <ChartIcon className="text-secondary-150" />,
              title: 'Avg:',
              result: stat.lunchRegistrations.avg,
              titleClassName: 'text-secondary-150',
              containerClassName: 'border border-secondary-150',
            },
            {
              // icon: <MinimumIcon className="text-secondary-150" />,
              title: 'Min:',
              result: stat.lunchRegistrations.min.value,
              date: formatDateByMode(
                stat.lunchRegistrations.min.date,
                chartMode,
              ),
              line: true,
              titleClassName: 'text-secondary-150',
              containerClassName: 'border border-secondary-150',
            },
            {
              // icon: <MaximumIcon className="text-secondary-150" />,
              title: 'Max:',
              result: stat.lunchRegistrations.max.value,
              date: formatDateByMode(
                stat.lunchRegistrations.max.date,
                chartMode,
              ),
              line: true,
              titleClassName: 'text-secondary-150',
              containerClassName: 'border border-secondary-150',
            },
          ]}
        />
      )}
 
      {/* Likes & Dislikes */}
      {showReactions && (stat?.likes || stat?.dislikes) && (
        <StatRow
          items={[
            {
              // icon: (
              //   <LikedIcon
              //     width={22}
              //     height={24}
              //     className="text-primary-350"
              //   />
              // ),
              title: 'Total:',
              result: stat.likes?.total,
              titleClassName: 'text-secondary',
              containerClassName: 'border border-secondary',
            },
            {
              // icon: <MaximumIcon className="text-primary-350" />,
              title: 'Max:',
              result: stat.likes?.max?.value,
              date: formatDateByMode(stat.likes?.max?.date, chartMode),
              line: true,
              titleClassName: 'text-secondary',
              containerClassName: 'border border-secondary',
            },
            {
              // icon: <DislikedIcon className="text-primary-550" />,
              title: 'Total:',
              result: stat.dislikes?.total,
              titleClassName: 'text-primary-550',
              containerClassName: 'border border-primary-550',
            },
            {
              // icon: <MaximumIcon className="text-primary-550" />,
              title: 'Max:',
              result: stat.dislikes?.max?.value,
              date: formatDateByMode(stat.dislikes?.max?.date, chartMode),
              line: true,
              titleClassName: 'text-primary-550',
              containerClassName: 'border border-primary-550',
            },
          ]}
        />
      )}
    </>
  );
};