All files / src/components/Product/NewProductListingBanner ReportListingBanner.tsx

100% Statements 6/6
62.5% Branches 5/8
100% Functions 2/2
100% Lines 5/5

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                                                                                                  6x 6x   6x                                                           32x 26x                                          
import React from "react";
import NewStatsTitle from "@common/NewStats/NewStatsTitle";
import { StatProps } from "@common/NewStats/Stat";
import { TruncateText, Text } from "@common/Text";
import MobileReportBanner from "@components/CampaignReport/MobileReportBanner";
import placeholder from "assets/images/Placeholder.png";
import {
  Box,
  CircularProgress,
  IconButton,
  Stack,
  useMediaQuery,
  useTheme,
} from "@mui/material";
import { palette } from "@palette";
import { convertToString } from "@utils/index";
import { Image } from "@common/StyledImage/Image";
import NewStat from "@common/NewStats/NewStat";
import { ReportActionButtons } from "@components/CampaignReport";
import NiceModal from "@ebay/nice-modal-react";
import { PEEK_MODE_MODAL } from "modals/modal_names";
 
interface ReportListingBannerProps {
  imgSrc?: string;
  type: string;
  createdAt?: string;
  stats?: StatProps[];
  textToCopy?: string;
  handleEdit?: (e: any) => void;
  handleOpenMenu?: (e: any) => void;
  secondaryActionButton?: React.ReactNode;
  statsIsFetching?: boolean;
  title?: string;
  previewLink: string;
}
 
function ReportListingBanner({
  imgSrc,
  type,
  stats,
  createdAt,
  textToCopy,
  title,
  handleEdit,
  handleOpenMenu,
  secondaryActionButton,
  statsIsFetching,
  previewLink,
}: ReportListingBannerProps) {
  const theme = useTheme();
  const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
 
  return (
    <Stack gap={2} direction="row" justifyContent="space-between">
      {statsIsFetching ? (
        <CircularProgress
          size={40}
          sx={{
            color: "#8F8F8F",
          }}
        />
      ) : (
        <Box>
          <NewStatsTitle
            isAmount
            label={stats![0].title}
            value={convertToString(stats ? (stats[0].value as number) : 0)}
            align="right"
            isMainTitle
          />
        </Box>
      )}
      <Stack gap={8} direction="row">
        {statsIsFetching ? (
          <CircularProgress
            size={40}
            sx={{
              color: "#8F8F8F",
            }}
          />
        ) : (
          stats?.map(({ isAmount, title, value, percent }, index) => {
            if (index === 0) return;
            return (
              <NewStat
                key={index}
                isAmount={isAmount}
                title={title}
                value={value}
                percent={percent}
                valueProps={{
                  lineHeight: "32.4px",
                  color: palette.black[100],
                }}
              />
            );
          })
        )}
      </Stack>
    </Stack>
  );
}
 
export default ReportListingBanner;