diff --git a/apps/web/app/s/[surveyId]/LinkSurvey.tsx b/apps/web/app/s/[surveyId]/LinkSurvey.tsx index a265fb5c0e..68dcc519bd 100644 --- a/apps/web/app/s/[surveyId]/LinkSurvey.tsx +++ b/apps/web/app/s/[surveyId]/LinkSurvey.tsx @@ -30,9 +30,14 @@ export default function LinkSurvey({ survey }: LinkSurveyProps) { const [responseId, setResponseId] = useState(null); const [displayId, setDisplayId] = useState(null); + const isPreview = new URLSearchParams(window.location.search).get("preview") === "true"; + useEffect(() => { if (survey) { setCurrentQuestion(survey.questions[0]); + + if (isPreview) return; + // create display createDisplay( { surveyId: survey.id }, @@ -42,7 +47,7 @@ export default function LinkSurvey({ survey }: LinkSurveyProps) { setDisplayId(display.id); }); } - }, [survey]); + }, [survey, isPreview]); useEffect(() => { if (currentQuestion && survey) { @@ -55,8 +60,6 @@ export default function LinkSurvey({ survey }: LinkSurveyProps) { } }, [currentQuestion, survey]); - const isPreview = new URLSearchParams(window.location.search).get("preview") === "true"; - const restartSurvey = () => { setCurrentQuestion(survey.questions[0]); setProgress(0);