Fix billing page not showing current plan (#550)

* update packages, fix error getting current subscription plan

* fix billing page not showing current plan

* add revalidation constant
This commit is contained in:
Matti Nannt
2023-07-13 20:28:48 +02:00
committed by GitHub
parent 62c001cbee
commit 21529da799
7 changed files with 14 additions and 7 deletions

View File

@@ -1,7 +1,8 @@
export const revalidate = 0;
export const revalidate = REVALIDATION_INTERVAL;
import EmptySpaceFiller from "@/components/shared/EmptySpaceFiller";
import { truncateMiddle } from "@/lib/utils";
import { REVALIDATION_INTERVAL } from "@formbricks/lib/constants";
import { getPeople } from "@formbricks/lib/services/person";
import { TPerson } from "@formbricks/types/v1/people";
import { PersonAvatar } from "@formbricks/ui";

View File

@@ -73,9 +73,9 @@ export default function PricingTable({ environmentId, session }: PricingTablePro
<div className="">
<div className="rounded-lg border border-slate-200 bg-slate-50 shadow-sm">
<div className="p-8">
<h2 className="inline-flex text-3xl font-bold text-slate-700">Free</h2>
<h2 className="mr-2 inline-flex text-3xl font-bold text-slate-700">Free</h2>
{team.plan === "free" && <Badge text="Current Plan" size="normal" type="success" />}
<p className=" mt-4 whitespace-pre-wrap text-sm text-slate-600">
<p className="mt-4 whitespace-pre-wrap text-sm text-slate-600">
Always free. Giving back to the community.
</p>
<ul className="mt-4 space-y-4">
@@ -109,7 +109,7 @@ export default function PricingTable({ environmentId, session }: PricingTablePro
<div className="">
<div className="rounded-lg border border-slate-300 bg-slate-100 shadow-sm">
<div className="p-8">
<h2 className="inline-flex text-3xl font-bold text-slate-700">Pro</h2>
<h2 className="mr-2 inline-flex text-3xl font-bold text-slate-700">Pro</h2>
{team.plan === "pro" && <Badge text="Current Plan" size="normal" type="success" />}
<p className="mt-4 whitespace-pre-wrap text-sm text-slate-600">
All features included. Unlimited usage.

View File

@@ -10,9 +10,10 @@ export const getAnalysisData = async (surveyId: string, environmentId: string) =
getSurveyResponses(surveyId),
]);
if (!survey) throw new Error(`Survey not found: ${surveyId}`);
if (!team) throw new Error(`Team not found for environment: ${environmentId}`);
if (survey.environmentId !== environmentId) throw new Error(`Survey not found: ${surveyId}`);
const limitReached =
IS_FORMBRICKS_CLOUD && team?.plan === "free" && allResponses.length >= RESPONSES_LIMIT_FREE;
IS_FORMBRICKS_CLOUD && team.plan === "free" && allResponses.length >= RESPONSES_LIMIT_FREE;
const responses = limitReached ? allResponses.slice(0, RESPONSES_LIMIT_FREE) : allResponses;
const responsesCount = allResponses.length;

View File

@@ -1,9 +1,11 @@
export const revalidate = 0;
export const revalidate = REVALIDATION_INTERVAL;
import { authOptions } from "@/app/api/auth/[...nextauth]/authOptions";
import ResponsePage from "@/app/environments/[environmentId]/surveys/[surveyId]/(analysis)/responses/ResponsePage";
import { getAnalysisData } from "@/app/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
import { getServerSession } from "next-auth";
import ResponsesLimitReachedBanner from "../ResponsesLimitReachedBanner";
import { REVALIDATION_INTERVAL } from "@formbricks/lib/constants";
export default async function Page({ params }) {
const session = await getServerSession(authOptions);

View File

@@ -1,10 +1,11 @@
export const revalidate = 0;
export const revalidate = REVALIDATION_INTERVAL;
import { authOptions } from "@/app/api/auth/[...nextauth]/authOptions";
import { getAnalysisData } from "@/app/environments/[environmentId]/surveys/[surveyId]/(analysis)/data";
import { getServerSession } from "next-auth";
import ResponsesLimitReachedBanner from "../ResponsesLimitReachedBanner";
import SummaryPage from "./SummaryPage";
import { REVALIDATION_INTERVAL } from "@formbricks/lib/constants";
export default async function Page({ params }) {
const session = await getServerSession(authOptions);

View File

@@ -38,6 +38,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
id: true,
name: true,
stripeCustomerId: true,
plan: true,
},
});

View File

@@ -1,5 +1,6 @@
export const RESPONSES_LIMIT_FREE = 100;
export const IS_FORMBRICKS_CLOUD = process.env.NEXT_PUBLIC_IS_FORMBRICKS_CLOUD === "1";
export const REVALIDATION_INTERVAL = process.env.NODE_ENV === "production" ? 30 : 0; // 30 seconds in production, 10 seconds in development
// URLs
const VERCEL_URL = process.env.NEXT_PUBLIC_VERCEL_URL ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : "";