2026-01-30 13:41:32 +01:00
|
|
|
'use client'
|
|
|
|
|
|
2026-02-11 13:20:52 +01:00
|
|
|
import { BookOpen, ClipboardList, GitCompare, Home, Trophy } from 'lucide-react'
|
2026-02-05 21:09:06 +01:00
|
|
|
import { RoleNav, type NavItem, type RoleNavUser } from '@/components/layouts/role-nav'
|
2026-02-08 14:37:32 +01:00
|
|
|
import { trpc } from '@/lib/trpc/client'
|
|
|
|
|
import { Badge } from '@/components/ui/badge'
|
2026-02-11 13:20:52 +01:00
|
|
|
import { useTranslations } from 'next-intl'
|
2026-01-30 13:41:32 +01:00
|
|
|
|
2026-02-05 21:09:06 +01:00
|
|
|
interface JuryNavProps {
|
|
|
|
|
user: RoleNavUser
|
|
|
|
|
}
|
2026-01-30 13:41:32 +01:00
|
|
|
|
2026-02-08 14:37:32 +01:00
|
|
|
function RemainingBadge() {
|
|
|
|
|
const { data: assignments } = trpc.assignment.myAssignments.useQuery(
|
|
|
|
|
{},
|
|
|
|
|
{ refetchInterval: 60000 }
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (!assignments) return null
|
|
|
|
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
const remaining = (assignments as Array<{
|
|
|
|
|
round: { status: string; votingStartAt: Date | null; votingEndAt: Date | null }
|
|
|
|
|
evaluation: { status: string } | null
|
|
|
|
|
}>).filter((a) => {
|
|
|
|
|
const isActive =
|
|
|
|
|
a.round.status === 'ACTIVE' &&
|
|
|
|
|
a.round.votingStartAt &&
|
|
|
|
|
a.round.votingEndAt &&
|
|
|
|
|
new Date(a.round.votingStartAt) <= now &&
|
|
|
|
|
new Date(a.round.votingEndAt) >= now
|
|
|
|
|
const isIncomplete = !a.evaluation || a.evaluation.status !== 'SUBMITTED'
|
|
|
|
|
return isActive && isIncomplete
|
|
|
|
|
}).length
|
|
|
|
|
|
|
|
|
|
if (remaining === 0) return null
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Badge variant="secondary" className="text-xs font-medium">
|
|
|
|
|
{remaining} remaining
|
|
|
|
|
</Badge>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 21:09:06 +01:00
|
|
|
export function JuryNav({ user }: JuryNavProps) {
|
2026-02-11 13:20:52 +01:00
|
|
|
const t = useTranslations('nav')
|
|
|
|
|
const navigation: NavItem[] = [
|
|
|
|
|
{
|
|
|
|
|
name: t('dashboard'),
|
|
|
|
|
href: '/jury',
|
|
|
|
|
icon: Home,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: t('assignments'),
|
|
|
|
|
href: '/jury/assignments',
|
|
|
|
|
icon: ClipboardList,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: t('awards'),
|
|
|
|
|
href: '/jury/awards',
|
|
|
|
|
icon: Trophy,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: t('compare'),
|
|
|
|
|
href: '/jury/compare',
|
|
|
|
|
icon: GitCompare,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: t('learningHub'),
|
|
|
|
|
href: '/jury/learning',
|
|
|
|
|
icon: BookOpen,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
2026-01-30 13:41:32 +01:00
|
|
|
return (
|
2026-02-05 21:09:06 +01:00
|
|
|
<RoleNav
|
|
|
|
|
navigation={navigation}
|
|
|
|
|
roleName="Jury"
|
|
|
|
|
user={user}
|
|
|
|
|
basePath="/jury"
|
2026-02-08 14:37:32 +01:00
|
|
|
statusBadge={<RemainingBadge />}
|
2026-02-05 21:09:06 +01:00
|
|
|
/>
|
2026-01-30 13:41:32 +01:00
|
|
|
)
|
|
|
|
|
}
|