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 | 8x 394x 394x 576x 394x 394x 394x 394x 394x | import { QKEY_LIST_ENTERPRISE_STATS } from "@constants/queryKeys";
import NiceModal from "@ebay/nice-modal-react";
import { useAppDispatch, useAppSelector } from "@redux/hooks";
import {
resetFilterByKey,
selectFiltersObject,
} from "@redux/slices/dynamicFilterSlice";
import { isEmpty } from "lodash";
import { countTopLevelDifferences } from "@utils/helpers";
import { defaultValuesProvidersFilter } from "@pages/AcquirerPortal/Enterprises/Modal/constants";
import { FILTER_PROVIDER_PANEL } from "modals/modal_names";
const useEnterpriseFilter = () => {
const dispatch = useAppDispatch();
const filterObject = useAppSelector((state) =>
selectFiltersObject(state, QKEY_LIST_ENTERPRISE_STATS),
);
const handleResetFilters = (event?: React.MouseEvent<HTMLElement>) => {
event?.stopPropagation();
dispatch(
resetFilterByKey({
filterKey: QKEY_LIST_ENTERPRISE_STATS,
}),
);
};
const handleOpenModal = () => NiceModal.show(FILTER_PROVIDER_PANEL);
const filtersAmount = isEmpty(filterObject)
? 0
: countTopLevelDifferences(filterObject, defaultValuesProvidersFilter);
const filterLabel =
filtersAmount > 0 ? `Filters (${filtersAmount})` : "Filter";
return {
handleResetFilters,
handleOpenModal,
filterLabel,
filtersAmount,
};
};
export default useEnterpriseFilter;
|