'use client' import { ClipboardCheck, FileCheck2, type LucideIcon, } from 'lucide-react' import { useRouter, useSearchParams } from 'next/navigation' import { useEffect, useState } from 'react' import DepartmentShell from './DepartmentShell' type AutomationWorkflowKey = 'performance-survey' | 'work-review' type AutomationWorkflow = { key: AutomationWorkflowKey title: string description: string href: string icon: LucideIcon } const AUTOMATION_WORKFLOWS: AutomationWorkflow[] = [ { key: 'performance-survey', title: '绩效考核调研', description: '考核问卷、填报与结果管理', href: '/performance-survey', icon: ClipboardCheck, }, { key: 'work-review', title: '作品过稿看板', description: '作品提交、评审与退修流转', href: '/work-review', icon: FileCheck2, }, ] function normalizeWorkflow(value: string | null): AutomationWorkflowKey { return value === 'work-review' ? 'work-review' : 'performance-survey' } export default function AutomationWorkflowsDashboard() { const router = useRouter() const searchParams = useSearchParams() const requestedWorkflow = normalizeWorkflow(searchParams.get('workflow')) const [activeWorkflowKey, setActiveWorkflowKey] = useState(requestedWorkflow) const activeWorkflow = AUTOMATION_WORKFLOWS.find((workflow) => workflow.key === activeWorkflowKey) || AUTOMATION_WORKFLOWS[0] useEffect(() => { setActiveWorkflowKey(requestedWorkflow) }, [requestedWorkflow]) const selectWorkflow = (workflow: AutomationWorkflow) => { if (workflow.key === activeWorkflowKey) return setActiveWorkflowKey(workflow.key) router.replace(`/workspaces/assets/automation-workflows?workflow=${workflow.key}`, { scroll: false }) } return (