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 | 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x 6x | import { useGetBusinessProfileData } from "@components/Settings/BusinessDetails/RebrandedBusinessProfile/hooks/useBusinessProfileV2";
import { useGetMerchantById } from "@hooks/enterprise-api/account/useGetMerchants";
import NiceModal from "@ebay/nice-modal-react";
import { BUSINESS_PROFILE_LINK_REQUEST_MODAL } from "modals/modal_names";
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import useNotificationActions from "@features/GiveNotificationModal/hooks/useNotificationActions";
import {
composePermission,
useAccessControl,
} from "@features/Permissions/AccessControl";
import RESOURCE_BASE, { OPERATIONS } from "@constants/permissions";
export const useRedirectLinkBPRequestReview = () => {
const location = useLocation();
const searchParams = new URLSearchParams(location.search);
const { data } = useGetMerchantById({ enabled: true });
const { markAsReadMutation } = useNotificationActions();
const isAllowedReadOwner = useAccessControl({
withPortal: true,
resource: composePermission(
RESOURCE_BASE.LEGAL_ENTITY,
RESOURCE_BASE.PRINCIPAL,
),
operation: OPERATIONS.READ,
});
const { data: legalEntityData } = useGetBusinessProfileData({
legalEntityID: data?.legalEntityID,
enabled: !!data?.legalEntityID && isAllowedReadOwner,
});
const merchantAccID = searchParams.get("accountID");
const merchantName = searchParams.get("merchantName");
const controllerID = searchParams.get("controllerID");
const notificationID = searchParams.get("notificationID");
const handleReviewLinkRequest = () => {
NiceModal.show(BUSINESS_PROFILE_LINK_REQUEST_MODAL, {
accID: legalEntityData?.controllerID,
merchantAccID: Number(merchantAccID),
merchantName,
});
};
useEffect(() => {
const isBusinessProfileController =
controllerID && legalEntityData?.controllerID === Number(controllerID);
Eif (!isBusinessProfileController) {
return;
}
if (merchantAccID && merchantName) {
// TODO: BE will need to send this id so we can mark as read
notificationID && markAsReadMutation.mutate([Number(notificationID)]);
handleReviewLinkRequest();
}
}, [merchantAccID, merchantName, legalEntityData]);
return {};
};
|