mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-07 22:31:35 -05:00
feat: let's v1.2 (#1332)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
committed by
GitHub
parent
21fe7080ef
commit
e9f4edadbd
@@ -2,7 +2,7 @@
|
||||
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import { SHORT_SURVEY_BASE_URL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
|
||||
import { SHORT_URL_BASE, WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { hasUserEnvironmentAccess } from "@formbricks/lib/environment/auth";
|
||||
import { createMembership } from "@formbricks/lib/membership/service";
|
||||
import { createProduct } from "@formbricks/lib/product/service";
|
||||
@@ -19,13 +19,13 @@ export const createShortUrlAction = async (url: string) => {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session) throw new AuthenticationError("Not authenticated");
|
||||
|
||||
const regexPattern = new RegExp("^" + SURVEY_BASE_URL);
|
||||
const regexPattern = new RegExp("^" + WEBAPP_URL);
|
||||
const isValidUrl = regexPattern.test(url);
|
||||
|
||||
if (!isValidUrl) throw new Error("Only Formbricks survey URLs are allowed");
|
||||
|
||||
const shortUrl = await createShortUrl(url);
|
||||
const fullShortUrl = SHORT_SURVEY_BASE_URL + shortUrl.id;
|
||||
const fullShortUrl = SHORT_URL_BASE + "/" + shortUrl.id;
|
||||
return fullShortUrl;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const revalidate = REVALIDATION_INTERVAL;
|
||||
|
||||
import Navigation from "@/app/(app)/environments/[environmentId]/components/Navigation";
|
||||
import { IS_FORMBRICKS_CLOUD, REVALIDATION_INTERVAL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
|
||||
import { IS_FORMBRICKS_CLOUD, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getEnvironment, getEnvironments } from "@formbricks/lib/environment/service";
|
||||
import { getProducts } from "@formbricks/lib/product/service";
|
||||
import { getTeamByEnvironmentId, getTeamsByUserId } from "@formbricks/lib/team/service";
|
||||
@@ -43,7 +43,7 @@ export default async function EnvironmentsNavbar({ environmentId, session }: Env
|
||||
environments={environments}
|
||||
session={session}
|
||||
isFormbricksCloud={IS_FORMBRICKS_CLOUD}
|
||||
surveyBaseUrl={SURVEY_BASE_URL}
|
||||
webAppUrl={WEBAPP_URL}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ interface NavigationProps {
|
||||
products: TProduct[];
|
||||
environments: TEnvironment[];
|
||||
isFormbricksCloud: boolean;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
}
|
||||
|
||||
export default function Navigation({
|
||||
@@ -73,7 +73,7 @@ export default function Navigation({
|
||||
products,
|
||||
environments,
|
||||
isFormbricksCloud,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
}: NavigationProps) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
@@ -495,7 +495,7 @@ export default function Navigation({
|
||||
<UrlShortenerModal
|
||||
open={showLinkShortenerModal}
|
||||
setOpen={(val) => setShowLinkShortenerModal(val)}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
/>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
@@ -12,14 +12,14 @@ import { createShortUrlAction } from "../actions";
|
||||
type UrlShortenerModalProps = {
|
||||
open: boolean;
|
||||
setOpen: (v: boolean) => void;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
};
|
||||
type UrlShortenerFormDataProps = {
|
||||
url: string;
|
||||
};
|
||||
type UrlValidationState = "default" | "valid" | "invalid";
|
||||
|
||||
export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlShortenerModalProps) {
|
||||
export default function UrlShortenerModal({ open, setOpen, webAppUrl }: UrlShortenerModalProps) {
|
||||
const [urlValidationState, setUrlValidationState] = useState<UrlValidationState>("default");
|
||||
const [shortUrl, setShortUrl] = useState("");
|
||||
const {
|
||||
@@ -41,7 +41,7 @@ export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlS
|
||||
return;
|
||||
}
|
||||
|
||||
const regexPattern = new RegExp("^" + surveyBaseUrl);
|
||||
const regexPattern = new RegExp("^" + webAppUrl);
|
||||
const isValid = regexPattern.test(value);
|
||||
if (!isValid) {
|
||||
setUrlValidationState("invalid");
|
||||
@@ -99,7 +99,7 @@ export default function UrlShortenerModal({ open, setOpen, surveyBaseUrl }: UrlS
|
||||
<div className="grid grid-cols-6 gap-3">
|
||||
<Input
|
||||
autoFocus
|
||||
placeholder={`${surveyBaseUrl}...`}
|
||||
placeholder={`${webAppUrl}...`}
|
||||
className={clsx(
|
||||
"col-span-5",
|
||||
urlValidationState === "valid"
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ interface ResponsePageProps {
|
||||
survey: TSurvey;
|
||||
surveyId: string;
|
||||
responses: TResponse[];
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
environmentTags: TTag[];
|
||||
@@ -32,7 +32,7 @@ const ResponsePage = ({
|
||||
survey,
|
||||
surveyId,
|
||||
responses,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
environmentTags,
|
||||
@@ -58,7 +58,7 @@ const ResponsePage = ({
|
||||
environment={environment}
|
||||
survey={survey}
|
||||
surveyId={surveyId}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ export const revalidate = REVALIDATION_INTERVAL;
|
||||
import { getAnalysisData } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
|
||||
import ResponsePage from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/responses/components/ResponsePage";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import { RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
|
||||
import { RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getEnvironment } from "@formbricks/lib/environment/service";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { getProfile } from "@formbricks/lib/profile/service";
|
||||
@@ -40,7 +40,7 @@ export default async function Page({ params }) {
|
||||
responses={responses}
|
||||
survey={survey}
|
||||
surveyId={params.surveyId}
|
||||
surveyBaseUrl={SURVEY_BASE_URL}
|
||||
webAppUrl={WEBAPP_URL}
|
||||
product={product}
|
||||
environmentTags={tags}
|
||||
profile={profile}
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import { TProfile } from "@formbricks/types/profile";
|
||||
interface LinkSurveyShareButtonProps {
|
||||
survey: TSurvey;
|
||||
className?: string;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ interface LinkSurveyShareButtonProps {
|
||||
export default function LinkSurveyShareButton({
|
||||
survey,
|
||||
className,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
}: LinkSurveyShareButtonProps) {
|
||||
@@ -45,7 +45,7 @@ export default function LinkSurveyShareButton({
|
||||
open={showLinkModal}
|
||||
setOpen={setShowLinkModal}
|
||||
product={product}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
profile={profile}
|
||||
/>
|
||||
)}
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@ interface ShareEmbedSurveyProps {
|
||||
survey: TSurvey;
|
||||
open: boolean;
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
}
|
||||
@@ -25,11 +25,11 @@ export default function ShareEmbedSurvey({
|
||||
survey,
|
||||
open,
|
||||
setOpen,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
}: ShareEmbedSurveyProps) {
|
||||
const surveyUrl = useMemo(() => surveyBaseUrl + survey.id, [survey]);
|
||||
const surveyUrl = useMemo(() => webAppUrl + "/s/" + survey.id, [survey]);
|
||||
const isSingleUseLinkSurvey = survey.singleUse?.enabled;
|
||||
const { email } = profile;
|
||||
const { brandColor } = product;
|
||||
@@ -45,7 +45,7 @@ export default function ShareEmbedSurvey({
|
||||
|
||||
const componentMap = {
|
||||
link: isSingleUseLinkSurvey ? (
|
||||
<LinkSingleUseSurveyModal survey={survey} surveyBaseUrl={surveyBaseUrl} />
|
||||
<LinkSingleUseSurveyModal survey={survey} surveyBaseUrl={webAppUrl} />
|
||||
) : (
|
||||
<LinkTab surveyUrl={surveyUrl} survey={survey} brandColor={surveyBrandColor} />
|
||||
),
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ import { TProfile } from "@formbricks/types/profile";
|
||||
interface SummaryMetadataProps {
|
||||
environment: TEnvironment;
|
||||
survey: TSurvey;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
singleUseIds?: string[];
|
||||
@@ -22,7 +22,7 @@ interface SummaryMetadataProps {
|
||||
export default function SuccessMessage({
|
||||
environment,
|
||||
survey,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
}: SummaryMetadataProps) {
|
||||
@@ -60,7 +60,7 @@ export default function SuccessMessage({
|
||||
survey={survey}
|
||||
open={showLinkModal}
|
||||
setOpen={setShowLinkModal}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ interface SummaryPageProps {
|
||||
survey: TSurvey;
|
||||
surveyId: string;
|
||||
responses: TResponse[];
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
environmentTags: TTag[];
|
||||
@@ -36,7 +36,7 @@ const SummaryPage = ({
|
||||
survey,
|
||||
surveyId,
|
||||
responses,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
environmentTags,
|
||||
@@ -64,7 +64,7 @@ const SummaryPage = ({
|
||||
environment={environment}
|
||||
survey={survey}
|
||||
surveyId={surveyId}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
|
||||
+2
-6
@@ -3,11 +3,7 @@ export const revalidate = REVALIDATION_INTERVAL;
|
||||
import { getAnalysisData } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
|
||||
import SummaryPage from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/SummaryPage";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import {
|
||||
OPEN_TEXT_RESPONSES_PER_PAGE,
|
||||
REVALIDATION_INTERVAL,
|
||||
SURVEY_BASE_URL,
|
||||
} from "@formbricks/lib/constants";
|
||||
import { OPEN_TEXT_RESPONSES_PER_PAGE, REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getEnvironment } from "@formbricks/lib/environment/service";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { getProfile } from "@formbricks/lib/profile/service";
|
||||
@@ -47,7 +43,7 @@ export default async function Page({ params }) {
|
||||
responses={responses}
|
||||
survey={survey}
|
||||
surveyId={params.surveyId}
|
||||
surveyBaseUrl={SURVEY_BASE_URL}
|
||||
webAppUrl={WEBAPP_URL}
|
||||
product={product}
|
||||
profile={profile}
|
||||
environmentTags={tags}
|
||||
|
||||
+5
-10
@@ -30,7 +30,7 @@ interface SummaryHeaderProps {
|
||||
surveyId: string;
|
||||
environment: TEnvironment;
|
||||
survey: TSurvey;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
product: TProduct;
|
||||
profile: TProfile;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ const SummaryHeader = ({
|
||||
surveyId,
|
||||
environment,
|
||||
survey,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
product,
|
||||
profile,
|
||||
}: SummaryHeaderProps) => {
|
||||
@@ -56,12 +56,7 @@ const SummaryHeader = ({
|
||||
</div>
|
||||
<div className="hidden justify-end gap-x-1.5 sm:flex">
|
||||
{survey.type === "link" && (
|
||||
<LinkSurveyShareButton
|
||||
survey={survey}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
<LinkSurveyShareButton survey={survey} webAppUrl={webAppUrl} product={product} profile={profile} />
|
||||
)}
|
||||
{(environment?.widgetSetupCompleted || survey.type === "link") && survey?.status !== "draft" ? (
|
||||
<SurveyStatusDropdown environment={environment} survey={survey} />
|
||||
@@ -87,7 +82,7 @@ const SummaryHeader = ({
|
||||
<LinkSurveyShareButton
|
||||
className="flex w-full justify-center p-1"
|
||||
survey={survey}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
@@ -172,7 +167,7 @@ const SummaryHeader = ({
|
||||
<SuccessMessage
|
||||
environment={environment}
|
||||
survey={survey}
|
||||
surveyBaseUrl={surveyBaseUrl}
|
||||
webAppUrl={webAppUrl}
|
||||
product={product}
|
||||
profile={profile}
|
||||
/>
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ interface SurveyDropDownMenuProps {
|
||||
survey: TSurvey;
|
||||
environment: TEnvironment;
|
||||
otherEnvironment: TEnvironment;
|
||||
surveyBaseUrl: string;
|
||||
webAppUrl: string;
|
||||
singleUseId?: string;
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ export default function SurveyDropDownMenu({
|
||||
survey,
|
||||
environment,
|
||||
otherEnvironment,
|
||||
surveyBaseUrl,
|
||||
webAppUrl,
|
||||
singleUseId,
|
||||
}: SurveyDropDownMenuProps) {
|
||||
const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
const surveyUrl = useMemo(() => surveyBaseUrl + survey.id, [survey.id, surveyBaseUrl]);
|
||||
const surveyUrl = useMemo(() => webAppUrl + "/s/" + survey.id, [survey.id, webAppUrl]);
|
||||
|
||||
const handleDeleteSurvey = async (survey) => {
|
||||
setLoading(true);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UsageAttributesUpdater } from "@/app/(app)/components/FormbricksClient"
|
||||
import SurveyDropDownMenu from "@/app/(app)/environments/[environmentId]/surveys/components/SurveyDropDownMenu";
|
||||
import SurveyStarter from "@/app/(app)/environments/[environmentId]/surveys/components/SurveyStarter";
|
||||
import { SurveyStatusIndicator } from "@formbricks/ui/SurveyStatusIndicator";
|
||||
import { SURVEY_BASE_URL } from "@formbricks/lib/constants";
|
||||
import { WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getEnvironment, getEnvironments } from "@formbricks/lib/environment/service";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { getSurveys } from "@formbricks/lib/survey/service";
|
||||
@@ -111,7 +111,7 @@ export default async function SurveysList({ environmentId }: { environmentId: st
|
||||
environmentId={environmentId}
|
||||
environment={environment}
|
||||
otherEnvironment={otherEnvironment!}
|
||||
surveyBaseUrl={SURVEY_BASE_URL}
|
||||
webAppUrl={WEBAPP_URL}
|
||||
singleUseId={singleUseId}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@ export const revalidate = REVALIDATION_INTERVAL;
|
||||
|
||||
import LinkSurvey from "@/app/s/[surveyId]/components/LinkSurvey";
|
||||
import SurveyInactive from "@/app/s/[surveyId]/components/SurveyInactive";
|
||||
import { REVALIDATION_INTERVAL, WEBAPP_URL, SURVEY_BASE_URL } from "@formbricks/lib/constants";
|
||||
import { REVALIDATION_INTERVAL, WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getOrCreatePersonByUserId } from "@formbricks/lib/person/service";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { getSurvey } from "@formbricks/lib/survey/service";
|
||||
@@ -56,7 +56,7 @@ export async function generateMetadata({ params }: LinkSurveyPageProps): Promise
|
||||
openGraph: {
|
||||
title: survey.name,
|
||||
description: "Create your own survey like this with Formbricks' open source survey suite.",
|
||||
url: `${SURVEY_BASE_URL}/${survey.id}`,
|
||||
url: `${WEBAPP_URL}/${survey.id}`,
|
||||
siteName: "",
|
||||
images: [ogImgURL],
|
||||
locale: "en_US",
|
||||
|
||||
Reference in New Issue
Block a user