Skip to content

Commit

Permalink
🧑‍💻 Use static pricing data (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella authored Aug 25, 2024
1 parent 2474888 commit 08d6d00
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 16 additions & 8 deletions apps/landing/src/pages/pricing.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 (
<Tabs value={tab} onValueChange={setTab}>
Expand Down Expand Up @@ -278,9 +290,7 @@ const FAQ = () => {
);
};

const Page: NextPageWithLayout<{ pricingData: PricingData }> = ({
pricingData,
}) => {
const Page: NextPageWithLayout = () => {
const { t } = useTranslation(["pricing"]);
return (
<div className="mx-auto max-w-3xl">
Expand Down Expand Up @@ -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,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
8 changes: 2 additions & 6 deletions apps/web/src/app/[locale]/(admin)/settings/billing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
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";
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 <BillingPage pricingData={prices} />;
return <BillingPage pricingData={pricingData} />;
}

export async function generateMetadata({ params }: { params: Params }) {
Expand Down
3 changes: 2 additions & 1 deletion packages/billing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 0 additions & 23 deletions packages/billing/src/next/index.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/billing/src/pricing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const pricingData = {
monthly: {
amount: 700,
currency: "usd",
},
yearly: {
amount: 5600,
currency: "usd",
},
};

0 comments on commit 08d6d00

Please sign in to comment.