- Added translation support for task-related strings in ProjectTaskForm and ProjectTasksSection components. - Integrated translation for navigation items in the Navigation component. - Created ProjectCalendarWidget component with Polish translations for project statuses and deadlines. - Developed Tooltip component for enhanced user experience with tooltips. - Established a field change history logging system in the database with associated queries. - Enhanced task update logging to include translated status and priority changes. - Introduced server-side translations for system messages to improve localization.
113 lines
3.4 KiB
JavaScript
113 lines
3.4 KiB
JavaScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
import { useSession, signOut } from "next-auth/react";
|
|
import { useTranslation } from "@/lib/i18n";
|
|
import LanguageSwitcher from "./LanguageSwitcher";
|
|
|
|
const Navigation = () => {
|
|
const pathname = usePathname();
|
|
const { data: session, status } = useSession();
|
|
const { t } = useTranslation();
|
|
|
|
const isActive = (path) => {
|
|
if (path === "/") return pathname === "/";
|
|
// Exact match for paths
|
|
if (pathname === path) return true;
|
|
// For nested paths, ensure we match the full path segment
|
|
if (pathname.startsWith(path + "/")) return true;
|
|
return false;
|
|
};
|
|
|
|
const navItems = [
|
|
{ href: "/projects", label: t('navigation.projects') },
|
|
{ href: "/calendar", label: t('navigation.calendar') || 'Kalendarz' },
|
|
{ href: "/tasks/templates", label: t('navigation.taskTemplates') },
|
|
{ href: "/project-tasks", label: t('navigation.projectTasks') },
|
|
{ href: "/contracts", label: t('navigation.contracts') },
|
|
];
|
|
|
|
// Add admin-only items
|
|
if (session?.user?.role === 'admin') {
|
|
navItems.push({ href: "/admin/users", label: t('navigation.userManagement') });
|
|
}
|
|
|
|
const handleSignOut = async () => {
|
|
await signOut({ callbackUrl: "/auth/signin" });
|
|
};
|
|
|
|
// Don't show navigation on auth pages
|
|
if (pathname.startsWith('/auth/')) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<nav className="bg-white border-b border-gray-200">
|
|
<div className="max-w-6xl mx-auto px-6">
|
|
<div className="flex items-center justify-between h-16">
|
|
<div className="flex items-center">
|
|
<Link href="/projects" className="text-xl font-bold text-gray-900">
|
|
{t('navigation.projectPanel')}
|
|
</Link>
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-4">
|
|
{status === "loading" ? (
|
|
<div className="text-gray-500">{t('navigation.loading')}</div>
|
|
) : session ? (
|
|
<>
|
|
<div className="flex space-x-8">
|
|
{navItems.map((item) => (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${
|
|
isActive(item.href)
|
|
? "bg-blue-100 text-blue-700"
|
|
: "text-gray-600 hover:text-gray-900 hover:bg-gray-50"
|
|
}`}
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-4 ml-8 pl-8 border-l border-gray-200">
|
|
{/* <LanguageSwitcher /> */}
|
|
|
|
<div className="flex items-center space-x-2">
|
|
<div className="text-sm">
|
|
<div className="font-medium text-gray-900">{session.user.name}</div>
|
|
{/* <div className="text-gray-500 capitalize">{t(`userRoles.${session.user.role}`) || session.user.role?.replace('_', ' ')}</div> */}
|
|
</div>
|
|
</div>
|
|
|
|
<button
|
|
onClick={handleSignOut}
|
|
className="bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-2 rounded-md text-sm font-medium transition-colors"
|
|
>
|
|
{t('navigation.signOut')}
|
|
</button>
|
|
</div>
|
|
</>
|
|
) : (
|
|
<>
|
|
<LanguageSwitcher />
|
|
<Link
|
|
href="/auth/signin"
|
|
className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md text-sm font-medium transition-colors"
|
|
>
|
|
{t('navigation.signIn')}
|
|
</Link>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
);
|
|
};
|
|
|
|
export default Navigation;
|