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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 21x 26x 26x 26x 26x 26x 26x 15x 14x 14x 1x 1x 1x 26x | import { Stack, Box } from "@mui/material";
import { ArrowRightIcon } from "@phosphor-icons/react";
import { StyledGiveButton } from "./UnderwritingCard.style";
import { CustomToolTip as PermissionTooltip } from "componentsV2/Table/CustomTooltip";
import { ACTION_DENY_MESSAGE } from "@constants/permissions";
import { useUnderwriterPermissions } from "features/Permissions/AccessControl/hooks";
import GiveAssignButton from "@shared/AssignButton/GiveAssignButton";
import { useMerchantSidePanelContext } from "@features/Merchants/MerchantSidePanel/Provider/MerchantSidePanelProvider";
import { useMemo } from "react";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
import useAssigneeManagedByAcquirer from "@hooks/useAssigneeManagedByAcquirer";
import { checkPortals } from "@utils/routing";
type TUnderwritingCardBody = {
underwriterName?: string;
underwriterEmail?: string;
underwriterImageURL?: string;
underwriterSetByAcquirer?: boolean;
underwriterID?: number;
handleManageUnderwriting?: () => void;
id: number;
isOnboarding: boolean;
isKYB?: boolean;
handleChangeAssignee?: (
oldAssignee: number | undefined,
newAssignee: string,
assigneeType?: string,
onSuccess?: () => void,
) => void;
};
const UnderwritingCardBody = ({
underwriterName,
underwriterEmail,
underwriterImageURL,
handleManageUnderwriting,
underwriterSetByAcquirer,
underwriterID,
id,
isOnboarding,
isKYB,
handleChangeAssignee,
}: TUnderwritingCardBody) => {
const { isViewUnderwritingAllowed } = useUnderwriterPermissions();
const { isNewApprovalFlowEnabled } = useGetFeatureFlagValues();
const { isSponsorView } = useMerchantSidePanelContext();
const { isEnterprisePortal } = checkPortals();
const { isManagedByAcquirer } = useAssigneeManagedByAcquirer({
underwriterSetByAcquirer: Boolean(underwriterSetByAcquirer),
});
const assigneesType = useMemo(() => {
if (!isNewApprovalFlowEnabled) {
Iif (isOnboarding) return "sales";
return "underwriting_admin";
}
Iif (isKYB) return "kyb";
Iif (isSponsorView) return "sponsor";
return "underwriting_admin";
}, [isNewApprovalFlowEnabled, isOnboarding, isKYB, isSponsorView]);
return (
<Stack direction="row" justifyContent="space-between" gap="16px">
{isManagedByAcquirer || isEnterprisePortal ? (
<div />
) : (
<Box
display="flex"
alignItems="center"
sx={{
"& > div": {
marginBottom: 0,
},
}}
>
<GiveAssignButton
title="Assign"
type={assigneesType}
data={{
accID: id,
underwriterName,
underwriterImageURL,
underwriterEmail,
underwriterSetByAcquirer,
underwriterID,
}}
showCaretIcon={false}
onChange={handleChangeAssignee}
/>
</Box>
)}
{handleManageUnderwriting && (
<PermissionTooltip
showToolTip={!isViewUnderwritingAllowed}
message={ACTION_DENY_MESSAGE}
placement="top"
alignment="end"
fluidWidth
>
<StyledGiveButton
variant="filled"
label={isKYB ? "KYB" : isOnboarding ? "Onboarding" : "Underwriting"}
endIcon={<ArrowRightIcon />}
onClick={handleManageUnderwriting}
disabled={!isViewUnderwritingAllowed}
/>
</PermissionTooltip>
)}
</Stack>
);
};
export default UnderwritingCardBody;
|