diff --git a/components/shared/Sidebar.tsx b/components/shared/Sidebar.tsx index 4fa38b8f..5cbe9171 100644 --- a/components/shared/Sidebar.tsx +++ b/components/shared/Sidebar.tsx @@ -1,43 +1,51 @@ -import { useState } from "react"; +import Link from "next/link"; +import { useRouter } from "next/router"; + import Button from "./Button"; import HomeIcon from "./Icon/group/home"; import NewsIcon from "./Icon/group/news"; import RoomsIcon from "./Icon/group/rooms"; + import { cn } from "@/lib/utils"; -enum SidebarActive { - NEWS = "news", - HOME = "home", - ROOMS = "rooms", +enum SidebarRoutes { + HOME = "/", + ROOMS = "/rooms", + NEWS = "/news", } export default function Sidebar() { - const [selected, setSelected] = useState(SidebarActive.NEWS); + const router = useRouter(); + const { pathname } = router; const buttons = [ - { text: "公告", Icon: NewsIcon, type: SidebarActive.NEWS }, - { text: "遊戲大廳", Icon: HomeIcon, type: SidebarActive.HOME }, - { text: "遊戲房間", Icon: RoomsIcon, type: SidebarActive.ROOMS }, + { text: "公告", Icon: NewsIcon, route: SidebarRoutes.NEWS }, + { text: "遊戲大廳", Icon: HomeIcon, route: SidebarRoutes.HOME }, + { text: "遊戲房間", Icon: RoomsIcon, route: SidebarRoutes.ROOMS }, ]; return ( );