This commit is contained in:
Stefan Pejcic 2024-02-11 19:34:34 +01:00
parent e91e495668
commit e4b92c5134

View File

@ -59,18 +59,17 @@ const handleSurveyTextSubmit = async (text: string) => {
return; return;
} }
const surveyIdToUpdate = survey?.id; // Use the existing survey ID if available
const data = await updateSurvey({ const data = await updateSurvey({
surveyId: surveyIdToUpdate, surveyId: survey.id,
body: { response: selectedOption, responseText: text }, body: { response: selectedOption, responseText: text },
}); });
if (!data) return; if (!data) return;
setSurvey(data); setSurvey(data);
// when the user submits text feedback, we show a thank you message
setIsFinished(true); setIsFinished(true);
// reset the survey after N seconds so that the user can submit another survey
setTimeout(() => { setTimeout(() => {
setSelectedOption(null); setSelectedOption(null);
setSurvey(null); setSurvey(null);