import { Box, Text, useFlow } from '@frigade/react';
import { ChevronRight } from 'lucide-react';
export function ProgressBadge() {
const flowId = 'flow_RgilNasCrSBQmrVM';
const { flow } = useFlow(flowId);
const stepsCompleted = flow?.getNumberOfCompletedSteps();
const totalSteps = flow?.getNumberOfAvailableSteps();
if (!flow) {
return null;
}
// This flag is automatically set to false if the Flow is not visible to the user.
// Flows will automatically be hidden if the user has already
// finished the Flow or if they don't fit the audience.
if (!flow.isVisible) {
return null;
}
return (
<Box
display="flex"
flexDirection="column"
border="md"
borderRadius="md"
borderColor="neutral.border"
py={2}
px={3}
gap={1}
>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
>
<Box display="flex">
<Text.Body2
fontWeight="medium"
color="--fr-colors-x-sub-header-text"
>
Getting started
</Text.Body2>
</Box>
<Box display="flex">
<ChevronRight />
</Box>
</Box>
<Box
display="flex"
flexDirection="row"
justifyContent="center"
alignItems="center"
gap={2}
>
<Box display="flex" alignItems="center">
<Text.Caption
fontWeight="medium"
>
{stepsCompleted}/{totalSteps}
</Text.Caption>
</Box>
<Box
display="flex"
gap={1}
justifyContent="space-between"
alignItems="center"
width="100%"
>
{Array.from({ length: totalSteps }, (_, i) => {
const stepNumber = i + 1;
const isCompleted = stepNumber <= stepsCompleted;
return (
<Box
key={i}
backgroundColor={
isCompleted
? 'blue'
: 'grey'
}
borderRadius="md"
height="9px"
width="100%"
display="flex"
/>
);
})}
</Box>
</Box>
</Box>
);
}