Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored code. Progress bar now is empty on first step of intake. #759

Merged
15 changes: 5 additions & 10 deletions src/Components/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,17 @@ const ProgressBar = ({ step }: ProgressBarProps) => {
const { theme, formData } = useContext(Context);
const totalSteps = getStepDirectory(formData.immutableReferrer).length + STARTING_QUESTION_NUMBER;
const { id } = useParams();
let stepValue: number = 0;
if (step !== undefined) {
stepValue = step;
} else if (id !== undefined) {
stepValue = Number(id);
}

let stepValue = step ?? id ?? 0;
let progressPercentage: number = ((Number(stepValue) - 1) / totalSteps) * 100;

const progressBarStyles = {
marginBottom: '5px',
backgroundColor: '#d6d6d6c4',
border: '1px solid #B0B0B0',
borderRadius: '500rem;',
height: '1rem',
boxShadow: 'inset -1px 1px 3px rgb(0 0 0 / 0.2)',
'& .MuiLinearProgress-bar': {
background: `linear-gradient(90deg, ${theme.primaryColor} 0%, ${theme.secondaryColor} 100%)`,
background: theme.secondaryColor,
borderRadius: '500rem;',
},
};
Expand All @@ -39,7 +34,7 @@ const ProgressBar = ({ step }: ProgressBarProps) => {
<LinearProgress
sx={progressBarStyles}
variant="determinate"
value={(stepValue / totalSteps) * 100}
value={progressPercentage}
className="progress-bar"
aria-label="Progress Bar"
/>
Expand Down