turkmen-expo/components/ui/Sidebar.tsx

56 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

2025-10-12 17:42:17 +00:00
"use client";
import React from "react";
import clsx from "clsx";
import { useTranslations } from "next-intl";
2025-10-12 17:42:17 +00:00
import { sidebarData } from "@/lib/database/pathnames";
import { Link, usePathname } from "@/i18n/navigation";
2025-10-12 17:42:17 +00:00
export const Sidebar = () => {
const pathname = usePathname();
const t = useTranslations();
2025-10-12 17:42:17 +00:00
return (
<div className="flex flex-col bg-white rounded-lg px-6 py-4 items-start gap-y-[12px] pb-5 mt-12 sticky top-0 left-0 overflow-hidden">
{sidebarData
.filter(
(obj) =>
(pathname === "/company/aboutus" && obj.company) ||
(pathname.includes("/members") && obj.members) ||
(pathname.includes("/news") && obj.news) ||
(pathname.includes("/visitors") && obj.visitors) ||
(pathname.includes("/services") && obj.services)
)
.map((item, i) => (
<div key={i}>
<p
className={clsx("mb-[16px] text-[16px] font-bold leading-[1.5]")}
>
{t(item.pathnameKey)}
2025-10-12 17:42:17 +00:00
</p>
<div className="flex flex-col items-start gap-y-[8px]">
<div className="flex flex-col gap-[10px] pl-4 pr-10">
{item.info.map((obj, i) => (
<Link
href={obj.link}
className={clsx(
"cursor-pointer py-1 leading-[130%] transition-all hover:opacity-80",
{
"hover:text-PRIMARY text-PRIMARY hover:cursor-default":
obj.link === pathname,
}
)}
key={i}
>
{t(obj.titleKey)}
2025-10-12 17:42:17 +00:00
</Link>
))}
</div>
</div>
</div>
))}
</div>
);
};