Repository: mahdi6788/ai-saas
Pull request #12: implement ProModal and useProModalStore for modal management across d…
Author: login: mahdi6788
Created: 2025-05-14T00:13:32Z | Merged: 2025-05-14T00:15:46Z

…ashboard routes

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Introduced a premium upgrade modal that appears when access is restricted, offering users an option to upgrade.
  - Added a visually styled badge component and a comprehensive dialog UI for consistent modal experiences.
  - Implemented a provider to ensure modals render correctly on the client side.
  - Added a centralized tools list for consistent display of available features.

- **Enhancements**
  - The "Upgrade" button in the free usage counter now opens the upgrade modal.
  - Improved sidebar stacking behavior for better layout consistency.

- **Bug Fixes**
  - None.

- **Chores**
  - Added a new dependency for state management.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/app/(dashboard)/(routes)/code/page.tsx b/app/(dashboard)/(routes)/code/page.tsx
index 6ece610..e0914ab 100644
--- a/app/(dashboard)/(routes)/code/page.tsx
+++ b/app/(dashboard)/(routes)/code/page.tsx
@@ -18,8 +18,10 @@ import { Loader } from "@/components/Loader";
 import { cn } from "@/lib/utils";
 import { UserAvatar } from "@/components/UserAvatar";
 import { BotAvatar } from "@/components/BotAvatar";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export default function CodePage() {
+  const {onOpen} = useProModalStore()
   const router = useRouter();
   const [messages, setMessages] = useState<{ role: string; content: string }[]>(
     []
@@ -46,6 +48,7 @@ export default function CodePage() {
         messages: newMessages,
       });
 
+      if (response?.status === 403) onOpen();
       setMessages((current) => [...current, userMessage, response.data]);
       form.reset();
     } catch (error) {
diff --git a/app/(dashboard)/(routes)/conversation/page.tsx b/app/(dashboard)/(routes)/conversation/page.tsx
index 1cb488a..4bade8d 100644
--- a/app/(dashboard)/(routes)/conversation/page.tsx
+++ b/app/(dashboard)/(routes)/conversation/page.tsx
@@ -17,8 +17,10 @@ import { Loader } from "@/components/Loader";
 import { cn } from "@/lib/utils";
 import { UserAvatar } from "@/components/UserAvatar";
 import { BotAvatar } from "@/components/BotAvatar";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export default function ConversationPage() {
+  const { onOpen } = useProModalStore();
   const router = useRouter();
   const [messages, setMessages] = useState<{ role: string; content: string }[]>(
     []
@@ -45,6 +47,7 @@ export default function ConversationPage() {
         messages: newMessages,
       });
 
+      if (response?.status === 403) onOpen();
       setMessages((current) => [...current, userMessage, response.data]);
       form.reset();
     } catch (error) {
@@ -106,7 +109,7 @@ export default function ConversationPage() {
             <Empty label="No conversation started." />
           )}
           {/* flex-col-reverse : first show the latest message that is from bot and then newest user prompt and etc. */}
-          <div className="flex flex-col gap-y-4">   
+          <div className="flex flex-col gap-y-4">
             {messages.map((message) => (
               <div
                 key={message.content}
diff --git a/app/(dashboard)/(routes)/dashboard/page.tsx b/app/(dashboard)/(routes)/dashboard/page.tsx
index d12e308..d8c5aaf 100644
--- a/app/(dashboard)/(routes)/dashboard/page.tsx
+++ b/app/(dashboard)/(routes)/dashboard/page.tsx
@@ -1,55 +1,11 @@
 "use client";
 
 import { Card } from "@/components/ui/card";
+import { tools } from "@/lib/tools";
 import { cn } from "@/lib/utils";
-import {
-  ArrowRight,
-  Code,
-  ImageIcon,
-  MessageSquare,
-  Music,
-  VideoIcon,
-} from "lucide-react";
+import { ArrowRight } from "lucide-react";
 import { useRouter } from "next/navigation";
 
-const tools = [
-  {
-    icon: MessageSquare,
-    label: "Conversation",
-    color: "text-violet-500",
-    bgColor: "bg-violet-500/10",
-    href: "/conversation",
-  },
-  {
-    icon: ImageIcon,
-    label: "Image Generation",
-    href: "/image",
-    color: "text-pink-700",
-    bgColor: "bg-pink-700/10",
-  },
-  {
-    icon: VideoIcon,
-    label: "Video Generation",
-    href: "/video",
-    color: "text-orange-700",
-    bgColor: "bg-orange-700/10",
-  },
-  {
-    icon: Music,
-    label: "Music Generation",
-    href: "/music",
-    color: "text-emerald-500",
-    bgColor: "bg-emerald-500/10",
-  },
-  {
-    icon: Code,
-    label: "Code Generation",
-    href: "/code",
-    color: "text-green-700",
-    bgColor: "bg-green-700/10",
-  },
-];
-
 export default function DashboardPage() {
   const router = useRouter();
   return (
diff --git a/app/(dashboard)/(routes)/image/page.tsx b/app/(dashboard)/(routes)/image/page.tsx
index e2d37a2..35b5abd 100644
--- a/app/(dashboard)/(routes)/image/page.tsx
+++ b/app/(dashboard)/(routes)/image/page.tsx
@@ -23,8 +23,10 @@ import {
   SelectValue,
 } from "@/components/ui/select";
 import { Card, CardFooter } from "@/components/ui/card";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export default function ImagePage() {
+  const { onOpen } = useProModalStore();
   const router = useRouter();
   const [images, setImages] = useState<string[]>([]);
 
@@ -47,8 +49,12 @@ export default function ImagePage() {
 
       // const base64Strings = response.data.map(image => image.url)
 
-      const images = await response.data
-      const b64_strings = images.map((image:{b64_json:string}) => image.b64_json)
+      if (response?.status === 403) onOpen();
+
+      const images = await response.data;
+      const b64_strings = images.map(
+        (image: { b64_json: string }) => image.b64_json
+      );
 
       setImages(b64_strings);
       form.reset();
@@ -169,11 +175,17 @@ export default function ImagePage() {
             {images.map((b64_string) => (
               <Card key={b64_string} className="rounded-lg overflow-hidden">
                 <div className="relative aspect-square">
-                  <Image alt="Image" src={`data:image/png;base64,${b64_string}`} fill />
+                  <Image
+                    alt="Image"
+                    src={`data:image/png;base64,${b64_string}`}
+                    fill
+                  />
                 </div>
                 <CardFooter className="p-2">
                   <Button
-                    onClick={() => window.open(`data:image/png;base64,${b64_string}`)}
+                    onClick={() =>
+                      window.open(`data:image/png;base64,${b64_string}`)
+                    }
                     variant="secondary"
                     className="w-full "
                   >
diff --git a/app/(dashboard)/(routes)/layout.tsx b/app/(dashboard)/(routes)/layout.tsx
index 5fb7c41..0499b67 100644
--- a/app/(dashboard)/(routes)/layout.tsx
+++ b/app/(dashboard)/(routes)/layout.tsx
@@ -11,7 +11,7 @@ export default async function DashboardLayout({
 
   return (
     <div className="relative h-full">
-      <div className="hidden md:flex h-full w-72 flex-col fixed inset-y-0 z-[80] bg-gray-900">
+      <div className="hidden md:flex h-full w-72 flex-col fixed inset-y-0 bg-gray-900">
         <Sidebar apiLimitCount={apiLimitCount} />
       </div>
       <main className="md:pl-72">
diff --git a/app/(dashboard)/(routes)/music/page.tsx b/app/(dashboard)/(routes)/music/page.tsx
index 3312ade..7bb6307 100644
--- a/app/(dashboard)/(routes)/music/page.tsx
+++ b/app/(dashboard)/(routes)/music/page.tsx
@@ -14,8 +14,10 @@ import { Input } from "@/components/ui/input";
 import { Button } from "@/components/ui/button";
 import { Empty } from "@/components/Empty";
 import { Loader } from "@/components/Loader";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export default function MusicPage() {
+  const { onOpen } = useProModalStore();
   const router = useRouter();
   const [music, setMusic] = useState<string>();
 
@@ -34,6 +36,8 @@ export default function MusicPage() {
 
       const response = await axios.post("/api/music", values);
 
+      if (response?.status === 403) onOpen();
+
       setMusic(response.data.audio);
       form.reset();
     } catch (error) {
diff --git a/app/(dashboard)/(routes)/video/page.tsx b/app/(dashboard)/(routes)/video/page.tsx
index 5e33abc..389ac98 100644
--- a/app/(dashboard)/(routes)/video/page.tsx
+++ b/app/(dashboard)/(routes)/video/page.tsx
@@ -14,8 +14,10 @@ import { Input } from "@/components/ui/input";
 import { Button } from "@/components/ui/button";
 import { Empty } from "@/components/Empty";
 import { Loader } from "@/components/Loader";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export default function VideoPage() {
+  const { onOpen } = useProModalStore();
   const router = useRouter();
   const [video, setVideo] = useState<string>();
 
@@ -34,6 +36,8 @@ export default function VideoPage() {
 
       const response = await axios.post("/api/video", values);
 
+      if (response?.status === 403) onOpen();
+
       setVideo(response.data[0]);
       form.reset();
     } catch (error) {
@@ -95,7 +99,10 @@ export default function VideoPage() {
           {/* flex-col-reverse : first show the latest message that is from bot and then newest user prompt and etc. */}
 
           {video && (
-            <video controls className="w-full mt-8 aspect-video rounded-lg border bg-black">
+            <video
+              controls
+              className="w-full mt-8 aspect-video rounded-lg border bg-black"
+            >
               <source src={video} />
             </video>
           )}
diff --git a/app/layout.tsx b/app/layout.tsx
index 06f27d6..ea3c422 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -9,6 +9,7 @@ import {
   // SignedOut,
   // UserButton,
 } from "@clerk/nextjs";
+import { ModalProvider } from "@/components/ModalProvider";
 
 const geistSans = Geist({
   variable: "--font-geist-sans",
@@ -45,6 +46,7 @@ export default function RootLayout({
               <UserButton/>
             </SignedIn>
           </header> */}
+          <ModalProvider />
           {children}
         </body>
       </html>
diff --git a/components/ModalProvider.tsx b/components/ModalProvider.tsx
new file mode 100644
index 0000000..f0fc7d6
--- /dev/null
+++ b/components/ModalProvider.tsx
@@ -0,0 +1,17 @@
+"use client";
+import { useEffect, useState } from "react";
+import { ProModal } from "./ProModal";
+
+export const ModalProvider = () => {
+  const [isMounted, setIsMounted] = useState(false);
+
+  useEffect(() => {
+    setIsMounted(true);
+  }, []);
+
+  if (!isMounted) {
+    return null;
+  }
+
+  return <ProModal />;
+};
diff --git a/components/ProModal.tsx b/components/ProModal.tsx
new file mode 100644
index 0000000..ff52f47
--- /dev/null
+++ b/components/ProModal.tsx
@@ -0,0 +1,58 @@
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
+import {
+  Dialog,
+  DialogContent,
+  DialogDescription,
+  DialogFooter,
+  DialogHeader,
+  DialogTitle,
+} from "./ui/dialog";
+import { Badge } from "./ui/badge";
+import { tools } from "@/lib/tools";
+import { Card } from "./ui/card";
+import { cn } from "@/lib/utils";
+import { Check, Zap } from "lucide-react";
+import { Button } from "./ui/button";
+
+export const ProModal = () => {
+  const { isOpen, onClose } = useProModalStore();
+  return (
+    <Dialog open={isOpen} onOpenChange={onClose}>
+      <DialogContent>
+        <DialogHeader>
+          <DialogTitle className="flex flex-col items-center justify-center gap-y4 pb-2">
+            <div className="flex items-center gap-x-2 font-bold py-1">
+              Upgrade to Genius
+              <Badge variant="premium" className="uppercase text-sm py-1 ">
+                Pro
+              </Badge>
+            </div>
+          </DialogTitle>
+          <DialogDescription asChild className="text-center pt-2 space-y-2 text-zinc-900 font-medium">
+            <div className="space-y-2">
+              {tools.map((tool) => (
+                <Card key={tool.label} className=" p-3 border-black/5">
+                  <div className="flex items-center justify-between">
+                    <div className="flex items-center gap-x-4">
+                      <div className={cn("p-2 w-fit rounded-md", tool.bgColor)}>
+                        <tool.icon className={cn("w-6 h-6", tool.color)} />
+                      </div>
+                      <div className="font-semibold text-sm ">{tool.label}</div>
+                    </div>
+                    <Check className="text-primary w-5 h-5" />
+                  </div>
+                </Card>
+              ))}
+            </div>
+          </DialogDescription>
+        </DialogHeader>
+        <DialogFooter>
+          <Button variant="premium" size="lg" className="w-full">
+            Upgrade
+            <Zap className="w-4 h-4 ml-2 fill-white" />
+          </Button>
+        </DialogFooter>
+      </DialogContent>
+    </Dialog>
+  );
+};
diff --git a/components/free-counter.tsx b/components/free-counter.tsx
index 9b863f7..8ac50a3 100644
--- a/components/free-counter.tsx
+++ b/components/free-counter.tsx
@@ -6,8 +6,10 @@ import { MAX_FREE_COUNTS } from "@/constants";
 import { Progress } from "./ui/progress";
 import { Button } from "./ui/button";
 import { Zap } from "lucide-react";
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
 
 export function FreeCounter({ apiLimitCount = 0 }: { apiLimitCount: number }) {
+  const { onOpen } = useProModalStore();
   const [mounted, setMounted] = useState(false);
   useEffect(() => {
     setMounted(true);
@@ -27,7 +29,7 @@ export function FreeCounter({ apiLimitCount = 0 }: { apiLimitCount: number }) {
               value={(apiLimitCount / MAX_FREE_COUNTS) * 100}
             />
           </div>
-          <Button variant="premium" className="w-full">
+          <Button onClick={onOpen} variant="premium" className="w-full">
             Upgrade
             <Zap className="w-4 h-4 ml-2 fill-white" />
           </Button>
diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx
new file mode 100644
index 0000000..9de0282
--- /dev/null
+++ b/components/ui/badge.tsx
@@ -0,0 +1,47 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const badgeVariants = cva(
+  "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
+  {
+    variants: {
+      variant: {
+        default:
+          "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
+        secondary:
+          "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
+        destructive:
+          "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
+        outline:
+          "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
+        premium: "bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-primary-foreground border-0"
+      },
+    },
+    defaultVariants: {
+      variant: "default",
+    },
+  }
+)
+
+function Badge({
+  className,
+  variant,
+  asChild = false,
+  ...props
+}: React.ComponentProps<"span"> &
+  VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
+  const Comp = asChild ? Slot : "span"
+
+  return (
+    <Comp
+      data-slot="badge"
+      className={cn(badgeVariants({ variant }), className)}
+      {...props}
+    />
+  )
+}
+
+export { Badge, badgeVariants }
diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx
new file mode 100644
index 0000000..7d7a9d3
--- /dev/null
+++ b/components/ui/dialog.tsx
@@ -0,0 +1,135 @@
+"use client"
+
+import * as React from "react"
+import * as DialogPrimitive from "@radix-ui/react-dialog"
+import { XIcon } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+function Dialog({
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Root>) {
+  return <DialogPrimitive.Root data-slot="dialog" {...props} />
+}
+
+function DialogTrigger({
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
+  return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
+}
+
+function DialogPortal({
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
+  return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
+}
+
+function DialogClose({
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Close>) {
+  return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
+}
+
+function DialogOverlay({
+  className,
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
+  return (
+    <DialogPrimitive.Overlay
+      data-slot="dialog-overlay"
+      className={cn(
+        "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
+        className
+      )}
+      {...props}
+    />
+  )
+}
+
+function DialogContent({
+  className,
+  children,
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Content>) {
+  return (
+    <DialogPortal data-slot="dialog-portal">
+      <DialogOverlay />
+      <DialogPrimitive.Content
+        data-slot="dialog-content"
+        className={cn(
+          "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
+          className
+        )}
+        {...props}
+      >
+        {children}
+        <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
+          <XIcon />
+          <span className="sr-only">Close</span>
+        </DialogPrimitive.Close>
+      </DialogPrimitive.Content>
+    </DialogPortal>
+  )
+}
+
+function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
+  return (
+    <div
+      data-slot="dialog-header"
+      className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
+      {...props}
+    />
+  )
+}
+
+function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
+  return (
+    <div
+      data-slot="dialog-footer"
+      className={cn(
+        "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
+        className
+      )}
+      {...props}
+    />
+  )
+}
+
+function DialogTitle({
+  className,
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Title>) {
+  return (
+    <DialogPrimitive.Title
+      data-slot="dialog-title"
+      className={cn("text-lg leading-none font-semibold", className)}
+      {...props}
+    />
+  )
+}
+
+function DialogDescription({
+  className,
+  ...props
+}: React.ComponentProps<typeof DialogPrimitive.Description>) {
+  return (
+    <DialogPrimitive.Description
+      data-slot="dialog-description"
+      className={cn("text-muted-foreground text-sm", className)}
+      {...props}
+    />
+  )
+}
+
+export {
+  Dialog,
+  DialogClose,
+  DialogContent,
+  DialogDescription,
+  DialogFooter,
+  DialogHeader,
+  DialogOverlay,
+  DialogPortal,
+  DialogTitle,
+  DialogTrigger,
+}
diff --git a/hooks/use-pro-modal-store.tsx b/hooks/use-pro-modal-store.tsx
new file mode 100644
index 0000000..1f45762
--- /dev/null
+++ b/hooks/use-pro-modal-store.tsx
@@ -0,0 +1,13 @@
+import { create } from "zustand";
+
+interface useProModalStoreType {
+  isOpen: boolean;
+  onOpen: () => void;
+  onClose: () => void;
+}
+
+export const useProModalStore = create<useProModalStoreType>((set) => ({
+  isOpen: false,
+  onOpen: () => set({ isOpen: true }),
+  onClose: () => set({ isOpen: false }),
+}));
diff --git a/lib/tools.ts b/lib/tools.ts
new file mode 100644
index 0000000..1fdda6d
--- /dev/null
+++ b/lib/tools.ts
@@ -0,0 +1,45 @@
+import {
+  Code,
+  ImageIcon,
+  MessageSquare,
+  Music,
+  VideoIcon,
+} from "lucide-react";
+
+export const tools = [
+  {
+    icon: MessageSquare,
+    label: "Conversation",
+    color: "text-violet-500",
+    bgColor: "bg-violet-500/10",
+    href: "/conversation",
+  },
+  {
+    icon: ImageIcon,
+    label: "Image Generation",
+    href: "/image",
+    color: "text-pink-700",
+    bgColor: "bg-pink-700/10",
+  },
+  {
+    icon: VideoIcon,
+    label: "Video Generation",
+    href: "/video",
+    color: "text-orange-700",
+    bgColor: "bg-orange-700/10",
+  },
+  {
+    icon: Music,
+    label: "Music Generation",
+    href: "/music",
+    color: "text-emerald-500",
+    bgColor: "bg-emerald-500/10",
+  },
+  {
+    icon: Code,
+    label: "Code Generation",
+    href: "/code",
+    color: "text-green-700",
+    bgColor: "bg-green-700/10",
+  },
+];
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index cfe45ca..ed0922e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,7 +30,8 @@
         "react-markdown": "^10.1.0",
         "replicate": "^1.0.1",
         "tailwind-merge": "^3.2.0",
-        "zod": "^3.24.4"
+        "zod": "^3.24.4",
+        "zustand": "^5.0.4"
       },
       "devDependencies": {
         "@eslint/eslintrc": "^3",
@@ -10008,6 +10009,35 @@
         "zod": "^3.24.1"
       }
     },
+    "node_modules/zustand": {
+      "version": "5.0.4",
+      "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.4.tgz",
+      "integrity": "sha512-39VFTN5InDtMd28ZhjLyuTnlytDr9HfwO512Ai4I8ZABCoyAj4F1+sr7sD1jP/+p7k77Iko0Pb5NhgBFDCX0kQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=12.20.0"
+      },
+      "peerDependencies": {
+        "@types/react": ">=18.0.0",
+        "immer": ">=9.0.6",
+        "react": ">=18.0.0",
+        "use-sync-external-store": ">=1.2.0"
+      },
+      "peerDependenciesMeta": {
+        "@types/react": {
+          "optional": true
+        },
+        "immer": {
+          "optional": true
+        },
+        "react": {
+          "optional": true
+        },
+        "use-sync-external-store": {
+          "optional": true
+        }
+      }
+    },
     "node_modules/zwitch": {
       "version": "2.0.4",
       "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
diff --git a/package.json b/package.json
index 9114a7d..be15660 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,8 @@
     "react-markdown": "^10.1.0",
     "replicate": "^1.0.1",
     "tailwind-merge": "^3.2.0",
-    "zod": "^3.24.4"
+    "zod": "^3.24.4",
+    "zustand": "^5.0.4"
   },
   "devDependencies": {
     "@eslint/eslintrc": "^3",


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 4**

<details>
<summary>🔭 Outside diff range comments (1)</summary><blockquote>

<details>
<summary>app/(dashboard)/(routes)/video/page.tsx (1)</summary><blockquote>

`98-98`: _⚠️ Potential issue_

**Fix incorrect empty state message.**

The empty state message mentions "No music generated" but this is a video generation page.


```diff
-          {!video && !isLoading && <Empty label="No music generated." />}
+          {!video && !isLoading && <Empty label="No video generated." />}
```

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (9)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary><blockquote>

`3-7`: **Consider renaming the interface to follow TypeScript conventions**

The interface name `useProModalStoreType` combines a hook naming convention (`use` prefix) with a type definition, which is somewhat unusual. Consider renaming it to something like `ProModalStore` or `IProModalStore` to better align with TypeScript interface naming conventions.

```diff
-interface useProModalStoreType {
+interface ProModalStore {
  isOpen: boolean;
  onOpen: () => void;
  onClose: () => void;
}
```

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/music/page.tsx (1)</summary><blockquote>

`39-40`: **Consider adding braces and user feedback for 403 errors**

For better readability and maintainability, consider adding curly braces to the if statement. Also, you might want to provide some user feedback about why the operation failed before opening the modal.

```diff
-      if (response?.status === 403) onOpen();
+      if (response?.status === 403) {
+        // Indicate to the user that this requires a Pro subscription
+        onOpen();
+      }
```

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/code/page.tsx (2)</summary><blockquote>

`24-24`: **Add spaces in destructuring for consistent style**

For consistent code style, consider adding spaces in the destructuring assignment.

```diff
-  const {onOpen} = useProModalStore()
+  const { onOpen } = useProModalStore()
```

---

`51-51`: **Consider adding braces around the conditional code block**

For better readability and consistency with coding standards, consider adding curly braces to the if statement.

```diff
-      if (response?.status === 403) onOpen();
+      if (response?.status === 403) {
+        onOpen();
+      }
```

</blockquote></details>
<details>
<summary>lib/tools.ts (1)</summary><blockquote>

`9-45`: **Consider adding a TypeScript interface for tool objects**

For better type safety and documentation, consider defining a TypeScript interface for the tool objects.

```diff
import {
  Code,
  ImageIcon,
  MessageSquare,
  Music,
  VideoIcon,
} from "lucide-react";
+import { LucideIcon } from "lucide-react";
+
+interface Tool {
+  icon: LucideIcon;
+  label: string;
+  color: string;
+  bgColor: string;
+  href: string;
+}

-export const tools = [
+export const tools: Tool[] = [
  {
    icon: MessageSquare,
    label: "Conversation",
    color: "text-violet-500",
    bgColor: "bg-violet-500/10",
    href: "/conversation",
  },
  // ...rest of the code
```

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/image/page.tsx (1)</summary><blockquote>

`54-57`: **Consider adding error handling for response data processing**

The response data extraction is working correctly, but there's no validation that the expected structure exists before accessing properties.

Consider adding a safeguard:

```diff
-      const images = await response.data;
-      const b64_strings = images.map(
-        (image: { b64_json: string }) => image.b64_json
-      );
+      const images = await response.data;
+      const b64_strings = Array.isArray(images) 
+        ? images.map((image: { b64_json: string }) => 
+            image && image.b64_json ? image.b64_json : '')
+        : [];
```

</blockquote></details>
<details>
<summary>components/ProModal.tsx (2)</summary><blockquote>

`23-30`: **Modal title could benefit from more semantic HTML structure**

The DialogTitle contains nested div elements that could be simplified for better accessibility.

Consider simplifying the title structure:

```diff
-          <DialogTitle className="flex flex-col items-center justify-center gap-y4 pb-2">
-            <div className="flex items-center gap-x-2 font-bold py-1">
-              Upgrade to Genius
-              <Badge variant="premium" className="uppercase text-sm py-1 ">
-                Pro
-              </Badge>
-            </div>
-          </DialogTitle>
+          <DialogTitle className="flex items-center justify-center gap-x-2 font-bold pb-2">
+            Upgrade to Genius
+            <Badge variant="premium" className="uppercase text-sm py-1">
+              Pro
+            </Badge>
+          </DialogTitle>
```

---

`17-58`: **Consider adding a loading state for the upgrade button**

When implementing the upgrade functionality, the button should have a loading state to prevent multiple clicks during processing.

Consider adding a loading state:

```diff
+import { useState } from "react";
+
 export const ProModal = () => {
   const { isOpen, onClose } = useProModalStore();
+  const [isLoading, setIsLoading] = useState(false);
+
+  const onUpgrade = async () => {
+    try {
+      setIsLoading(true);
+      // Upgrade logic here
+    } catch (error) {
+      console.error("Error upgrading:", error);
+    } finally {
+      setIsLoading(false);
+    }
+  };

   return (
     // ...Dialog content
         <DialogFooter>
-          <Button variant="premium" size="lg" className="w-full">
+          <Button 
+            onClick={onUpgrade}
+            disabled={isLoading}
+            variant="premium" 
+            size="lg" 
+            className="w-full"
+          >
-            Upgrade
+            {isLoading ? "Processing..." : "Upgrade"}
             <Zap className="w-4 h-4 ml-2 fill-white" />
           </Button>
         </DialogFooter>
```

</blockquote></details>
<details>
<summary>components/ui/dialog.tsx (1)</summary><blockquote>

`65-69`: **Consider improving close button focus styles**

The close button has a complex set of styles including focus styles, but it uses `focus:outline-hidden` which might impact keyboard accessibility.

Consider adjusting the focus styles:

```diff
-        <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
+        <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 376831b653e3d384a9f634b35b13afd64e62a3a6 and 5a025ca285fa68472826c599611c656ce9d88556.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `package-lock.json` is excluded by `!**/package-lock.json`

</details>

<details>
<summary>📒 Files selected for processing (16)</summary>

* `app/(dashboard)/(routes)/code/page.tsx` (2 hunks)
* `app/(dashboard)/(routes)/conversation/page.tsx` (3 hunks)
* `app/(dashboard)/(routes)/dashboard/page.tsx` (1 hunks)
* `app/(dashboard)/(routes)/image/page.tsx` (3 hunks)
* `app/(dashboard)/(routes)/layout.tsx` (1 hunks)
* `app/(dashboard)/(routes)/music/page.tsx` (2 hunks)
* `app/(dashboard)/(routes)/video/page.tsx` (3 hunks)
* `app/layout.tsx` (2 hunks)
* `components/ModalProvider.tsx` (1 hunks)
* `components/ProModal.tsx` (1 hunks)
* `components/free-counter.tsx` (2 hunks)
* `components/ui/badge.tsx` (1 hunks)
* `components/ui/dialog.tsx` (1 hunks)
* `hooks/use-pro-modal-store.tsx` (1 hunks)
* `lib/tools.ts` (1 hunks)
* `package.json` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (8)</summary>

<details>
<summary>app/layout.tsx (1)</summary><blockquote>

<details>
<summary>components/ModalProvider.tsx (1)</summary>

* `ModalProvider` (5-17)

</details>

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/video/page.tsx (1)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

* `useProModalStore` (9-13)

</details>

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/conversation/page.tsx (1)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

* `useProModalStore` (9-13)

</details>

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/code/page.tsx (1)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

* `useProModalStore` (9-13)

</details>

</blockquote></details>
<details>
<summary>app/(dashboard)/(routes)/music/page.tsx (1)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

* `useProModalStore` (9-13)

</details>

</blockquote></details>
<details>
<summary>components/ui/badge.tsx (1)</summary><blockquote>

<details>
<summary>lib/utils.ts (1)</summary>

* `cn` (4-6)

</details>

</blockquote></details>
<details>
<summary>components/ui/dialog.tsx (1)</summary><blockquote>

<details>
<summary>lib/utils.ts (1)</summary>

* `cn` (4-6)

</details>

</blockquote></details>
<details>
<summary>components/ProModal.tsx (7)</summary><blockquote>

<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

* `useProModalStore` (9-13)

</details>
<details>
<summary>components/ui/dialog.tsx (6)</summary>

* `Dialog` (125-125)
* `DialogContent` (127-127)
* `DialogHeader` (130-130)
* `DialogTitle` (133-133)
* `DialogDescription` (128-128)
* `DialogFooter` (129-129)

</details>
<details>
<summary>components/ui/badge.tsx (1)</summary>

* `Badge` (47-47)

</details>
<details>
<summary>lib/tools.ts (1)</summary>

* `tools` (9-45)

</details>
<details>
<summary>components/ui/card.tsx (1)</summary>

* `Card` (85-85)

</details>
<details>
<summary>lib/utils.ts (1)</summary>

* `cn` (4-6)

</details>
<details>
<summary>components/ui/button.tsx (1)</summary>

* `Button` (60-60)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (32)</summary><blockquote>

<details>
<summary>package.json (1)</summary>

`34-35`: **Added zustand dependency for state management**

The addition of zustand (v5.0.4) as a dependency is appropriate for implementing the modal state management system. Zustand is a lightweight state management library that works well with React and Next.js applications.

</details>
<details>
<summary>app/(dashboard)/(routes)/layout.tsx (1)</summary>

`14-14`: **Removed z-index from sidebar for proper modal stacking**

The removal of the `z-[80]` class from the sidebar container is appropriate for ensuring the new modal system can properly overlay the entire UI without z-index conflicts. This change allows the modal to establish its own stacking context without competing with the sidebar.

</details>
<details>
<summary>app/layout.tsx (1)</summary>

`12-12`: **Added ModalProvider to root layout**

Good implementation of the modal provider at the root layout level. This approach ensures the modal can be triggered from any component in the application. The provider is correctly placed before the children to ensure proper component hierarchy.



Also applies to: 49-49

</details>
<details>
<summary>components/free-counter.tsx (2)</summary>

`9-9`: **Added ProModal hook integration**

Importing and using the `useProModalStore` hook is the correct approach for accessing the modal's state management functions. The destructuring of `onOpen` from the hook follows React best practices.



Also applies to: 12-12

---

`32-32`: **Connected Upgrade button to modal**

The implementation correctly connects the "Upgrade" button to the modal opening function. This change completes the integration of the free counter component with the new modal system.

</details>
<details>
<summary>components/ModalProvider.tsx (1)</summary>

`1-17`: **Clean implementation of a client-side modal provider.**

The `ModalProvider` component correctly implements the Next.js pattern for client-side only rendering using the `isMounted` state pattern. This prevents hydration issues by not rendering the modal during server-side rendering.

For future iterations, consider making this component more reusable by accepting children props instead of directly rendering a specific modal component.

</details>
<details>
<summary>app/(dashboard)/(routes)/conversation/page.tsx (1)</summary>

`20-23`: **Good implementation of the Pro modal hook.**

The import and usage of `useProModalStore` looks clean and follows React best practices by destructuring only what's needed.

</details>
<details>
<summary>app/(dashboard)/(routes)/dashboard/page.tsx (1)</summary>

`4-6`: **Good refactoring to centralize tool definitions.**

Extracting the `tools` array to a separate module is a good practice for maintainability and reuse. This also correctly simplifies the imports from lucide-react.

</details>
<details>
<summary>app/(dashboard)/(routes)/video/page.tsx (2)</summary>

`17-20`: **Good implementation of the Pro modal hook.**

The import and usage of `useProModalStore` looks clean and follows React best practices.

---

`102-108`: **Video tag formatting improved for better readability.**

The explicit opening and closing video tags are more readable than the self-closing version, making it clearer what elements are nested inside.

</details>
<details>
<summary>hooks/use-pro-modal-store.tsx (1)</summary>

`9-13`: **Implementation looks good**

The Zustand store implementation is clean, follows best practices, and provides a simple, focused API for managing modal state.

</details>
<details>
<summary>lib/tools.ts (1)</summary>

`1-8`: **Good job centralizing tool definitions**

Centralizing tool definitions in a single module improves maintainability and reduces duplication across components.

</details>
<details>
<summary>app/(dashboard)/(routes)/image/page.tsx (5)</summary>

`26-26`: **Good addition of the Pro Modal store hook**

The import of `useProModalStore` is correctly placed at the top of the file with other imports.

---

`29-29`: **Appropriately destructured `onOpen` from the store**

Using object destructuring for the `onOpen` method from the store follows React best practices for working with hooks.

---

`52-53`: **Well-implemented permission check**

The conditional check for HTTP 403 status followed by the modal trigger is a clean approach to handle premium feature access restrictions.

---

`178-182`: **Improved Image component formatting**

The formatting changes to the Image component improve code readability without changing functionality.

---

`186-189`: **Improved button onClick handler formatting**

The formatting changes to the Button onClick handler improve code readability.

</details>
<details>
<summary>components/ProModal.tsx (4)</summary>

`1-16`: **Well-organized imports**

The imports are properly organized and grouped by their source locations. The component imports related UI primitives from the dialog, badge, and button components, along with necessary icons and utilities.

---

`17-19`: **Proper store integration for modal state management**

The component correctly uses the `useProModalStore` hook to manage modal state, destructuring `isOpen` and `onClose` for controlling visibility.

---

`20-21`: **Dialog properly configured with open state and close handler**

The Dialog component is correctly configured with the `open` and `onOpenChange` props connected to the store state and handler.

---

`31-47`: **Good use of mapping for feature display**

The dynamic rendering of tools using the `map` function is efficient and maintainable. The component correctly uses the tools array to display features in a consistent format.

</details>
<details>
<summary>components/ui/badge.tsx (4)</summary>

`1-6`: **Well-organized imports with proper dependencies**

The imports are clearly organized with React and necessary utilities from external libraries.

---

`7-27`: **Well-defined badge variants with comprehensive styling**

The badge variants are well-defined using class-variance-authority with appropriate styling for different states and appearances. The premium variant has a nice gradient styling that stands out.

---

`29-45`: **Well-implemented component with asChild support**

The Badge component is properly implemented with support for the `asChild` prop using Radix UI's Slot component, allowing for flexible composition.

---

`47-47`: **Appropriate exports**

Both the Badge component and badgeVariants are correctly exported, allowing for reuse of the variants in other components if needed.

</details>
<details>
<summary>components/ui/dialog.tsx (7)</summary>

`1-8`: **Proper client directive and imports**

The "use client" directive is correctly placed at the top, and imports are well-organized with React, Radix UI dialog primitives, and necessary icons.

---

`9-32`: **Well-implemented basic dialog components**

The Dialog, DialogTrigger, DialogPortal, and DialogClose components are correctly implemented as thin wrappers around Radix UI primitives with appropriate data attributes.

---

`33-47`: **Well-designed overlay with animation**

The DialogOverlay component is properly implemented with animation states and appropriate styling for the background overlay.

---

`49-73`: **Accessible dialog content with close button**

The DialogContent component correctly composes the dialog portal, overlay, and content with appropriate animations and accessibility features. The close button includes an icon and screen reader text.

---

`75-96`: **Responsive header and footer components**

The DialogHeader and DialogFooter components are correctly implemented with responsive layouts that adapt to different screen sizes, using flexbox appropriately.

---

`98-122`: **Well-styled title and description components**

The DialogTitle and DialogDescription components properly extend the Radix UI primitives with appropriate typography styles.

---

`124-135`: **Complete component exports**

All dialog-related components are correctly exported for use in other components.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-14T00:16:57Z

Review comments:
diff_hunk: @@ -45,6 +47,7 @@ export default function ConversationPage() {
         messages: newMessages,
       });
 
+      if (response?.status === 403) onOpen();
path: app/(dashboard)/(routes)/conversation/page.tsx
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Add braces to the conditional and improve error handling.**

While the conditional works, it would be better to use braces for maintainability. Also, there's inconsistent null checking between the response status check and data usage.


```diff
-      if (response?.status === 403) onOpen();
+      if (response?.status === 403) {
+        onOpen();
+      }
```

Also consider adding the same check in the catch block, as 403 responses might sometimes throw errors:

```typescript
catch (error: any) {
  console.log(error);
  if (error?.response?.status === 403) {
    onOpen();
  }
}
```

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-14T00:16:56Z
author_association: NONE
diff_hunk: @@ -106,7 +109,7 @@ export default function ConversationPage() {
             <Empty label="No conversation started." />
           )}
           {/* flex-col-reverse : first show the latest message that is from bot and then newest user prompt and etc. */}
-          <div className="flex flex-col gap-y-4">   
+          <div className="flex flex-col gap-y-4">
path: app/(dashboard)/(routes)/conversation/page.tsx
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Verify the intended message display order.**

The class changed from `flex-col-reverse` to `flex-col`, which affects the display order of messages. However, the comment on line 111 mentions "flex-col-reverse : first show the latest message", suggesting reverse order was intentional.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if other route files use flex-col or flex-col-reverse for message display
rg "flex flex-col-reverse" --type tsx
rg "flex flex-col " --type tsx
```

Length of output: 128

---

The previous `rg --type tsx` call failed because `tsx` isn’t defined as a file type. Let’s re-run without the type filter and inspect the surrounding lines in the conversation page to confirm whether the old comment was left unchanged:

---

🏁 Script executed:

```shell
#!/bin/bash
set -e

# Find any remaining uses of flex-col-reverse
rg "flex-col-reverse" -n .

# Show lines 105–115 of the conversation page to verify the in-file comment vs. the new class
sed -n '105,115p' "app/(dashboard)/(routes)/conversation/page.tsx"
```

Length of output: 1483

---



</details>

**Review message display order**

The inline comment on line 111 still refers to `flex-col-reverse`, but the wrapper now uses `flex-col`, which flips the rendering order. Please:

• Decide if you intend to show newest-first (reverse chronological) or oldest-first (natural).  
• If you want reverse order, revert the wrapper to `className="flex flex-col-reverse gap-y-4"` or explicitly reverse the `messages` array in code.  
• If you want oldest-first, remove or update the inline `flex-col-reverse` comment here and in the other routes (music, image, code, video) to avoid confusion.

Locations to adjust:  
- app/(dashboard)/(routes)/conversation/page.tsx (line 111)  
- app/(dashboard)/(routes)/music/page.tsx  
- app/(dashboard)/(routes)/image/page.tsx  
- app/(dashboard)/(routes)/code/page.tsx  
- app/(dashboard)/(routes)/video/page.tsx

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-14T00:16:56Z
author_association: NONE
diff_hunk: @@ -34,6 +36,8 @@ export default function VideoPage() {
 
       const response = await axios.post("/api/video", values);
 
+      if (response?.status === 403) onOpen();
+
path: app/(dashboard)/(routes)/video/page.tsx
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Add braces to the conditional and improve error handling.**

Similar to the conversation page, the conditional should use braces for maintainability and better error handling.


```diff
-      if (response?.status === 403) onOpen();
+      if (response?.status === 403) {
+        onOpen();
+      }
```

Also consider adding similar handling in the catch block:

```typescript
catch (error: any) {
  console.log(error);
  if (error?.response?.status === 403) {
    onOpen();
  }
}
```

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-14T00:16:57Z
author_association: NONE
diff_hunk: @@ -0,0 +1,58 @@
+import { useProModalStore } from "@/hooks/use-pro-modal-store";
+import {
+  Dialog,
+  DialogContent,
+  DialogDescription,
+  DialogFooter,
+  DialogHeader,
+  DialogTitle,
+} from "./ui/dialog";
+import { Badge } from "./ui/badge";
+import { tools } from "@/lib/tools";
+import { Card } from "./ui/card";
+import { cn } from "@/lib/utils";
+import { Check, Zap } from "lucide-react";
+import { Button } from "./ui/button";
+
+export const ProModal = () => {
+  const { isOpen, onClose } = useProModalStore();
+  return (
+    <Dialog open={isOpen} onOpenChange={onClose}>
+      <DialogContent>
+        <DialogHeader>
+          <DialogTitle className="flex flex-col items-center justify-center gap-y4 pb-2">
+            <div className="flex items-center gap-x-2 font-bold py-1">
+              Upgrade to Genius
+              <Badge variant="premium" className="uppercase text-sm py-1 ">
+                Pro
+              </Badge>
+            </div>
+          </DialogTitle>
+          <DialogDescription asChild className="text-center pt-2 space-y-2 text-zinc-900 font-medium">
+            <div className="space-y-2">
+              {tools.map((tool) => (
+                <Card key={tool.label} className=" p-3 border-black/5">
+                  <div className="flex items-center justify-between">
+                    <div className="flex items-center gap-x-4">
+                      <div className={cn("p-2 w-fit rounded-md", tool.bgColor)}>
+                        <tool.icon className={cn("w-6 h-6", tool.color)} />
+                      </div>
+                      <div className="font-semibold text-sm ">{tool.label}</div>
+                    </div>
+                    <Check className="text-primary w-5 h-5" />
+                  </div>
+                </Card>
+              ))}
+            </div>
+          </DialogDescription>
+        </DialogHeader>
+        <DialogFooter>
+          <Button variant="premium" size="lg" className="w-full">
+            Upgrade
+            <Zap className="w-4 h-4 ml-2 fill-white" />
+          </Button>
+        </DialogFooter>
path: components/ProModal.tsx
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Missing functionality in upgrade button**

The upgrade button is styled correctly but doesn't have any functionality attached to it.

Is there a plan to implement the actual upgrade functionality for this button? Currently, it's only visual without any action when clicked.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if there are other components or files that might handle the upgrade functionality
echo "Searching for upgrade-related functionality in components"
rg -A 3 "Upgrade" --type ts --type tsx | grep -v "ProModal.tsx"
```

Length of output: 214

---

🏁 Script executed:

```shell
#!/bin/bash
# Searching for upgrade-related functionality in TypeScript and JavaScript files, excluding ProModal.tsx
rg -i -n upgrade -g "*.ts" -g "*.tsx" -g "*.js" -g "*.jsx" -C3 | grep -v "components/ProModal.tsx" || echo "No other occurrences found"
```

Length of output: 545

---

```bash
#!/bin/bash
# Display the top of ProModal.tsx to inspect its props and handlers
sed -n '1,80p' components/ProModal.tsx
```

---

```bash
#!/bin/bash
# Inspect ProModal.tsx component definition to see available props and handlers
sed -n '1,80p' components/ProModal.tsx
```

---

🏁 Script executed:

```shell
#!/bin/bash
# Inspect the ProModal component signature and props to see if an upgrade handler is expected
sed -n '1,100p' components/ProModal.tsx
```

Length of output: 2134

---



</details>

**Add click handler to Upgrade button in ProModal**

The “Upgrade” button in `components/ProModal.tsx` (around lines 49–54) is purely visual—it has no `onClick` or other handler to initiate the upgrade flow. Clicking it won’t trigger any action.

• File: `components/ProModal.tsx`  
  Location:  
  ```tsx
  <DialogFooter>
    <Button variant="premium" size="lg" className="w-full">
      Upgrade
      <Zap className="w-4 h-4 ml-2 fill-white" />
    </Button>
  </DialogFooter>
  ```

Suggested fix:  
• Define and import an `handleUpgrade` (or similar) function that kicks off your payment/plan upgrade flow.  
• Add it as an `onClick` to the button:

```diff
<DialogFooter>
- <Button variant="premium" size="lg" className="w-full">
+ <Button
+   variant="premium"
+   size="lg"
+   className="w-full"
+   onClick={handleUpgrade}
+ >
    Upgrade
    <Zap className="w-4 h-4 ml-2 fill-white" />
</Button>
```

This will ensure the button actually performs the intended upgrade action rather than just displaying UI.

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-14T00:16:57Z
author_association: NONE

PR comments:
user: login: vercel[bot]
created_at: 2025-05-14T00:13:37Z
body: [vc]: #+jIQ4B1ikqCGQRxTTZBmgwuCcrEuiNpT4DOSpsZTZbk=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJnZW5pdXMiLCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vbWFoZGktZGV2cy1wcm9qZWN0cy9nZW5pdXMvRnJHWWFqUVZNZXFzVjJHZkdYbWtMUExtMTc3dyIsInByZXZpZXdVcmwiOiJnZW5pdXMtZ2l0LXByb21vZGFsLW1haGRpLWRldnMtcHJvamVjdHMudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJnZW5pdXMtZ2l0LXByb21vZGFsLW1haGRpLWRldnMtcHJvamVjdHMudmVyY2VsLmFwcCJ9LCJyb290RGlyZWN0b3J5IjpudWxsfV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **genius** | ✅ Ready ([Inspect](https://vercel.com/mahdi-devs-projects/genius/FrGYajQVMeqsV2GfGXmkLPLm177w)) | [Visit Preview](https://genius-git-promodal-mahdi-devs-projects.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/genius-git-promodal-mahdi-devs-projects.vercel.app?via=pr-comment-feedback-link) | May 14, 2025 0:14am |


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-05-14T00:13:40Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This change introduces a new modal system for handling "Pro" upgrade prompts across multiple dashboard routes. It adds a Zustand-powered modal store, a reusable `ProModal` component, and a `ModalProvider` to the app layout. Several page components now trigger the modal when a 403 API response is received. The `tools` array is externalized for consistent use.

## Changes

| Files/Group                                                                                 | Change Summary                                                                                                                                                                                                                                                                                                                                                   |
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `components/ui/badge.tsx`                                                                  | Added a new `Badge` UI component with multiple style variants for consistent badge rendering.                                                                                                                                                                                                                                                                   |
| `components/ui/dialog.tsx`                                                                 | Introduced a new dialog component module based on Radix UI, providing styled, accessible dialog primitives for use in modals.                                                                                                                                                                                                                                   |
| `components/ProModal.tsx`                                                                  | Added a new `ProModal` component displaying a premium upgrade prompt, using the `tools` array and new UI primitives.                                                                                                                                                                                                                                            |
| `components/ModalProvider.tsx`                                                             | Added a `ModalProvider` component to ensure modals render only on the client side after mount.                                                                                                                                                                                                                                                                  |
| `hooks/use-pro-modal-store.tsx`                                                            | Introduced a Zustand store hook `useProModalStore` to manage modal open/close state and expose handlers.                                                                                                                                                                                                                                                        |
| `lib/tools.ts`                                                                             | Added a new `tools` array module containing tool metadata for consistent use across the app.                                                                                                                                                                                                                                                                    |
| `app/layout.tsx`                                                                           | Inserted `ModalProvider` into the root layout to enable global modal support.                                                                                                                                                                                                                                                                                   |
| `components/free-counter.tsx`                                                              | Updated to open the Pro modal when the "Upgrade" button is clicked, using the new modal store.                                                                                                                                                                                                                                                                  |
| `app/(dashboard)/(routes)/code/page.tsx`<br>`app/(dashboard)/(routes)/conversation/page.tsx`<br>`app/(dashboard)/(routes)/image/page.tsx`<br>`app/(dashboard)/(routes)/music/page.tsx`<br>`app/(dashboard)/(routes)/video/page.tsx` | Updated each page to import and use `useProModalStore`, triggering the Pro modal when a 403 API response is encountered. Minor formatting changes in some files.                                                                                                                   |
| `app/(dashboard)/(routes)/dashboard/page.tsx`                                              | Refactored to import the `tools` array from `@/lib/tools` instead of local declaration; reduced icon imports accordingly.                                                                                                                                                                                               |
| `app/(dashboard)/(routes)/layout.tsx`                                                      | Removed the `z-[80]` CSS class from the sidebar container, altering its stacking context.                                                                                                                                                                                                                                |
| `package.json`                                                                             | Added the `zustand` dependency for state management.                                                                                                                                                                                                                                                                                                            |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant PageComponent
    participant API
    participant useProModalStore
    participant ProModal

    User->>PageComponent: Submit form (e.g., generate code/image)
    PageComponent->>API: POST request
    API-->>PageComponent: Response (status 403)
    PageComponent->>useProModalStore: onOpen()
    useProModalStore-->>ProModal: isOpen = true
    ProModal-->>User: Show "Upgrade to Pro" modal
```

## Possibly related PRs

- [mahdi6788/ai-saas#3](https://github.com/mahdi6788/ai-saas/pull/3): Externalizes the `tools` array, which is now imported and used across the app for tool metadata.
- [mahdi6788/ai-saas#4](https://github.com/mahdi6788/ai-saas/pull/4): Modifies the same conversation page's `onSubmit` handler, now extended to show the Pro modal on 403 errors.

## Poem

> 🐇  
> A modal hops in with a premium glow,  
> When 403 says "no", now users know!  
> Zustand keeps state, while badges shine bright,  
> Tools line up neatly, all labeled just right.  
> Upgrade, dear friend, let your journey begin—  
> With dialogs and badges, success hops in!  
>

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡️ Faster reviews with caching</summary>
> 
> - CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure `Review - Disable Cache` at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the `Data Retention` setting under your Organization Settings.
> 
> Enjoy the performance boost—your workflow just got faster.
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACJ4Zm5ItgxQqwp8AFlFNF9MemxEElSMrK8AZQJ/SAAzfD5mEshmTDRSJNC0BjTEZFo0RFgBfGd6NLxpaMgAdz77bAFmdRp6OTDYD3zKRrRYWngANgB2AA4j9GRub19/IJDIDEcBTYBGACYNGDXGWExSZBqGfL8LDwZJpWjYBggojoBTxfDkZJ3NBsehFTK9HJeeHQybqWAwgGIAjMSCwfD4ADW/D4RNqHgY2UieQKaJK5Tp73cBXQtF24nhyG0JIIWwwLQ89QxkF22XwRGQTAwiCQNGSXnkHS6yAkzng+EBvX6g2Gfn1NGQuNwCCwVo8aG4CXgDP5GE5nyUiE68G4Lp4aQk8CU9FQAgo8BIVXQGGD0ad1Gkq2oqw8cQSJDa1D1wOQINVQbC+EgZG+GAYEoaTTFrXY1WwpZd2XU8itoyIZLwyelfQGQwo9AKYizyHwkdtfvwIjEbo8Fx8fkCwSJjEwkEe84DJEmURB0pIuG0OVCY4AqjYADJcWC4XDcRAcAD096IeLmGiYzHvTR2+2OR3v2jARA0D6e9Zy8e9Xg0Ix9GMcAoDIegRxwAhiDIZQllhNouF4fhhFEcQpBkeQmCUKhVHULQdBgkwoDgVBUBXNA8EIUhyCoDD3ywvw0EmWYnBcVdiMUZRyM0bRdDAQxYNMAx7W4e8AApDR7YYAEpFNGc11JIkhQPFDRcEQAAPDgDGicyDAsSAAEEAElULY+N+0cJoBKQhgS1+NxPg8n4U1BRQIQTMdU1qdpo0gfJxX4SM0EgAADDZWQxdl/Hi0lySpEUx3igBhYSrHFdL324eF2HeWylUDDwc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GpEwCdYeoi80AmpDr1GDJlbWfARlluNPZIgAwRABRLAH8CfQSsbsE2L2j6xIMYwpfD1KCiBhVxuo4OaKNHRkxdRIAQnaqFHVaE/jLiG8L8byNDZ7wPAoEgXD2I6D4hS8Ag9ChhGjK7BDCaSJ0MXCjhrip4x0NgHIKQSfdKgqAIFnEx8rjgmSMRQFNQFPpNx/uOXN8v4ArgYRec3IDMW+mrK8jLBv+WYrMxcE9kLqEjK6oV3oDFcixqLddBGK4AFpFUwAAAN7oSMAXAPThoHygYtoAsgcGDPUTo2drxRAbqFhIoDaSVxq4JWvuMMknsLxEYMyW7AAC+kFbXOmIjGZiQxoeUpLon0hCAvoCk5oTc1aH9d7mHZSDJbhIBUw7EDAauiqA+quSKQ7kzyRfxmBMiMIKwB9sBzIK/CO4bAXcCFLIBhSuAY4KKdFGiBPp+h0YCYEmB/gGxogAAPQACsGgJ6BoAejRAyK8AjlsFIGalht4TcJQBIDNpZSOpiHf5AFK0ERR18p/RdlrChiUSr0Q5BiuGAxRsSDqHEzYkIx4m2D1OrZTTkYAgJHMpINEduIhFijMRYxd1FgFxCoC8RgSAkFYDpDIhqAxIVESSAYD2mcR1AAAfUDCIBXphTcMFuFoCvSboDcCSLtLgiQBqpaAJ6C8GqkMgXgRwaqdbj2BHAHoBwGGS8D2AMBqpAATgxl7AngTwBgHsGqloySAGM2gCcGqmEygZ0kKAC9NwDvTOYX0kgBuF+mvSEIQMoAA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=mahdi6788/ai-saas&utm_content=12):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE