blob: 2e70aeba356ecd801738ca6c679ed1f22eaf2eba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// components/MobileMenu.tsx
"use client";
import * as React from "react";
import Link from "next/link";
import { useRouter, usePathname } from "next/navigation";
import { MenuSection, mainNav, additionalNav, MenuItem, mainNavVendor, additionalNavVendor } from "@/config/menuConfig";
import { cn } from "@/lib/utils";
import { Drawer, DrawerContent, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer";
import { Button } from "@/components/ui/button";
interface MobileMenuProps {
lng: string;
onClose: () => void;
}
export function MobileMenu({ lng, onClose }: MobileMenuProps) {
const router = useRouter();
const handleLinkClick = (href: string) => {
router.push(href);
onClose();
};
const pathname = usePathname();
const isPartnerRoute = pathname?.includes("/partners");
const main = isPartnerRoute ? mainNavVendor : mainNav;
const additional = isPartnerRoute ? additionalNavVendor : additionalNav;
return (
<Drawer open={true} onOpenChange={onClose}>
<DrawerTrigger asChild>
</DrawerTrigger>
<DrawerTitle />
<DrawerContent className="max-h-[60vh] p-0">
<div className="overflow-auto p-6">
<nav>
<ul className="space-y-4">
{/* 메인 네비게이션 섹션 */}
{main.map((section: MenuSection) => (
<li key={section.title}>
<h3 className="text-md font-medium">{section.title}</h3>
<ul className="mt-2 space-y-2">
{section.items.map((item: MenuItem) => (
<li key={item.title}>
<Link
href={`/${lng}${item.href}`}
className="text-indigo-600"
onClick={() => handleLinkClick(item.href)}
>
{item.title}
{item.label && (
<span className="ml-2 rounded-md bg-[#adfa1d] px-1.5 py-0.5 text-xs text-[#000000]">
{item.label}
</span>
)}
</Link>
{item.description && (
<p className="text-xs text-gray-500">{item.description}</p>
)}
</li>
))}
</ul>
</li>
))}
{/* 추가 네비게이션 항목 */}
{additional.map((item: MenuItem) => (
<li key={item.title}>
<Link
href={item.href}
className="block text-sm text-indigo-600"
onClick={() => handleLinkClick(`/${lng}${item.href}`)}
>
{item.title}
</Link>
</li>
))}
</ul>
</nav>
</div>
</DrawerContent>
</Drawer>
);
}
|