Skip to content

Commit a827b3c

Browse files
committed
feat: add plan details component
1 parent cbe8e46 commit a827b3c

File tree

2 files changed

+40
-0
lines changed
  • src
    • app/(authenticated)/(dashboard)/[publicId]/settings/billing
    • components/billing/plan-details

2 files changed

+40
-0
lines changed

src/app/(authenticated)/(dashboard)/[publicId]/settings/billing/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PlanDetails } from "@/components/billing/plan-details";
12
import { Pricing } from "@/components/billing/pricing";
23
import { PageLayout } from "@/components/dashboard/page-layout";
34
import { api } from "@/trpc/server";
@@ -14,6 +15,7 @@ const BillingPage = async () => {
1415

1516
return (
1617
<PageLayout title="Billing" description="manage your billing">
18+
<PlanDetails subscription={subscription} />
1719
<Pricing products={products} subscription={subscription} />
1820
</PageLayout>
1921
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { dayjsExt } from "@/common/dayjs";
2+
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
3+
import { badgeVariants } from "@/components/ui/badge";
4+
5+
import type { RouterOutputs } from "@/trpc/shared";
6+
7+
type TSubscription =
8+
RouterOutputs["billing"]["getSubscription"]["subscription"];
9+
10+
interface PlanDetailsProps {
11+
subscription: TSubscription;
12+
}
13+
14+
export function PlanDetails({ subscription }: PlanDetailsProps) {
15+
return (
16+
<div>
17+
<Alert>
18+
<AlertTitle>Plan Details</AlertTitle>
19+
<AlertDescription>
20+
<p>
21+
You are currently on the{" "}
22+
<span className={badgeVariants()}>
23+
{subscription ? subscription.price.product.name : "Free"}
24+
</span>{" "}
25+
plan.{" "}
26+
{subscription ? (
27+
<>
28+
Current billing cycle:{" "}
29+
{dayjsExt(subscription?.currentPeriodStart).format("ll")} -{" "}
30+
{dayjsExt(subscription?.currentPeriodEnd).format("ll")}
31+
</>
32+
) : null}
33+
</p>
34+
</AlertDescription>
35+
</Alert>
36+
</div>
37+
);
38+
}

0 commit comments

Comments
 (0)