fix: default autocomplete value (#1986)

Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Dhruwang Jariwala
2024-02-01 15:00:17 +05:30
committed by GitHub
parent 1402f4a48b
commit b7250a284a
2 changed files with 5 additions and 13 deletions
@@ -257,12 +257,12 @@ export default function ResponseOptionsCard({
surveyClosedMessage.subheading,
]);
const handleCheckMark = () => {
const toggleAutocomplete = () => {
if (autoComplete) {
const updatedSurvey = { ...localSurvey, autoComplete: null };
setLocalSurvey(updatedSurvey);
} else {
const updatedSurvey = { ...localSurvey, autoComplete: 25 };
const updatedSurvey = { ...localSurvey, autoComplete: Math.max(25, responseCount + 5) };
setLocalSurvey(updatedSurvey);
}
};
@@ -310,7 +310,7 @@ export default function ResponseOptionsCard({
<AdvancedOptionToggle
htmlId="closeOnNumberOfResponse"
isChecked={autoComplete}
onToggle={handleCheckMark}
onToggle={toggleAutocomplete}
title="Close survey on response limit"
description="Automatically close the survey after a certain number of responses."
childBorder={true}>
@@ -411,7 +411,7 @@ export default function ResponseOptionsCard({
htmlId="singleUserSurveyOptions"
isChecked={!!localSurvey.singleUse?.enabled}
onToggle={handleSingleUseSurveyToggle}
title="Single-Use Survey Links"
title="Single-use survey links"
description="Allow only 1 response per survey link."
childBorder={true}>
<div className="flex w-full items-center space-x-1 p-4 pb-4">
@@ -507,7 +507,7 @@ export default function ResponseOptionsCard({
htmlId="protectSurveyWithPin"
isChecked={isPinProtectionEnabled}
onToggle={handleProtectSurveyWithPinToggle}
title="Protect Survey with a PIN"
title="Protect survey with a PIN"
description="Only users who have the PIN can access the survey."
childBorder={true}>
<div className="flex w-full items-center space-x-1 p-4 pb-4">
@@ -223,14 +223,6 @@ export default function SurveyMenuBar({
return false;
}
/*
Check whether the count for autocomplete responses is not less
than the current count of accepted response and also it is not set to 0
*/
if ((survey.autoComplete && responseCount >= survey.autoComplete) || survey?.autoComplete === 0) {
return false;
}
return true;
};