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 | 481x 481x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 11x 481x 55x 55x 55x 481x | import { Box, Stack, useMediaQuery } from "@mui/material";
import { Text } from "@common/Text";
import { palette } from "@palette";
import { Tooltip } from "@common/Tooltip";
import { UPDAT_DENY_BY_OFAC } from "@constants/permissions";
import GiveTooltip from "@shared/Tooltip/GiveTooltip";
import { Theme } from "@mui/material";
export const STATUS_ENUM = {
INCOMPLETE: "INCOMPLETE",
APPROVED: "APPROVED",
UNDER_VERIFICATION: "UNDER_VERIFICATION",
} as const;
export type HomepageCardStatus = (typeof STATUS_ENUM)[keyof typeof STATUS_ENUM];
type TStepsRecapOptions = {
title: string;
onClick?: () => void;
hidden?: boolean;
isLocked?: boolean;
datatestID?: string;
status?: HomepageCardStatus;
isUnderVerification?: boolean;
isSuspended?: boolean;
isIncomplete?: boolean;
tooltipProps?: {
show: boolean;
message: string;
placement: any;
};
};
const HomepageCard = ({
title,
onClick,
hidden,
isLocked,
datatestID,
status,
isSuspended,
isIncomplete,
tooltipProps,
}: TStepsRecapOptions) => {
const isMobileView = useMediaQuery(
(theme: Theme) => theme.breakpoints.down("new_sm"),
{ noSsr: true },
);
const isApproved = STATUS_ENUM.APPROVED === status;
const isUnderVerification = STATUS_ENUM.UNDER_VERIFICATION === status;
const interactable = !isLocked && !isSuspended;
const isAgreementCard = title === "Sign Agreement";
const approvedLabel = isAgreementCard ? "Signed" : "Approved";
const isShowIncompleteTag =
isIncomplete && !isApproved && !isUnderVerification && !isSuspended;
const { show, message, placement } = tooltipProps || {};
return (
<GiveTooltip
disableHoverListener={!show}
title={message}
placement={placement}
>
<Stack
width="100%"
direction={isMobileView ? "column" : "row"}
alignItems={isMobileView ? "flex-start" : "center"}
data-testid={datatestID}
gap="8px"
sx={{
padding: "16px",
border: `1px solid ${palette.liftedWhite[200]}`,
borderRadius: "8px",
position: "relative",
cursor: "default",
...(interactable && {
cursor: "pointer",
}),
...(hidden && {
display: "none",
}),
"&:hover": !isLocked
? {
backgroundColor: "#fff",
boxShadow: "1px 1px 15px 0px rgba(161, 175, 180, 0.10)",
}
: null,
}}
onClick={() => {
Eif (interactable && onClick) onClick();
}}
>
<Text
variant="body"
color={palette.black[100]}
align="left"
sx={{ opacity: interactable ? 1 : 0.5 }}
fontSize="18px"
flexGrow={1}
>
{title}
</Text>
<Box>
{isApproved && !isSuspended && <Tag label={approvedLabel} />}
{isUnderVerification && !isSuspended && (
<Tag label="Under verification" />
)}
{isShowIncompleteTag && <Tag label="Incomplete" />}
{/* {isLocked && isIncomplete && !isSuspended && (
<LockIcon datatestID="lock_icon_test_id" />
)} */}
{isSuspended && (
<Tooltip title={UPDAT_DENY_BY_OFAC} placement="top">
<Tag label="Suspended" />
</Tooltip>
)}
</Box>
</Stack>
</GiveTooltip>
);
};
type TagProps = {
label:
| "Approved"
| "Completed"
| "Suspended"
| "Under verification"
| "Signed"
| "Incomplete";
};
const Tag = ({ label }: TagProps) => {
const isMobileView = useMediaQuery(
(theme: Theme) => theme.breakpoints.down("new_sm"),
{ noSsr: true },
);
return (
<Box
sx={{
display: "flex",
padding: "2px 24px",
alignItems: "center",
borderRadius: "100px",
background: tagMap[label].background,
userSelect: "none",
whiteSpace: "nowrap",
}}
>
<Text
color={tagMap[label].color}
variant={isMobileView ? "bodyXS" : "body"}
fontWeight="book"
textTransform="capitalize"
>
{label}
</Text>
</Box>
);
};
const tagMap = {
Approved: {
background: "#E6F3EC",
color: palette.filled.success,
},
Signed: {
background: "#E6F3EC",
color: palette.filled.success,
},
Completed: {
background: "#E6F3EC",
color: palette.filled.success,
},
Suspended: {
background: palette.tag.warning.bg,
color: palette.tag.warning.hover,
},
"Under verification": {
background: "#E6EAF2",
color: palette.filled.blue,
},
Incomplete: {
background: palette.tag.warning.bg,
color: palette.tag.warning.hover,
},
};
export default HomepageCard;
|