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 | 27x 27x 27x 81x 10x 21x 27x 27x 27x 27x 81x 10x | import { Grid, Stack } from "@mui/material";
import GiveProgressBar from "./GiveProgressBar";
import { GiveUnderwritingProgressItem } from "./GiveProgressBar.types";
import { CheckCircleIcon, CircleDashedIcon } from "@phosphor-icons/react";
import GiveText from "@shared/Text/GiveText";
import { useAppTheme } from "@theme/v2/Provider";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
interface GiveUnderwritingProgressBarProps {
completed: number;
incomplete: number;
disabled: number;
width?: string | number;
showStatus?: boolean;
}
export default function GiveUnderwritingProgressBar({
completed,
incomplete,
disabled,
width,
showStatus = true,
}: GiveUnderwritingProgressBarProps) {
const total = completed + incomplete + disabled;
const values: Record<string, GiveUnderwritingProgressItem> = {
completed: {
value: (100 * completed) / total,
variant: "completed",
type: "underwriting",
hidden: completed < 1,
},
incomplete: {
value: (100 * incomplete) / total,
variant: "incomplete",
type: "underwriting",
hidden: incomplete < 1,
},
disabled: {
value: (100 * disabled) / total,
variant: "disabled",
type: "underwriting",
hidden: disabled < 1,
},
};
return (
<Stack gap="12px">
<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) => (
<GiveProgressBar
key={item.variant}
value={item.value}
type={item.type}
variant={item.variant}
/>
))}
</Grid>
{showStatus && (
<ProgressStatus
completed={completed}
incomplete={incomplete}
disabled={disabled}
/>
)}
</Stack>
);
}
const ProgressStatus = ({
completed,
incomplete,
disabled,
}: GiveUnderwritingProgressBarProps) => {
const { palette } = useAppTheme();
const { isMobileView } = useCustomThemeV2();
const items = [
{
label: "Completed",
value: completed,
icon: (
<CheckCircleIcon
size={24}
color={palette.primitive?.success[50]}
weight="fill"
/>
),
hidden: completed < 1,
},
{
label: "Ready for confirmation",
value: incomplete,
icon: (
<CheckCircleIcon size={24} color={palette.primitive?.success[50]} />
),
hidden: incomplete < 1,
},
{
label: "Open",
value: disabled, // TODO: get correct values
icon: (
<CircleDashedIcon size={24} color={palette.icon?.["icon-secondary"]} />
),
hidden: disabled < 1,
},
];
return (
<Stack
direction={isMobileView ? "column" : "row"}
alignItems={isMobileView ? "flex-start" : "center"}
gap={isMobileView ? 1 : 3}
>
{items
.filter((item) => !item.hidden)
.map(({ icon, label, value }, index) => (
<Stack key={index} direction="row" alignItems="center" gap="4px">
{icon}
<GiveText
variant="bodyS"
color="secondary"
data-testid="progress-status"
>{`${label} (${value})`}</GiveText>
</Stack>
))}
</Stack>
);
};
|