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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 21x 32x 32x 21x | import { Box, Stack } from "@mui/material";
import { useAppTheme } from "@theme/v2/Provider";
import ChallengeLayout from "./ChallengeLayout";
import ImagesStacker from "features/Minibuilders/Conversations/utils/ImagesStacker";
import {
BellSimpleRingingIcon,
CaretRightIcon,
ChatsCircleIcon,
CheckCircleIcon,
CircleDashedIcon,
DotsThreeVerticalIcon,
XCircleIcon,
} from "@phosphor-icons/react";
import { CustomPalette } from "@theme/v2/palette.interface";
import { TChallange, TChallengeStatus } from "./types";
import GiveText from "@shared/Text/GiveText";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import GiveButton from "@shared/Button/GiveButton";
import { useNotifications } from "./hooks/useNotifications";
import GiveTooltip from "@shared/Tooltip/GiveTooltip";
import { useEnterprisePermissions } from "@components/AcquirerEnterprises/CreateEnterprise/hooks/useEnterprisePermissions";
import { ACTION_DENY_MESSAGE, NO_PAH_MESSAGE } from "@constants/permissions";
import { checkPortals } from "@utils/routing";
import { useMerchantSidePanelContext } from "@features/Merchants/MerchantSidePanel/Provider/MerchantSidePanelProvider";
interface Props {
challenge: TChallange;
isMerchantOnboarding?: boolean;
handleOpenMenu: (e: HTMLElement, challenge: TChallange) => void;
handleOpenConversation: ({
convTag,
challengeID,
}: {
convTag: string;
challengeID: number;
}) => void;
handleOpenChallenge: (
challenge: TChallange,
handleOpenConversation: () => void,
) => void;
isPAHAdded: number | "";
}
export default function ChallengeItem({
challenge,
isMerchantOnboarding,
handleOpenMenu,
handleOpenConversation,
handleOpenChallenge,
isPAHAdded,
}: Props) {
const {
data: {
merchantInfo: { merchantID },
status: { statusName },
},
} = useMerchantSidePanelContext();
const { openNotifyMerchantModal } = useNotifications({
merchantID,
statusName,
});
const { isEnterprisePortal } = checkPortals();
const { merchant_underwriting } = useEnterprisePermissions();
const { palette } = useAppTheme();
const isMerchantNotified = Boolean(challenge.notifiedAt);
const isEDD = challenge.categoryName === "enhanced_due_diligence";
const convTag = challenge.merchantDisplayTitle || challenge.name;
const isDisabledConversation = isEnterprisePortal && !merchant_underwriting;
const handleOpenNotifiaction = () => {
openNotifyMerchantModal({
challengeTypeName: challenge?.challengeTypeName,
challengeID: challenge?.id,
topicName: challenge?.merchantDisplayTitle,
defaultMessage: challenge?.predefinedReason ?? undefined,
hideInputs: ["module"],
});
};
const handleOpen = () => {
if (isMerchantOnboarding) return;
const openConv = () =>
handleOpenConversation({
convTag: convTag,
challengeID: challenge.id,
});
handleOpenChallenge(challenge, openConv);
};
const isOptional = challenge.name === "bank_account_connected_with_plaid";
return (
<ChallengeLayout
icon={getStatusIcons(challenge.statusName, palette)}
applyIconBG={false}
alwaysShowConversation
horizontalPadding="8px"
attachConversations={
<Stack direction="row" alignItems="center">
<Box width="100%">
<ImagesStacker data={challenge.userAvatarsInThread || []} />
</Box>
<GiveTooltip
width="compact"
alignment="left"
title={ACTION_DENY_MESSAGE}
color="default"
disableHoverListener={!isDisabledConversation}
>
<GiveIconButton
Icon={ChatsCircleIcon}
variant="ghost"
disabled={isDisabledConversation}
onClick={(e) => {
e.stopPropagation();
handleOpenConversation({ convTag, challengeID: challenge.id });
}}
/>
</GiveTooltip>
</Stack>
}
main={
<Stack>
<GiveText
variant="bodyS"
sx={{
color: palette.primitive?.neutral[90],
}}
>
{isEDD ? challenge.name : challenge.merchantDisplayTitle}
{isOptional ? " (Optional)" : ""}
</GiveText>
<Stack direction="row" gap="6px" alignItems="center">
<GiveText
variant="bodyXS"
color={
challenge.statusName === "rejected" ? "error" : "secondary"
}
pr="10px"
>
{StatusDisplayName[challenge.statusName as TChallengeStatus]}
</GiveText>
{isMerchantNotified && (
<>
<BellSimpleRingingIcon size={16} color={palette.text.secondary} />
<GiveText variant="bodyXS" color="secondary">
Merchant Notified
</GiveText>
</>
)}
</Stack>
</Stack>
}
end={
isMerchantOnboarding ? (
<GiveTooltip
width="compact"
alignment="left"
title={
isDisabledConversation ? ACTION_DENY_MESSAGE : NO_PAH_MESSAGE
}
color="default"
disableHoverListener={!!isPAHAdded && !isDisabledConversation}
>
<GiveButton
label="Notify"
size="small"
color="light"
variant="filled"
disabled={!isPAHAdded || isDisabledConversation}
sx={{ border: "none" }}
onClick={(e) => {
e.stopPropagation();
handleOpenNotifiaction();
}}
/>
</GiveTooltip>
) : (
<Stack direction="row" gap="8px" alignItems="center">
<GiveIconButton
Icon={DotsThreeVerticalIcon}
variant="ghost"
onClick={(e) => {
e.stopPropagation();
handleOpenMenu(e.currentTarget, challenge);
}}
/>
<GiveIconButton
Icon={CaretRightIcon}
variant="ghost"
size="small"
onClick={handleOpen}
/>
</Stack>
)
}
onClick={handleOpen}
/>
);
}
const getStatusIcons = (status: TChallengeStatus, palette: CustomPalette) => {
const icons = {
closed: (
<CheckCircleIcon
size={24}
color={palette.primitive?.success[50]}
weight="fill"
/>
),
ready_for_verification: (
<CheckCircleIcon size={24} color={palette.primitive?.success[50]} />
),
open: <CircleDashedIcon size={24} color={palette.icon?.["icon-secondary"]} />,
rejected: (
<XCircleIcon size={24} color={palette.primitive?.error["50"]} weight="fill" />
),
};
return icons[status];
};
const StatusDisplayName = {
closed: "Completed",
ready_for_verification: "Ready for Confirmation",
open: "Open",
rejected: "Rejected",
};
|