From c89d03022295f254b2ca3dd34211df4edf513d06 Mon Sep 17 00:00:00 2001
From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com>
Date: Mon, 22 Jan 2024 14:41:06 +0530
Subject: [PATCH] feat: report survey link (#1932)
---
.../s/[surveyId]/components/LegalFooter.tsx | 26 +++++++++++++++++--
.../app/s/[surveyId]/components/PinScreen.tsx | 4 +++
apps/web/app/s/[surveyId]/page.tsx | 5 +++-
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/apps/web/app/s/[surveyId]/components/LegalFooter.tsx b/apps/web/app/s/[surveyId]/components/LegalFooter.tsx
index e55d41065d..3089cc21ef 100644
--- a/apps/web/app/s/[surveyId]/components/LegalFooter.tsx
+++ b/apps/web/app/s/[surveyId]/components/LegalFooter.tsx
@@ -4,10 +4,26 @@ interface LegalFooterProps {
bgColor?: string | null;
IMPRINT_URL?: string;
PRIVACY_URL?: string;
+ IS_FORMBRICKS_CLOUD: boolean;
+ surveyUrl: string;
}
-export default function LegalFooter({ bgColor, IMPRINT_URL, PRIVACY_URL }: LegalFooterProps) {
- if (!IMPRINT_URL && !PRIVACY_URL) return null;
+export default function LegalFooter({
+ bgColor,
+ IMPRINT_URL,
+ PRIVACY_URL,
+ IS_FORMBRICKS_CLOUD,
+ surveyUrl,
+}: LegalFooterProps) {
+ if (!IMPRINT_URL && !PRIVACY_URL && !IS_FORMBRICKS_CLOUD) return null;
+
+ const createMailToLink = (surveyLink) => {
+ const subject = encodeURIComponent("Reporting this survey");
+ const body = encodeURIComponent(
+ `I report the survey to the Formbricks team as it is spam, abusive or violates the terms.\n\n${surveyLink}`
+ );
+ return `mailto:hola@formbricks.com?subject=${subject}&body=${body}`;
+ };
return (
)}
+ {PRIVACY_URL && IS_FORMBRICKS_CLOUD && |}
+ {IS_FORMBRICKS_CLOUD && (
+
+ Report Survey
+
+ )}
);
diff --git a/apps/web/app/s/[surveyId]/components/PinScreen.tsx b/apps/web/app/s/[surveyId]/components/PinScreen.tsx
index a0df45a022..5a9b9ff70e 100644
--- a/apps/web/app/s/[surveyId]/components/PinScreen.tsx
+++ b/apps/web/app/s/[surveyId]/components/PinScreen.tsx
@@ -25,6 +25,7 @@ interface LinkSurveyPinScreenProps {
webAppUrl: string;
IMPRINT_URL?: string;
PRIVACY_URL?: string;
+ IS_FORMBRICKS_CLOUD: boolean;
}
const LinkSurveyPinScreen: NextPage = (props) => {
@@ -39,6 +40,7 @@ const LinkSurveyPinScreen: NextPage = (props) => {
singleUseResponse,
IMPRINT_URL,
PRIVACY_URL,
+ IS_FORMBRICKS_CLOUD,
} = props;
const [localPinEntry, setLocalPinEntry] = useState("");
@@ -124,6 +126,8 @@ const LinkSurveyPinScreen: NextPage = (props) => {
bgColor={survey.styling?.background?.bg || "#ffff"}
IMPRINT_URL={IMPRINT_URL}
PRIVACY_URL={PRIVACY_URL}
+ IS_FORMBRICKS_CLOUD={IS_FORMBRICKS_CLOUD}
+ surveyUrl={webAppUrl + "/s/" + survey.id}
/>
);
diff --git a/apps/web/app/s/[surveyId]/page.tsx b/apps/web/app/s/[surveyId]/page.tsx
index cb65a102a1..1d28015675 100644
--- a/apps/web/app/s/[surveyId]/page.tsx
+++ b/apps/web/app/s/[surveyId]/page.tsx
@@ -8,7 +8,7 @@ import { checkValidity } from "@/app/s/[surveyId]/lib/prefilling";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
-import { IMPRINT_URL, PRIVACY_URL } from "@formbricks/lib/constants";
+import { IMPRINT_URL, IS_FORMBRICKS_CLOUD, PRIVACY_URL } from "@formbricks/lib/constants";
import { WEBAPP_URL } from "@formbricks/lib/constants";
import { createPerson, getPersonByUserId } from "@formbricks/lib/person/service";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
@@ -184,6 +184,7 @@ export default async function LinkSurveyPage({ params, searchParams }: LinkSurve
webAppUrl={WEBAPP_URL}
IMPRINT_URL={IMPRINT_URL}
PRIVACY_URL={PRIVACY_URL}
+ IS_FORMBRICKS_CLOUD={IS_FORMBRICKS_CLOUD}
/>
);
}
@@ -207,6 +208,8 @@ export default async function LinkSurveyPage({ params, searchParams }: LinkSurve
bgColor={survey.styling?.background?.bg || "#ffff"}
IMPRINT_URL={IMPRINT_URL}
PRIVACY_URL={PRIVACY_URL}
+ IS_FORMBRICKS_CLOUD={IS_FORMBRICKS_CLOUD}
+ surveyUrl={WEBAPP_URL + "/s/" + survey.id}
/>
) : null;