import { useState, useEffect } from "react" import { useRouter, usePathname } from "next/navigation" import { cn } from "@/lib/utils" interface GuideCommunityToggleProps { topicName: string } export const GuideCommunityToggle: React.FC = ({ topicName }) => { const router = useRouter() const pathname = usePathname() const [view, setView] = useState<"guide" | "community">("guide") useEffect(() => { setView(pathname.includes("/community/") ? "community" : "guide") }, [pathname]) const handleToggle = (newView: "guide" | "community") => { setView(newView) router.push(newView === "community" ? `/community/${topicName}` : `/${topicName}`) } return (
) }