All files / src/features/Settlements styles.ts

93.75% Statements 30/32
60% Branches 12/20
81.81% Functions 9/11
100% Lines 27/27

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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255              7x     3x                                                                                       7x       1794x 204x   1590x     26x                           7x       298x 298x             183x                               7x       1496x 1496x               7x                               7x 26x                   7x       26x   26x                                                                       7x               7x               7x             7x                               7x             7x                 62x                      
import { IconButton } from "@common/IconButton";
import { Box, Stack } from "@mui/material";
import { Table, TableCell, TableHead, TableRow } from "@mui/material";
import GiveButton from "@shared/Button/GiveButton";
import { styled, useAppTheme } from "@theme/v2/Provider";
 
// SettlementMerchantTableStyls:
export const getTableStyles = (
  palette: ReturnType<typeof useAppTheme>["palette"],
  isMobileView: boolean,
) => ({
  containerSx: {
    height: isMobileView ? "calc(100vh - 185px)" : "calc(100vh - 146px)",
    position: "relative",
    overflowX: "hidden !important",
    overflowY: "auto",
    width: "100%",
    maxWidth: "100%",
    "& .MuiTableContainer-root": {
      overflowX: "hidden !important",
      width: "100%",
    },
    "& .MuiTable-root": {
      borderCollapse: "separate !important",
      borderSpacing: "0 !important",
    },
    "& caption": {
      position: "sticky",
      top: 0,
      zIndex: 3,
      backgroundColor: palette.background?.paper,
    },
    "& thead": {
      position: "sticky",
      top: isMobileView ? "100px" : "44px",
      zIndex: 2,
      backgroundColor: palette.background?.paper,
    },
    "& thead th": {
      paddingLeft: "0 !important",
      paddingRight: "0 !important",
      borderBottom: `1px solid ${palette.border?.primary}`,
    },
  },
  rowSx: {
    "& > *": {
      borderBottom: "none !important",
      paddingLeft: "0 !important",
      paddingRight: "0 !important",
    },
  },
});
 
// SettlementReportBankProviderTable Styles
const getCellWidth = (
  isFirstColumn: boolean | undefined,
  isMobileView: boolean | undefined,
): string => {
  if (isFirstColumn) {
    return isMobileView ? "160px" : "200px";
  }
  return isMobileView ? "100px" : "136px";
};
 
export const StyledTableHead = styled(TableHead)(({ theme }) => ({
  "& th": {
    border: 0,
    borderBottom: `0.5px solid ${theme.palette.border?.secondary}`,
    borderRight: `0.5px solid ${theme.palette.border?.secondary}`,
  },
  "& th:first-child": {
    borderLeft: 0,
  },
  "& th:last-child": {
    borderRight: 0,
  },
}));
 
export const StyledHeaderCell = styled(TableCell)<{
  isFirstColumn?: boolean;
  isMobileView?: boolean;
}>(({ isFirstColumn, isMobileView }) => {
  const width = getCellWidth(isFirstColumn, isMobileView);
  return {
    width,
    minWidth: width,
    maxWidth: width,
  };
});
 
export const StyledTableRow = styled(TableRow)(({ theme }) => ({
  "& td": {
    borderRight: `0.5px solid ${theme.palette.border?.secondary}`,
    borderBottom: `0.5px solid ${theme.palette.border?.secondary}`,
  },
  "& td:first-child": {
    borderLeft: 0,
  },
  "& td:last-child": {
    borderRight: 0,
  },
  "&:last-child td": {
    borderBottom: 0,
  },
}));
 
export const StyledBodyCell = styled(TableCell)<{
  isFirstColumn?: boolean;
  isMobileView?: boolean;
}>(({ isFirstColumn, isMobileView }) => {
  const width = getCellWidth(isFirstColumn, isMobileView);
  return {
    padding: "12px 16px",
    width,
    minWidth: width,
    maxWidth: width,
  };
});
 
export const StyledIconButton = styled(IconButton)(() => ({
  boxShadow: "none",
  border: "none",
  background: "none",
  "&.MuiButtonBase-root": {
    "&.MuiButton-sizeSmall": {
      padding: "0px !important",
      height: "16px",
      width: "16px",
    },
  },
  "&:hover": {
    background: "none",
  },
}));
 
export const Container = styled(Stack)<{ isMobileView?: boolean }>(
  ({ theme, isMobileView }) => ({
    marginTop: isMobileView ? "32px" : "48px",
    marginBottom: "24px",
    borderRadius: `${theme.customs?.radius.small}px`,
    border: `0.5px solid ${theme.palette.border?.secondary}`,
    maxWidth: "90vw",
    overflowX: "auto",
  }),
);
 
export const StyledTable = styled(Table)<{
  isMobileView?: boolean;
  isScrolled?: boolean;
}>(({ theme, isMobileView, isScrolled }) => {
  const shadowColor = theme.palette.primitive?.shadow?.["shadow-left"];
 
  return {
    tableLayout: "fixed",
    border: "none",
    ...(isMobileView && {
      "& th:first-child, & td:first-child": {
        position: "sticky",
        left: 0,
        zIndex: 10,
        ...(isScrolled && {
          "&::after": {
            content: '""',
            position: "absolute",
            top: 0,
            right: 0,
            bottom: 0,
            width: "12px",
            pointerEvents: "none",
            boxShadow: `8px 0px 12px 0px ${shadowColor}`,
          },
        }),
      },
      "& thead th:first-child": {
        zIndex: 11,
        backgroundColor:
          theme.palette?.surface?.secondary || theme.palette.background?.paper,
      },
      // The sticky first column needs an opaque background or the scrolling
      // data columns show through it on mobile (garbled/overlapping labels).
      "& tbody td:first-child": {
        backgroundColor:
          theme.palette?.surface?.primary || theme.palette.background?.paper,
      },
    }),
  };
});
 
export const Image = styled("img")(() => ({
  height: 18,
  width: 28,
  display: "block",
  margin: "0 auto",
}));
 
//SettlementActions styles
export const DesktopContainer = styled(Box)({
  display: "flex",
  gap: "12px",
  marginTop: "24px",
  alignItems: "center",
  justifyContent: "space-between",
});
 
export const MobileContainer = styled(Box)({
  display: "flex",
  flexDirection: "column",
  marginTop: "24px",
  maxWidth: "90vw",
});
 
export const ScrollableRow = styled(Stack)({
  display: "flex",
  flexDirection: "row",
  gap: "12px",
  maxWidth: "100%",
  overflowX: "auto",
  overflowY: "hidden",
  flexWrap: "nowrap",
  WebkitOverflowScrolling: "touch",
  "&::-webkit-scrollbar": {
    display: "none",
  },
  scrollbarWidth: "none",
  msOverflowStyle: "none",
});
 
export const MobileRightActionsContainer = styled(Stack)({
  display: "flex",
  flexDirection: "row",
  gap: "12px",
  width: "100%",
});
 
export const FullWidthWrapper = styled(Box)({
  flex: 1,
  minWidth: 0,
  "& > *": {
    width: "100%",
  },
});
 
//DateSelectDropdownButton Style
export const StyledButton = styled(GiveButton)(({ theme }) => ({
  borderRadius: "40px",
  whiteSpace: "nowrap",
  border: "none",
  color: theme.palette.text.primary,
  minWidth: "auto",
  backgroundColor: theme.palette.primitive?.transparent?.["darken-5"],
  "&:hover": {
    backgroundColor: theme.palette.primitive?.transparent?.["darken-10"],
  },
}));