chore: fix tests

This commit is contained in:
Tiago Farto
2026-04-20 12:30:03 +00:00
parent a89d598f8d
commit 7dde3edd8d
3 changed files with 107 additions and 108 deletions
@@ -50,16 +50,6 @@ interface TIntegrationFieldSelection {
includeVariables: boolean;
}
type TIntegrationPipelineData = {
surveyId: string;
response: {
createdAt: Date;
data: Record<string, TResponseDataValue>;
meta: TResponseMeta;
variables: Record<string, string | number>;
};
};
const toIntegrationFieldSelection = (config: {
elementIds: string[];
includeCreatedAt?: boolean | null;
@@ -19,6 +19,8 @@ export const SurveyInactive = async ({
workspace?: Pick<Workspace, "linkSurveyBranding">;
}) => {
const t = await getTranslate();
const hasCustomClosedMessage =
(status === "completed" || status === "link expired") && Boolean(surveyClosedMessage);
const icons = {
paused: isScheduled ? (
<CalendarClockIcon className="h-20 w-20" />
@@ -38,6 +40,16 @@ export const SurveyInactive = async ({
"response submitted": t("s.response_submitted"),
"link expired": t("c.link_expired_description"),
};
let title = `${t("common.survey")} ${status}.`;
if (hasCustomClosedMessage) {
title = surveyClosedMessage?.heading ?? title;
} else if (isScheduled) {
title = t("common.survey_scheduled");
}
const description =
status === "completed" && surveyClosedMessage ? surveyClosedMessage.subheading : descriptions[status];
const showCTA =
status !== "link invalid" &&
@@ -50,18 +62,8 @@ export const SurveyInactive = async ({
<div className="flex h-full flex-col items-center justify-between bg-gradient-to-br from-slate-200 to-slate-50 px-4 py-8 text-center">
<div className="my-auto flex flex-col items-center space-y-3 text-slate-300">
{icons[status]}
<h1 className="text-4xl font-bold text-slate-800">
{(status === "completed" || status === "link expired") && surveyClosedMessage
? surveyClosedMessage.heading
: isScheduled
? t("common.survey_scheduled")
: `${t("common.survey")} ${status}.`}
</h1>
<p className="text-lg leading-10 text-slate-500">
{status === "completed" && surveyClosedMessage
? surveyClosedMessage.subheading
: descriptions[status]}
</p>
<h1 className="text-4xl font-bold text-slate-800">{title}</h1>
<p className="text-lg leading-10 text-slate-500">{description}</p>
{showCTA && (
<Button className="mt-2" asChild>
<Link href="https://formbricks.com">{t("s.create_your_own")}</Link>
@@ -1,6 +1,7 @@
"use client";
import { CalendarClockIcon, CheckIcon, PauseIcon, PencilIcon } from "lucide-react";
import { type ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { TSurvey } from "@formbricks/types/surveys/types";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/modules/ui/components/tooltip";
@@ -11,107 +12,113 @@ interface SurveyStatusIndicatorProps {
tooltip?: boolean;
}
const InProgressIndicator = () => (
<span className="relative flex h-3 w-3">
<span className="absolute inline-flex h-full w-full animate-ping-slow rounded-full bg-green-500 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
);
const PausedIndicator = ({ isScheduled }: { isScheduled: boolean }) => (
<div className="rounded-full bg-slate-300 p-1">
{isScheduled ? (
<CalendarClockIcon className="h-3 w-3 text-slate-600" />
) : (
<PauseIcon className="h-3 w-3 text-slate-600" />
)}
</div>
);
const CompletedIndicator = () => (
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
);
const DraftIndicator = () => (
<div className="rounded-full bg-slate-300 p-1">
<PencilIcon className="h-3 w-3 text-slate-600" />
</div>
);
const DraftTooltipIndicator = () => (
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
);
const renderStatusIndicator = ({ isScheduled, status, tooltip }: SurveyStatusIndicatorProps): ReactNode => {
switch (status) {
case "inProgress":
return <InProgressIndicator />;
case "paused":
return <PausedIndicator isScheduled={isScheduled ?? false} />;
case "completed":
return <CompletedIndicator />;
case "draft":
return tooltip ? <DraftTooltipIndicator /> : <DraftIndicator />;
default:
return null;
}
};
const renderTooltipContent = ({
isScheduled,
status,
t,
}: Pick<SurveyStatusIndicatorProps, "isScheduled" | "status"> & {
t: ReturnType<typeof useTranslation>["t"];
}): ReactNode => {
switch (status) {
case "inProgress":
return (
<>
<span>{t("common.gathering_responses")}</span>
<InProgressIndicator />
</>
);
case "paused":
return (
<>
<span className="text-slate-800">
{isScheduled ? t("common.survey_scheduled") : t("common.survey_paused")}
</span>
<PausedIndicator isScheduled={isScheduled ?? false} />
</>
);
case "completed":
return (
<>
<span>{t("common.survey_completed")}</span>
<CompletedIndicator />
</>
);
default:
return null;
}
};
export const SurveyStatusIndicator = ({
status,
isScheduled = false,
tooltip,
}: SurveyStatusIndicatorProps) => {
const { t } = useTranslation();
if (tooltip) {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
{status === "inProgress" && (
<span className="relative flex h-3 w-3">
<span className="absolute inline-flex h-full w-full animate-ping-slow rounded-full bg-green-500 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
)}
{status === "paused" && (
<div className="rounded-full bg-slate-300 p-1">
{isScheduled ? (
<CalendarClockIcon className="h-3 w-3 text-slate-600" />
) : (
<PauseIcon className="h-3 w-3 text-slate-600" />
)}
</div>
)}
{status === "completed" && (
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "draft" && (
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
)}
</TooltipTrigger>
<TooltipTrigger>{renderStatusIndicator({ status, isScheduled, tooltip })}</TooltipTrigger>
<TooltipContent>
<div className="flex items-center space-x-2">
{status === "inProgress" ? (
<>
<span>{t("common.gathering_responses")}</span>
<span className="relative flex h-3 w-3">
<span className="absolute inline-flex h-full w-full animate-ping-slow rounded-full bg-green-500 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
</>
) : status === "paused" ? (
<>
<span className="text-slate-800">
{isScheduled ? t("common.survey_scheduled") : t("common.survey_paused")}
</span>
<div className="rounded-full bg-slate-300 p-1">
{isScheduled ? (
<CalendarClockIcon className="h-3 w-3 text-slate-600" />
) : (
<PauseIcon className="h-3 w-3 text-slate-600" />
)}
</div>
</>
) : status === "completed" ? (
<div className="flex items-center space-x-2">
<span>{t("common.survey_completed")}</span>
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
</div>
) : null}
{renderTooltipContent({ status, isScheduled, t })}
</div>
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
} else
return (
<span>
{status === "inProgress" && (
<span className="relative flex h-3 w-3">
<span className="absolute inline-flex h-full w-full animate-ping-slow rounded-full bg-green-500 opacity-75"></span>
<span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
</span>
)}
{status === "paused" && (
<div className="rounded-full bg-slate-300 p-1">
{isScheduled ? (
<CalendarClockIcon className="h-3 w-3 text-slate-600" />
) : (
<PauseIcon className="h-3 w-3 text-slate-600" />
)}
</div>
)}
{status === "completed" && (
<div className="rounded-full bg-slate-200 p-1">
<CheckIcon className="h-3 w-3 text-slate-600" />
</div>
)}
{status === "draft" && (
<div className="rounded-full bg-slate-300 p-1">
<PencilIcon className="h-3 w-3 text-slate-600" />
</div>
)}
</span>
);
}
return <span>{renderStatusIndicator({ status, isScheduled, tooltip })}</span>;
};