"use client"; import React from "react"; import { useRouter } from "next/navigation"; import { Sparkles, X } from "lucide-react"; interface UpgradePromptProps { /** Which plan the user needs to unlock the feature */ requiredPlan?: "Creator" | "Studio"; /** Short description of the feature the user tried to access */ feature?: string; /** Optional; if set the prompt shows inline, otherwise it auto-hides after 8 s */ variant?: "banner" | "toast"; /** Called when the user dismisses the prompt */ onDismiss?: () => void; } /** * A small upgrade prompt shown when a user tries to use a feature * that requires an upgrade. */ export default function UpgradePrompt({ requiredPlan = "Creator", feature = "this feature", variant = "banner", onDismiss, }: UpgradePromptProps) { const router = useRouter(); const [visible, setVisible] = React.useState(true); // Auto-dismiss after 8 seconds for the toast variant React.useEffect(() => { if (variant !== "toast") return; const id = setTimeout(() => { setVisible(false); onDismiss?.(); }, 8000); return () => clearTimeout(id); }, [variant, onDismiss]); if (!visible) return null; return (
{feature} requires the {requiredPlan} plan. {" "}
{onDismiss && ( )}
); }