From c68a9c8d1584a30ca5c4b70d005474d485dba93f Mon Sep 17 00:00:00 2001 From: Piyush Gupta Date: Tue, 18 Jul 2023 19:38:03 +0530 Subject: [PATCH] fix: edge case of close on date --- .../surveys/[surveyId]/SummaryHeader.tsx | 117 ++++++++++------- .../shared/SurveyStatusDropdown.tsx | 119 ++++++++++-------- 2 files changed, 139 insertions(+), 97 deletions(-) diff --git a/apps/web/app/environments/[environmentId]/surveys/[surveyId]/SummaryHeader.tsx b/apps/web/app/environments/[environmentId]/surveys/[surveyId]/SummaryHeader.tsx index 174050afa1..bad9fbf51a 100644 --- a/apps/web/app/environments/[environmentId]/surveys/[surveyId]/SummaryHeader.tsx +++ b/apps/web/app/environments/[environmentId]/surveys/[surveyId]/SummaryHeader.tsx @@ -21,6 +21,10 @@ import { DropdownMenuSubTrigger, DropdownMenuTrigger, ErrorComponent, + Tooltip, + TooltipProvider, + TooltipTrigger, + TooltipContent, } from "@formbricks/ui"; import { CheckCircleIcon, @@ -48,6 +52,10 @@ const SummaryHeader = ({ surveyId, environmentId, survey }: SummaryHeaderProps) const { environment, isLoadingEnvironment, isErrorEnvironment } = useEnvironment(environmentId); const { triggerSurveyMutate } = useSurveyMutation(environmentId, surveyId); + const isCloseOnDateEnabled = survey.closeOnDate !== null; + const closeOnDate = survey.closeOnDate ? new Date(survey.closeOnDate) : null; + const isStatusChangeDisabled = (isCloseOnDateEnabled && closeOnDate && closeOnDate < new Date()) ?? false; + if (isLoadingProduct || isLoadingEnvironment) { return ; } @@ -64,53 +72,64 @@ const SummaryHeader = ({ surveyId, environmentId, survey }: SummaryHeaderProps)
{survey.type === "link" && } {(environment?.widgetSetupCompleted || survey.type === "link") && survey?.status !== "draft" ? ( - + + + + + + + To update the survey status, update the “Close +
survey on date” setting in the Response Options. +
+
+
) : null}