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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | 63x 79x 79x 79x 79x 79x 1x 1x 1x 79x 1x | import { Stack } from "@mui/material";
import { MouseEvent } from "react";
import { WithTooltipWrapper } from "@common/Menu/NewDropdownMenu";
import {
DELETE_DENY_MESSAGE,
Edit_DENY_BY_OFAC_V2,
} from "@constants/permissions";
import { TOwnerFile } from "@components/Merchants/MerchantPreview/components/PrimaryAccountHolder/types";
import { TMerchantDocument } from "@components/Merchants/MerchantPreview/data.types";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import { DownloadSimpleIcon, EyeIcon, TrashIcon } from "@phosphor-icons/react";
import { useAppTheme } from "@theme/v2/Provider";
import { useEnterprisePermissions } from "@components/AcquirerEnterprises/CreateEnterprise/hooks/useEnterprisePermissions";
import { checkPortals } from "@utils/routing";
type Props = {
type: TOwnerFile;
downloadHandler: (
documentData?: TMerchantDocument | undefined,
) => Promise<void>;
deleteDocument?: () => void;
previewDocument: () => void;
disabled?: {
download?: boolean;
delete?: boolean;
preview?: boolean;
};
hidden?: {
download?: boolean;
delete?: boolean;
preview?: boolean;
};
isBusinessOwnerModal?: boolean;
isOFACMatch?: boolean;
};
const IDUploaderActions = ({
downloadHandler,
deleteDocument,
previewDocument,
disabled,
hidden,
type,
isBusinessOwnerModal,
isOFACMatch,
}: Props) => {
const { modify_merchant } = useEnterprisePermissions();
const { isEnterprisePortal } = checkPortals();
const isHidden = isEnterprisePortal && !modify_merchant;
const theme = useAppTheme();
const actionToDo = (
e: MouseEvent<HTMLDivElement>,
action: () => void,
disabled = false,
) => {
e.stopPropagation();
Iif (disabled) return;
action();
};
return (
<>
<Stack
className="pah-uploader-actions"
direction="row"
gap={0.5}
alignItems="center"
>
{hidden?.preview || (
<GiveIconButton
data-testid="view-id-file-btn"
variant="ghost"
Icon={EyeIcon}
disabled={disabled?.preview}
onClick={(e: any) =>
actionToDo(e, previewDocument, disabled?.preview)
}
sx={{ backgroundColor: theme.palette.neutral.white }}
hidden={hidden?.preview}
/>
)}
{!isHidden && (
<>
{hidden?.download || (
<GiveIconButton
data-testid="download-id-file-btn"
variant="ghost"
Icon={DownloadSimpleIcon}
disabled={disabled?.download}
onClick={(e: any) => {
actionToDo(e, downloadHandler, disabled?.download);
}}
sx={{ backgroundColor: theme.palette.neutral.white }}
hidden={hidden?.download}
/>
)}
{hidden?.delete ||
((type != "businessOwnerID" || isBusinessOwnerModal) &&
deleteDocument && (
<WithTooltipWrapper
hasTooltip={Boolean(disabled?.delete)}
tooltipProps={{
show: Boolean(disabled?.delete),
message: isOFACMatch
? Edit_DENY_BY_OFAC_V2
: DELETE_DENY_MESSAGE,
}}
>
<GiveIconButton
data-testid="delete-id-file-btn"
variant="ghost"
Icon={TrashIcon}
disabled={disabled?.delete}
onClick={(e: any) => {
actionToDo(e, deleteDocument, disabled?.delete);
}}
sx={{ backgroundColor: theme.palette.neutral.white }}
hidden={true}
/>
</WithTooltipWrapper>
))}
</>
)}
</Stack>
</>
);
};
export default IDUploaderActions;
|