From 8ae5933d299510efb3094ba8ef72a2cd14c4beee Mon Sep 17 00:00:00 2001 From: Mandeep Singh Date: Mon, 24 Jun 2024 00:48:39 +0530 Subject: [PATCH 1/2] Integrate the Stripe Subscriptions API as the payment gateway --- app/(root)/create-podcast/page.tsx | 126 ++++--- app/(root)/layout.tsx | 3 - app/(root)/profile/[profileId]/page.tsx | 1 + app/layout.tsx | 12 +- app/plans/page.tsx | 479 ++++++++++++++++++++++++ components/ButtonSpinner.tsx | 25 ++ components/GenerateThumbnail.tsx | 114 ++++-- components/LeftSidebar.tsx | 5 +- components/ProfileCard.tsx | 35 +- components/ui/toast.tsx | 2 + constants/index.ts | 87 +++++ convex/_generated/api.d.ts | 10 +- convex/crons.ts | 13 + convex/http.ts | 23 ++ convex/openai.ts | 173 ++++++++- convex/payments.ts | 30 ++ convex/podcasts.ts | 64 +++- convex/schema.ts | 29 +- convex/stripe.ts | 281 ++++++++++++++ convex/tasks.ts | 8 - convex/users.ts | 157 +++++++- convex/util.ts | 9 + hooks/useIsSubscribed.ts | 36 ++ lib/rateLimits.ts | 16 + package-lock.json | 62 ++- package.json | 6 +- providers/IsFetchingProvider.tsx | 31 ++ public/icons/chart.svg | 6 + public/icons/premium.svg | 249 ++++++++++++ public/images/blueBlob.svg | 69 ++++ types/index.ts | 6 + 31 files changed, 2046 insertions(+), 121 deletions(-) create mode 100644 app/plans/page.tsx create mode 100644 components/ButtonSpinner.tsx create mode 100644 convex/crons.ts create mode 100644 convex/payments.ts create mode 100644 convex/stripe.ts delete mode 100644 convex/tasks.ts create mode 100644 convex/util.ts create mode 100644 hooks/useIsSubscribed.ts create mode 100644 lib/rateLimits.ts create mode 100644 providers/IsFetchingProvider.tsx create mode 100644 public/icons/chart.svg create mode 100644 public/icons/premium.svg create mode 100644 public/images/blueBlob.svg diff --git a/app/(root)/create-podcast/page.tsx b/app/(root)/create-podcast/page.tsx index be32cec..eac0840 100644 --- a/app/(root)/create-podcast/page.tsx +++ b/app/(root)/create-podcast/page.tsx @@ -24,16 +24,18 @@ import { SelectValue, } from "@/components/ui/select" import { cn } from "@/lib/utils" -import { useState } from "react" +import { use, useState } from "react" import { Textarea } from "@/components/ui/textarea" import GeneratePodcast from "@/components/GeneratePodcast" import GenerateThumbnail from "@/components/GenerateThumbnail" -import { Loader } from "lucide-react" +import { Loader, Lock, LockKeyhole } from "lucide-react" import { Id } from "@/convex/_generated/dataModel" import { useToast } from "@/components/ui/use-toast" import { useMutation } from "convex/react" import { api } from "@/convex/_generated/api" import { useRouter } from "next/navigation" +import { useIsSubscribed } from "@/hooks/useIsSubscribed" +import { useClerk } from "@clerk/nextjs" const voiceCategories = ['alloy', 'shimmer', 'nova', 'echo', 'fable', 'onyx']; @@ -59,6 +61,10 @@ const CreatePodcast = () => { const createPodcast = useMutation(api.podcasts.createPodcast) + const { user } = useClerk(); + + const isSubscribed = useIsSubscribed(user?.id!); + const { toast } = useToast() // 1. Define your form. @@ -114,16 +120,25 @@ const CreatePodcast = () => {

Create Podcast

- +
( - Title + + Title + - + @@ -136,12 +151,30 @@ const CreatePodcast = () => {