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 | 37x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 3x 3x 3x 3x 3x 3x | import React, { useEffect } from "react";
import { useBulkMarkMerchants } from "@components/AcquirerMerchants/hooks/useBulkMarkMerchants";
import { useAppDispatch, useAppSelector } from "@redux/hooks";
import { resetMarkedMerchants } from "@redux/slices/enterprise/merchants";
import useCheckSponsor from "@hooks/common/useCheckSponsor";
import { ACTION_DENY_MESSAGE } from "@constants/permissions";
import { useGetBackgroundTaskStatus } from "@components/AcquirerMerchants/hooks/useGetBackgroundTaskStatus";
import GiveCheckbox from "@shared/GiveCheckbox/GiveCheckbox";
import { CustomToolTip } from "./CustomTooltip";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { selectedQueryString } from "@redux/slices/tableFilters";
import {
AUTO_APPROVAL_QUERY,
AUTO_APPROVAL_QUERY_REFACTORED,
PRE_APPROVAL_QUERY,
PRE_APPROVAL_QUERY_REFACTORED,
} from "@shared/constants";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
const MarkAllCheckBox = () => {
const { isMerchantStatusRefactorEnabled } = useGetFeatureFlagValues();
const {
isMarkAllChecked,
toggleBulkMark,
preApprovalCount,
autoApprovalCount,
readyForReviewCount,
} = useBulkMarkMerchants();
const { isMobileView } = useCustomThemeV2();
const dispatch = useAppDispatch();
const queryString = useAppSelector(selectedQueryString);
const { hasSponsorAccess } = useCheckSponsor();
useGetBackgroundTaskStatus({ enabled: true });
useEffect(() => {
// reset marked merchants on page exit
return () => {
dispatch(resetMarkedMerchants({}));
};
}, []);
const autoApprovalKey = isMerchantStatusRefactorEnabled
? AUTO_APPROVAL_QUERY_REFACTORED
: AUTO_APPROVAL_QUERY;
const preApprovalKey = isMerchantStatusRefactorEnabled
? PRE_APPROVAL_QUERY_REFACTORED
: PRE_APPROVAL_QUERY;
const disableOnAutoApproval =
queryString === autoApprovalKey && autoApprovalCount === 0;
const disableOnPreApproval =
queryString === preApprovalKey && preApprovalCount === 0;
const isDisabled =
!hasSponsorAccess ||
readyForReviewCount === 0 ||
disableOnAutoApproval ||
disableOnPreApproval;
return (
<CustomToolTip
message={ACTION_DENY_MESSAGE}
showToolTip={!hasSponsorAccess}
onClick={(e) => e.stopPropagation()}
placement={isMobileView ? "bottom" : "bottom-end"}
customTooltipStyles={{
"&.MuiStack-root": {
zIndex: 10,
width: "auto",
cursor: isDisabled ? "default" : "pointer",
pointerEvents: "auto",
},
}}
>
<GiveCheckbox
size="medium"
sx={{
cursor: "pointer",
"& .MuiCheckbox-root": {
pointerEvents: "auto",
},
marginRight: "8px",
}}
onClick={(e) => e.stopPropagation()}
onChange={(e) => toggleBulkMark && toggleBulkMark(e.target.checked)}
disabled={isDisabled}
aria-disabled={false}
checked={isMarkAllChecked}
data-testid="mark-all-checkbox-v2"
/>
</CustomToolTip>
);
};
export default React.memo(MarkAllCheckBox);
|