|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import clsx from "clsx"; |
| 4 | +import Link from "next/link"; |
| 5 | +import { usePathname } from "next/navigation"; |
| 6 | +import { MdHome } from "react-icons/md"; |
| 7 | +import { MdNotificationsNone } from "react-icons/md"; |
| 8 | +import { MdSupervisedUserCircle } from "react-icons/md"; |
| 9 | +import { MdQuestionMark } from "react-icons/md"; |
| 10 | + |
| 11 | +// Map of links to display in the side navigation. |
| 12 | +// Depending on the size of the application, this would be stored in a database. |
| 13 | +const links = [ |
| 14 | + { name: "ホーム", href: "/admin", icon: MdHome }, |
| 15 | + { |
| 16 | + name: "ユーザー一覧", |
| 17 | + href: "/admin/users", |
| 18 | + icon: MdSupervisedUserCircle, |
| 19 | + }, |
| 20 | + { |
| 21 | + name: "お知らせ配信", |
| 22 | + href: "/admin/notification", |
| 23 | + icon: MdNotificationsNone, |
| 24 | + }, |
| 25 | + { |
| 26 | + name: "お問い合わせ", |
| 27 | + href: "/admin/question", |
| 28 | + icon: MdQuestionMark, |
| 29 | + }, |
| 30 | +]; |
| 31 | + |
| 32 | +export default function NavLinks() { |
| 33 | + const pathname = usePathname(); |
| 34 | + |
| 35 | + return ( |
| 36 | + <> |
| 37 | + {links.map((link) => { |
| 38 | + const LinkIcon = link.icon; |
| 39 | + return ( |
| 40 | + <Link |
| 41 | + key={link.name} |
| 42 | + href={link.href} |
| 43 | + className={clsx( |
| 44 | + "flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 font-medium text-sm hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3", |
| 45 | + { |
| 46 | + "bg-sky-100 text-blue-600": pathname === link.href, |
| 47 | + }, |
| 48 | + )} |
| 49 | + > |
| 50 | + <LinkIcon className="w-6" /> |
| 51 | + <p className="hidden md:block">{link.name}</p> |
| 52 | + </Link> |
| 53 | + ); |
| 54 | + })} |
| 55 | + </> |
| 56 | + ); |
| 57 | +} |
0 commit comments