mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 02:10:12 -06:00
fix: progress bar on welcome card (#3006)
This commit is contained in:
committed by
GitHub
parent
4ebe144191
commit
3dc3edb83e
@@ -13,7 +13,7 @@ export const ProgressBar = ({ survey, questionId }: ProgressBarProps) => {
|
||||
() => survey.questions.findIndex((q) => q.id === questionId),
|
||||
[survey, questionId]
|
||||
);
|
||||
const questionIds = useMemo(() => survey.questions.map((question) => question.id), [survey.questions]);
|
||||
const endingCardIds = useMemo(() => survey.endings.map((ending) => ending.id), [survey.endings]);
|
||||
|
||||
const calculateProgress = useCallback(
|
||||
(index: number, questionsLength: number) => {
|
||||
@@ -30,11 +30,15 @@ export const ProgressBar = ({ survey, questionId }: ProgressBarProps) => {
|
||||
return survey.questions.map((_, index) => calculateProgress(index, survey.questions.length));
|
||||
}, [calculateProgress, survey]);
|
||||
|
||||
return (
|
||||
<Progress
|
||||
progress={
|
||||
!questionIds.includes(questionId) ? 1 : questionId === "start" ? 0 : progressArray[currentQuestionIdx]
|
||||
}
|
||||
/>
|
||||
);
|
||||
const progressValue = useMemo(() => {
|
||||
if (questionId === "start") {
|
||||
return 0;
|
||||
} else if (endingCardIds.includes(questionId)) {
|
||||
return 1;
|
||||
} else {
|
||||
return progressArray[currentQuestionIdx];
|
||||
}
|
||||
}, [questionId, endingCardIds, progressArray, currentQuestionIdx]);
|
||||
|
||||
return <Progress progress={progressValue} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user