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 | 165x 165x 165x 24x 6x 21x 165x 165x 165x 165x 660x 165x 422x | import { Grid, Stack, Skeleton } from "@mui/material";
import {
CheckCircleIcon,
CircleIcon,
CircleDashedIcon,
} from "@phosphor-icons/react";
import GiveText from "@shared/Text/GiveText";
import { useAppTheme } from "@theme/v2/Provider";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import KYBIcon from "@assets/APRIcons/KYBIcon";
import UnderwritingIcon from "@assets/APRIcons/UnderwritingIcon";
import GiveProgressBarV2 from "./GiveProgressbarV2";
import { GiveUnderwritingProgressItem } from "@shared/ProgressBar/GiveProgressBar.types";
interface GiveUnderwritingProgressBarProps {
completed: number;
incomplete: number;
incomplete2: number;
disabled: number;
width?: string | number;
showStatus?: boolean;
label: any;
isPendingView?: boolean;
hasData?: boolean;
}
export default function GiveUnderwritingProgressBarV2({
completed,
incomplete,
incomplete2,
disabled,
width,
showStatus = true,
label,
isPendingView = false,
hasData = true,
}: GiveUnderwritingProgressBarProps) {
const total = completed + incomplete + incomplete2 + disabled;
const values: Record<string, GiveUnderwritingProgressItem> = {
completed: {
value: (100 * completed) / total,
variant: "completed",
type: label,
hidden: completed < 1,
},
incomplete: {
value: (100 * incomplete) / total,
variant: "incomplete",
type: label,
hidden: incomplete < 1,
},
incomplete2: {
value: (100 * incomplete2) / total,
variant: "incomplete2",
type: label,
hidden: incomplete2 < 1,
},
disabled: {
value: (100 * disabled) / total,
variant: "disabled",
type: label,
hidden: disabled < 1,
},
};
return (
<Stack gap="12px">
{!hasData ? (
<Skeleton
variant="rectangular"
height={8}
width="100%"
sx={{ borderRadius: "8px" }}
/>
) : (
<Grid
container
p="0px !important"
m="0px !important"
alignItems="center"
justifyContent="space-between"
wrap="nowrap"
width={width}
flex={1}
>
{Object.values(values)
.filter((item) => !item.hidden)
.map((item) => (
<GiveProgressBarV2
key={item.variant}
value={item.value}
type={item.type}
variant={item.variant}
borderRadius={8}
/>
))}
</Grid>
)}
{showStatus && (
<ProgressStatus
completed={completed}
incomplete={incomplete}
incomplete2={incomplete2}
disabled={disabled}
label={label}
isPendingView={isPendingView}
hasData={hasData}
/>
)}
</Stack>
);
}
const ProgressStatus = ({
completed,
incomplete,
incomplete2,
disabled,
label,
isPendingView,
hasData = true,
}: GiveUnderwritingProgressBarProps) => {
const { palette } = useAppTheme();
const { isMobileView } = useCustomThemeV2();
const CompletedIcon = isPendingView ? (
<CircleIcon size={24} color={palette.primitive?.success[50]} />
) : (
<CheckCircleIcon
size={24}
color={palette.primitive?.success[50]}
weight="fill"
/>
);
const statusesList = [
{
label: "Completed",
value: completed,
hidden: label === "KYB" && completed < 1,
icon: CompletedIcon,
},
{
label: "Ready for Underwriting",
value: incomplete,
hidden: isPendingView,
icon: <UnderwritingIcon />,
},
{
label: "In Progress",
value: incomplete2,
hidden:
(["Sponsor", "Underwriting"].includes(label) && incomplete2 < 1) ||
isPendingView,
icon: <KYBIcon />,
},
{
label: isPendingView ? "Open" : "Ready for KYB",
value: disabled,
hidden: label === "Sponsor" && disabled < 1,
icon: (
<CircleDashedIcon size={24} color={palette.icon?.["icon-secondary"]} />
),
},
];
const filteredStatusesList = statusesList.filter((item) => !item.hidden);
return (
<Stack
direction={isMobileView ? "column" : "row"}
alignItems={isMobileView ? "flex-start" : "center"}
flexWrap={filteredStatusesList?.length === 4 ? "wrap" : "nowrap"}
gap={2}
>
{filteredStatusesList.map(({ icon, label, value }, index) => (
<Stack key={index} direction="row" alignItems="center" gap="4px">
{icon}
<GiveText
variant="bodyS"
color="secondary"
data-testid="progress-status"
sx={{ whiteSpace: "nowrap" }}
>
{`${label} (${hasData ? value : "-"})`}
</GiveText>
</Stack>
))}
</Stack>
);
};
|