diff --git a/apps/web/src/lib/pricing.constants.ts b/apps/web/src/lib/pricing.constants.ts index 9a1e972..589d353 100644 --- a/apps/web/src/lib/pricing.constants.ts +++ b/apps/web/src/lib/pricing.constants.ts @@ -29,6 +29,13 @@ export type PricingPlan = { * ! Changing these values will change the pricing of the plans in Stripe. * ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ */ + +export const MAX_BLOGS_PER_PLAN: Record = { + free: 1, + hobby: 3, + pro: 100, +}; + export const PRICING_PLANS: PricingPlan[] = [ // ALWAYS KEEP FREE PLAN FIRST IN THE ARRAY { @@ -55,7 +62,7 @@ export const PRICING_PLANS: PricingPlan[] = [ monthlyPrice: 29, yearlyPrice: 288, // will be divided by 12 in pricing page features: [ - "2 blogs", + `${MAX_BLOGS_PER_PLAN.hobby} blogs`, "3 authors", "Unlimited posts", "Unlimited categories", diff --git a/apps/web/src/pages/blogs/create.tsx b/apps/web/src/pages/blogs/create.tsx index 1938c31..8b99c5c 100644 --- a/apps/web/src/pages/blogs/create.tsx +++ b/apps/web/src/pages/blogs/create.tsx @@ -1,19 +1,17 @@ import AppLayout from "@/layouts/AppLayout"; -import { generateSlug } from "@/lib/utils/slugs"; import { useBlogsQuery, useCreateBlogMutation } from "@/queries/blogs"; import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; -import Link from "next/link"; import { Textarea } from "@/components/ui/textarea"; import { toast } from "sonner"; import { Smile } from "lucide-react"; -import { RESERVED_SLUGS } from "@/lib/constants"; import { useSubscriptionQuery } from "@/queries/subscription"; import { SubscribeSection } from "../account"; +import { MAX_BLOGS_PER_PLAN } from "@/lib/pricing.constants"; export default function CreateBlog() { const DEFAULT_EMOJI = "📝"; @@ -67,56 +65,52 @@ export default function CreateBlog() { return ; } - if ( - (subscription?.plan === "free" || !subscription?.isValidSubscription) && - totalBlogs >= 1 - ) { - return ( - -
-

-
- -
- - You have reached the blog limit for your plan. - -

-
-

- Update your plan to create more blogs. -

-
-
-
- -
-
-
- ); - } + // if ( + // (subscription?.plan === "free" || !subscription?.isValidSubscription) && + // totalBlogs >= 1 + // ) { + // return ( + // + //
+ //

+ //
+ // + //
+ // + // You have reached the blog limit for your plan. + // + //

+ //
+ //

+ // Update your plan to create more blogs. + //

+ //
+ //
+ //
+ // + //
+ //
+ //
+ // ); + // } if ( - subscription?.plan === "hobby" && - subscription?.isValidSubscription && - totalBlogs >= 2 + subscription?.plan && + totalBlogs >= MAX_BLOGS_PER_PLAN[subscription.plan] ) { return ( -
-

+
+

- The Hobby plan can only create 2 blogs + The {subscription.plan} plan can only create{" "} + {MAX_BLOGS_PER_PLAN[subscription.plan]}{" "} + {MAX_BLOGS_PER_PLAN[subscription.plan] === 1 ? "blog" : "blogs"}

-
-

- Subscribe to the Pro Plan to create more blogs. -

-