mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-04 19:51:51 +02:00
🧑💻 Use static pricing data (#1275)
This commit is contained in:
parent
2474888b14
commit
08d6d00e52
7 changed files with 30 additions and 42 deletions
|
@ -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 (
|
||||
<Tabs value={tab} onValueChange={setTab}>
|
||||
|
@ -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">
|
||||
|
@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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 <BillingPage pricingData={prices} />;
|
||||
return <BillingPage pricingData={pricingData} />;
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Params }) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue