Fix round deletion FK constraint with migration and defensive code

- Add SQL migration to CASCADE Evaluation.formId and SET NULL ProjectFile.roundId
- Explicitly delete evaluations in round delete transaction as defensive measure
- Make sidebar Apply Page link dynamic using current edition context

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 20:42:33 +01:00
parent 5c4200158f
commit 573785e440
3 changed files with 30 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ import {
import { getInitials } from '@/lib/utils'
import { Logo } from '@/components/shared/logo'
import { EditionSelector } from '@/components/shared/edition-selector'
import { useEdition } from '@/contexts/edition-context'
import { UserAvatar } from '@/components/shared/user-avatar'
import { NotificationBell } from '@/components/shared/notification-bell'
import { trpc } from '@/lib/trpc/client'
@@ -145,10 +146,19 @@ export function AdminSidebar({ user }: AdminSidebarProps) {
const pathname = usePathname()
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false)
const { data: avatarUrl } = trpc.avatar.getUrl.useQuery()
const { currentEdition } = useEdition()
const isSuperAdmin = user.role === 'SUPER_ADMIN'
const roleLabel = roleLabels[user.role || ''] || 'User'
// Build dynamic admin nav with current edition's apply page
const dynamicAdminNav = adminNavigation.map((item) => {
if (item.name === 'Apply Page' && currentEdition?.id) {
return { ...item, href: `/admin/programs/${currentEdition.id}/apply-settings` }
}
return item
})
return (
<>
{/* Mobile menu button */}
@@ -235,7 +245,7 @@ export function AdminSidebar({ user }: AdminSidebarProps) {
<p className="mb-2 px-3 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/60">
Administration
</p>
{adminNavigation.map((item) => {
{dynamicAdminNav.map((item) => {
let isActive = pathname.startsWith(item.href)
if (item.activeMatch) {
isActive = pathname.includes(item.activeMatch)