mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
d4168b45f2
Gate assignment and team actions by permissions, limit client and end-user images to 2 MB, and make the technical status end date optional. Also update status remark handling and rename the Task navigation label.
60 lines
2.5 KiB
TypeScript
60 lines
2.5 KiB
TypeScript
'use client'
|
|
import { HTMLAttributes } from "react"
|
|
import Link from "next/link"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { usePathname } from "next/navigation"
|
|
import { useSession } from "next-auth/react"
|
|
|
|
export function MainNav({ className, ...props }: HTMLAttributes<HTMLElement>) {
|
|
const pathname = usePathname()
|
|
const { data: session } = useSession()
|
|
|
|
const getMenuActiveStyle = (path: string) => {
|
|
if (pathname?.startsWith(path) && (pathname !== '' && pathname !== '/') && (path !== '' && path !== '/')) {
|
|
return 'font-semibold text-primary border-b-[3px] border-his'
|
|
} else {
|
|
if (path === pathname) {
|
|
return 'font-semibold text-primary border-b-[3px] border-his'
|
|
}
|
|
}
|
|
return 'text-muted-foreground'
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<nav className={cn("hidden md:flex items-center space-x-4 lg:space-x-6 h-16", className)} {...props}>
|
|
<Link
|
|
href="/" prefetch
|
|
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/')}`}
|
|
>
|
|
<i className="ti ti-layers-linked text-base mr-0.5"></i>
|
|
Overview
|
|
</Link>
|
|
<Link
|
|
href="/history" prefetch
|
|
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/history')}`}
|
|
>
|
|
<i className="ti ti-history-toggle text-base mr-0.5"></i>
|
|
History
|
|
</Link>
|
|
<Link
|
|
href="/task" prefetch
|
|
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/task')}`}
|
|
>
|
|
<i className="ti ti-checklist text-base mr-0.5"></i>
|
|
Task
|
|
</Link>
|
|
{session?.user.detail.role.allow_admin_panel &&
|
|
<Link
|
|
href="/admin" prefetch title="Go to Admin Panel"
|
|
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/admin')}`}
|
|
>
|
|
<i className="ti ti-spy text-base mr-0.5"></i>
|
|
Admin Panel
|
|
</Link>
|
|
}
|
|
</nav>
|
|
</>
|
|
)
|
|
} |