All files / src/pages/AcquirerPortal/Enterprises AcquirerEnterprises.tsx

90.9% Statements 10/11
40% Branches 2/5
100% Functions 3/3
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                      4x                   114x   114x 174x     114x   114x   114x   114x     114x   84x                                                    
import { useListEnterprisesStats } from "@hooks/acquirer-api/merchants";
import { useGetCurrentMerchantId, useMasqueradeRedirect } from "@hooks/common";
import { PortalRootContainer } from "@components/Layout/Layout";
import { useAppSelector } from "@redux/hooks";
import { NotAuthorizedWrapper } from "@containers/NotAuthorizedWrapper";
import { ConnectionErrorState } from "@common/EmptyState";
import EnterprisesTable from "features/Enterprises/EnterprisesTable/EnterprisesTable";
import { useAppTheme } from "@theme/v2/Provider";
import { QKEY_LIST_ENTERPRISE_STATS } from "@constants/queryKeys";
import { STORED_PROVIDER_ROWS_PER_PAGE } from "@constants/stringConstants";
 
export const AcquirerEnterprisesPage = () => {
  const {
    allRows,
    totalRows,
    page,
    setPage,
    isLoading,
    setPageDispatcher,
    rowsPerPage,
    state: { isError },
  } = useListEnterprisesStats();
 
  const hasNotMerchantsListPermission = useAppSelector(
    (state) => state.app.permissions?.enterprises_list,
  );
 
  const { isSponsor } = useGetCurrentMerchantId();
 
  const { palette } = useAppTheme();
 
  useMasqueradeRedirect();
 
  Iif (isError && !hasNotMerchantsListPermission && !isLoading)
    return <ConnectionErrorState />;
 
  return (
    <PortalRootContainer
      sx={(theme) => ({
        [theme.breakpoints.down("new_sm")]: {
          gap: "0 !important",
        },
        alignItems: "center",
        backgroundColor: palette.surface?.primary,
      })}
    >
      <NotAuthorizedWrapper notAuthorized={hasNotMerchantsListPermission}>
        <EnterprisesTable
          type="provider"
          allRows={allRows}
          isLoading={isLoading}
          totalRows={totalRows}
          rowsPerPage={rowsPerPage}
          page={page}
          setPageDispatcher={setPageDispatcher}
          setPage={setPage}
          queryKey={QKEY_LIST_ENTERPRISE_STATS}
          storageKey={STORED_PROVIDER_ROWS_PER_PAGE}
          isSponsor={isSponsor}
        />
      </NotAuthorizedWrapper>
    </PortalRootContainer>
  );
};