From 08d6d00e521cced4dba2255fedff40ddbae94899 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Sun, 25 Aug 2024 13:00:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Use=20stati?= =?UTF-8?q?c=20pricing=20data=20(#1275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 -- apps/landing/src/pages/pricing.tsx | 24 ++++++++++++------- .../settings/billing/billing-plans.tsx | 2 -- .../(admin)/settings/billing/page.tsx | 8 ++----- packages/billing/package.json | 3 ++- packages/billing/src/next/index.ts | 23 ------------------ packages/billing/src/pricing.ts | 10 ++++++++ 7 files changed, 30 insertions(+), 42 deletions(-) delete mode 100644 packages/billing/src/next/index.ts create mode 100644 packages/billing/src/pricing.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61fcbf14beb..e7ac54d1ff9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,8 +65,6 @@ jobs: - name: Create production build run: yarn turbo build:test --filter=@rallly/web - env: - STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} - name: Start services run: yarn docker:up diff --git a/apps/landing/src/pages/pricing.tsx b/apps/landing/src/pages/pricing.tsx index a4792a87237..b3de66449cc 100644 --- a/apps/landing/src/pages/pricing.tsx +++ b/apps/landing/src/pages/pricing.tsx @@ -1,5 +1,4 @@ -import type { PricingData } from "@rallly/billing"; -import { getProPricing } from "@rallly/billing"; +import { pricingData } from "@rallly/billing/pricing"; import { Badge } from "@rallly/ui/badge"; import { BillingPlan, @@ -49,7 +48,20 @@ export const UpgradeButton = ({ ); }; -const PriceTables = ({ pricingData }: { pricingData: PricingData }) => { +const PriceTables = ({ + pricingData, +}: { + pricingData: { + monthly: { + amount: number; + currency: string; + }; + yearly: { + amount: number; + currency: string; + }; + }; +}) => { const [tab, setTab] = React.useState("yearly"); return ( @@ -278,9 +290,7 @@ const FAQ = () => { ); }; -const Page: NextPageWithLayout<{ pricingData: PricingData }> = ({ - pricingData, -}) => { +const Page: NextPageWithLayout = () => { const { t } = useTranslation(["pricing"]); return (
@@ -332,13 +342,11 @@ Page.getLayout = getPageLayout; export default Page; export const getStaticProps: GetStaticProps = async (ctx) => { - const pricingData = await getProPricing(); const res = await getStaticTranslations(["pricing"])(ctx); if ("props" in res) { return { props: { ...res.props, - pricingData, }, }; } diff --git a/apps/web/src/app/[locale]/(admin)/settings/billing/billing-plans.tsx b/apps/web/src/app/[locale]/(admin)/settings/billing/billing-plans.tsx index b4bf4821b44..659a4d99ff9 100644 --- a/apps/web/src/app/[locale]/(admin)/settings/billing/billing-plans.tsx +++ b/apps/web/src/app/[locale]/(admin)/settings/billing/billing-plans.tsx @@ -19,12 +19,10 @@ import { UpgradeButton } from "@/components/upgrade-button"; export type PricingData = { monthly: { - id: string; amount: number; currency: string; }; yearly: { - id: string; amount: number; currency: string; }; diff --git a/apps/web/src/app/[locale]/(admin)/settings/billing/page.tsx b/apps/web/src/app/[locale]/(admin)/settings/billing/page.tsx index 538371c1d84..3e81f2dc2bc 100644 --- a/apps/web/src/app/[locale]/(admin)/settings/billing/page.tsx +++ b/apps/web/src/app/[locale]/(admin)/settings/billing/page.tsx @@ -1,5 +1,4 @@ -import { getProPricing } from "@rallly/billing"; -import { unstable_cache } from "next/cache"; +import { pricingData } from "@rallly/billing/pricing"; import { notFound } from "next/navigation"; import { BillingPage } from "@/app/[locale]/(admin)/settings/billing/billing-page"; @@ -7,14 +6,11 @@ import { Params } from "@/app/[locale]/types"; import { getTranslation } from "@/app/i18n"; import { env } from "@/env"; -const getCachedProPricing = unstable_cache(getProPricing, ["pricing-data"]); - export default async function Page() { if (env.NEXT_PUBLIC_SELF_HOSTED === "true") { notFound(); } - const prices = await getCachedProPricing(); - return ; + return ; } export async function generateMetadata({ params }: { params: Params }) { diff --git a/packages/billing/package.json b/packages/billing/package.json index 6fa32aa1531..80829480a82 100644 --- a/packages/billing/package.json +++ b/packages/billing/package.json @@ -5,7 +5,8 @@ "exports": { "./server/*": "./src/server/*.tsx", "./next": "./src/next/index.ts", - ".": "./src/index.ts" + ".": "./src/index.ts", + "./*": "./src/*.ts" }, "scripts": { "normalize-subscription-metadata": "dotenv -e ../../.env -- tsx ./src/scripts/normalize-metadata.ts" diff --git a/packages/billing/src/next/index.ts b/packages/billing/src/next/index.ts deleted file mode 100644 index 9b9be3d70b9..00000000000 --- a/packages/billing/src/next/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { getPricing } from "../lib/get-pricing"; - -export async function GET( - request: NextRequest, - { - params, - }: { - params: { - method: string; - }; - }, -) { - switch (params.method) { - case "pricing": - const data = await getPricing(); - return NextResponse.json(data); - default: - return NextResponse.json({ message: "Method not found" }); - } -} - -export const handlers = { GET }; diff --git a/packages/billing/src/pricing.ts b/packages/billing/src/pricing.ts new file mode 100644 index 00000000000..234230cab6b --- /dev/null +++ b/packages/billing/src/pricing.ts @@ -0,0 +1,10 @@ +export const pricingData = { + monthly: { + amount: 700, + currency: "usd", + }, + yearly: { + amount: 5600, + currency: "usd", + }, +};