Skip to content

Commit

Permalink
max 2 posts on free tier
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtouha committed Feb 21, 2024
1 parent 0a53a48 commit 65297bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
14 changes: 3 additions & 11 deletions src/app/(main)/dashboard/_components/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { NewPost } from "./new-post";
import { PostCard } from "./post-card";

interface PostsProps {
promises: Promise<
[RouterOutputs["post"]["myPosts"], RouterOutputs["stripe"]["getPlan"]]
>;
promises: Promise<[RouterOutputs["post"]["myPosts"], RouterOutputs["stripe"]["getPlan"]]>;
}

export function Posts({ promises }: PostsProps) {
Expand Down Expand Up @@ -49,17 +47,11 @@ export function Posts({ promises }: PostsProps) {
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
<NewPost
isEligible={
(optimisticPosts.length < 3 || subscriptionPlan?.isPro) ?? false
}
isEligible={(optimisticPosts.length < 2 || subscriptionPlan?.isPro) ?? false}
setOptimisticPosts={setOptimisticPosts}
/>
{optimisticPosts.map((post) => (
<PostCard
key={post.id}
post={post}
setOptimisticPosts={setOptimisticPosts}
/>
<PostCard key={post.id} post={post} setOptimisticPosts={setOptimisticPosts} />
))}
</div>
);
Expand Down
22 changes: 6 additions & 16 deletions src/app/(main)/dashboard/billing/_components/billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ export async function Billing({ stripePromises }: BillingProps) {
<>
<section>
<Card className="space-y-2 p-8">
<h3 className="text-lg font-semibold sm:text-xl">
{plan?.name ?? "Free"} plan
</h3>
<h3 className="text-lg font-semibold sm:text-xl">{plan?.name ?? "Free"} plan</h3>
<p className="text-sm text-muted-foreground">
{!plan?.isPro
? "The free plan is limited to 3 posts. Upgrade to the Pro plan to unlock unlimited posts."
? "The free plan is limited to 2 posts. Upgrade to the Pro plan to unlock unlimited posts."
: plan.isCanceled
? "Your plan will be canceled on "
: "Your plan renews on "}
{plan?.stripeCurrentPeriodEnd
? formatDate(plan.stripeCurrentPeriodEnd)
: null}
{plan?.stripeCurrentPeriodEnd ? formatDate(plan.stripeCurrentPeriodEnd) : null}
</p>
</Card>
</section>
Expand All @@ -48,26 +44,20 @@ export async function Billing({ stripePromises }: BillingProps) {
<Card key={item.name} className="flex flex-col p-2">
<CardHeader className="h-full">
<CardTitle className="line-clamp-1">{item.name}</CardTitle>
<CardDescription className="line-clamp-2">
{item.description}
</CardDescription>
<CardDescription className="line-clamp-2">{item.description}</CardDescription>
</CardHeader>
<CardContent className="h-full flex-1 space-y-6">
<div className="text-3xl font-bold">
{item.price}
<span className="text-sm font-normal text-muted-foreground">
/month
</span>
<span className="text-sm font-normal text-muted-foreground">/month</span>
</div>
<div className="space-y-2">
{item.features.map((feature) => (
<div key={feature} className="flex items-center gap-2">
<div className="aspect-square shrink-0 rounded-full bg-foreground p-px text-background">
<CheckIcon className="size-4" aria-hidden="true" />
</div>
<span className="text-sm text-muted-foreground">
{feature}
</span>
<span className="text-sm text-muted-foreground">{feature}</span>
</div>
))}
</div>
Expand Down

0 comments on commit 65297bc

Please sign in to comment.