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 | 1x 6x 6x 6x 6x 6x 6x 6x 6x | import { useGetEnterpriseConfigurationById } from "@features/Merchants/MerchantSidePanel/Modals/ProviderConfigurationModal/hooks/useGetEnterpriseConfigurationById";
import useMasqueradeReducer from "@hooks/Reducers/useMasqueradeReducer";
import { useGetCurrentMerchantId } from "@hooks/common";
import { useAppDispatch, useAppSelector } from "@redux/hooks";
import { selectUser } from "@redux/slices/auth/auth";
import { updateEnterpriseConfiguration } from "@redux/slices/enterprise/enterpriseSettings";
import { checkPortals } from "@utils/routing";
export const useGetEnterpriseConfiguration = () => {
const dispatch = useAppDispatch();
const { merchantId } = useGetCurrentMerchantId();
const auth = useAppSelector(selectUser);
const { isEnterprisePortal } = checkPortals();
const { isMasqueradeMode } = useMasqueradeReducer();
const isMasqueradeEnterprise =
isMasqueradeMode && auth?.role === "acquirer" && isEnterprisePortal;
const query = useGetEnterpriseConfigurationById(merchantId, {
onSuccess: (data) => {
if (data?.data) {
const permissionsOfEnterprise = data?.data?.reduce(
(acc: any, curr: any) => {
return {
...acc,
[curr.name]: curr.isActive,
};
},
{},
);
dispatch(updateEnterpriseConfiguration(permissionsOfEnterprise));
}
},
// TODO: check useless api call of acquirer
enabled:
(!!merchantId && auth.role === "provider") || isMasqueradeEnterprise,
});
return query;
};
|