mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 02:10:12 -06:00
fix: do not create a display if the survey is in preview mode (#304)
This commit is contained in:
@@ -30,9 +30,14 @@ export default function LinkSurvey({ survey }: LinkSurveyProps) {
|
||||
const [responseId, setResponseId] = useState<string | null>(null);
|
||||
const [displayId, setDisplayId] = useState<string | null>(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);
|
||||
|
||||
Reference in New Issue
Block a user