All files / src/components/Disputes/DisputeTable/Banner DisputesBanner.tsx

90.9% Statements 10/11
60% Branches 6/10
100% Functions 1/1
90.9% Lines 10/11

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                                              1x           15x 15x   15x 15x 15x   15x 15x   15x                                       15x                                                                                                      
import ProductBannerBase from "@features/Products/ProductBannerBase";
import { Box } from "@mui/material";
import { useDisputesStats } from "../hooks/useDisputesStats";
import DisputeActions from "./DisputeActions";
import GiveTabs from "@shared/Tabs/GiveTabs";
import { useAppTheme } from "@theme/v2/Provider";
import useThemeSettings from "@components/EnterpriseSettings/Branding/hooks/useThemeSettings";
import { SIDEMENU_WIDTH } from "@constants/constants";
import {
  tabNames,
  useDisputeTableNewTable,
} from "@components/Disputes/DisputesList/hooks/useDisputeTableNewTable";
import { useAppSelector } from "@redux/hooks";
import { selectDisputeTab } from "@redux/slices/transactions";
 
type Props = {
  search: string;
  actualTotalRows?: number;
  handleSearchChange: (value: string) => void;
  selectedTabFilter?: string | number;
  compact?: boolean;
};
 
const DisputesBanner = ({
  handleSearchChange,
  search,
  actualTotalRows,
  compact,
}: Props) => {
  const { data, tabStats, isLoading } = useDisputesStats();
  const theme = useAppTheme();
  const { textColor, bgColorHighlight, colors, isGradientText } =
    useThemeSettings();
  const { tableFilters } = useDisputeTableNewTable();
  const tab = useAppSelector(selectDisputeTab);
 
  const { mainStats, stats } = data || {};
  const dataIsNotReady = typeof tabStats === "undefined" || isLoading;
 
  Iif (compact) {
    return (
      <ProductBannerBase
        mainStats={mainStats}
        parseStats={stats}
        title="Disputes"
        isLoading={dataIsNotReady}
        compact
        compactActions={
          <DisputeActions
            handleSearchChange={handleSearchChange}
            search={search}
            noTransactions={actualTotalRows === 0}
            compact
          />
        }
      />
    );
  }
 
  return (
    <Box pb={3}>
      <ProductBannerBase
        mainStats={mainStats}
        parseStats={stats}
        title="Disputes"
        isLoading={dataIsNotReady}
      />
      <DisputeActions
        handleSearchChange={handleSearchChange}
        search={search}
        noTransactions={actualTotalRows === 0}
      />
      <GiveTabs
        items={tableFilters}
        type="pill"
        selected={tab || tabNames.all}
        variant="gradient"
        containerSx={{
          display: "flex",
          overflowX: "auto",
          scrollbarWidth: "none",
          [theme.breakpoints.down("v2_sm")]: {
            width: "100vw",
            // The negative margin compensates for table padding to prevent layout breaking.
            margin: "0 -20px",
            padding: "0 20px",
            whiteSpace: "nowrap",
            overflowX: "auto",
          },
 
          [theme.breakpoints.between("v2_sm", "new_lg")]: {
            width: "100vw",
            // The negative margin compensates for table padding to prevent layout breaking.
            margin: `0 -${40 + SIDEMENU_WIDTH}px`,
            padding: `0 40px 0 ${40 + SIDEMENU_WIDTH}px`,
            whiteSpace: "nowrap",
            overflowX: "auto",
          },
          gap: "4px",
        }}
        selectedTabSx={{
          textColor: isGradientText ? colors?.[0] : textColor,
          backgroundColor: bgColorHighlight,
        }}
      />
    </Box>
  );
};
 
export default DisputesBanner;