"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { Switch } from "@/components/ui/switch" import { Users, Settings, Target, MessageSquare, Plus, Edit, Trash2, Shield, Database, Bell } from "lucide-react" // Mock data with colors const users = [ { id: 1, name: "陳雅雯", email: "sarah.chen@company.com", role: "executive", status: "active", lastLogin: "2024-02-10", department: "業務部", position: "業務副總", color: "emerald", }, { id: 2, name: "王志明", email: "mike.wang@company.com", role: "manager", status: "active", lastLogin: "2024-02-09", department: "技術部", position: "技術長", color: "blue", }, { id: 3, name: "李美玲", email: "lisa.lee@company.com", role: "executive", status: "inactive", lastLogin: "2024-01-28", department: "行銷部", position: "行銷長", color: "purple", }, { id: 4, name: "張建國", email: "john.chang@company.com", role: "manager", status: "active", lastLogin: "2024-02-08", department: "研發部", position: "研發總監", color: "orange", }, ] const kpiTemplates = [ { id: 1, name: "營收成長率", category: "財務", defaultWeight: 30, isActive: true, usageCount: 15, color: "emerald" }, { id: 2, name: "團隊滿意度", category: "團隊", defaultWeight: 25, isActive: true, usageCount: 12, color: "blue" }, { id: 3, name: "市場佔有率", category: "營運", defaultWeight: 20, isActive: true, usageCount: 8, color: "purple" }, { id: 4, name: "創新指數", category: "創新", defaultWeight: 25, isActive: false, usageCount: 3, color: "orange" }, { id: 5, name: "客戶滿意度", category: "營運", defaultWeight: 20, isActive: true, usageCount: 10, color: "cyan" }, { id: 6, name: "成本控制率", category: "財務", defaultWeight: 15, isActive: true, usageCount: 6, color: "red" }, ] const questionTemplates = [ { id: 1, question: "您如何評價本季度的整體表現?", type: "評分", category: "績效", isRequired: true, color: "blue" }, { id: 2, question: "本期間您的主要成就是什麼?", type: "文字", category: "績效", isRequired: true, color: "emerald" }, { id: 3, question: "您面臨了哪些挑戰,如何克服?", type: "文字", category: "挑戰", isRequired: false, color: "yellow", }, { id: 4, question: "您如何有效領導團隊?", type: "評分", category: "領導力", isRequired: true, color: "purple" }, { id: 5, question: "下一季度的目標是什麼?", type: "文字", category: "目標", isRequired: true, color: "orange" }, ] const systemSettings = [ { id: 1, name: "自動提醒", description: "自動發送審查提醒通知", enabled: true, category: "通知" }, { id: 2, name: "郵件通知", description: "透過郵件發送系統通知", enabled: true, category: "通知" }, { id: 3, name: "資料備份", description: "每日自動備份系統資料", enabled: true, category: "安全" }, { id: 4, name: "雙重驗證", description: "要求使用者啟用雙重驗證", enabled: false, category: "安全" }, { id: 5, name: "審計日誌", description: "記錄所有系統操作日誌", enabled: true, category: "安全" }, ] export default function AdminPanel() { const [activeTab, setActiveTab] = useState("users") const [isDialogOpen, setIsDialogOpen] = useState(false) const [dialogType, setDialogType] = useState("") const handleOpenDialog = (type: string) => { setDialogType(type) setIsDialogOpen(true) } const adminStats = { totalUsers: users.length, activeUsers: users.filter((u) => u.status === "active").length, totalKPIs: kpiTemplates.length, activeKPIs: kpiTemplates.filter((k) => k.isActive).length, totalQuestions: questionTemplates.length, requiredQuestions: questionTemplates.filter((q) => q.isRequired).length, } return (
{/* Header */}
公司 Logo

系統管理中心

用戶、模板與系統設定管理

{/* Stats Cards */}
總用戶
{adminStats.totalUsers}
活躍用戶
{adminStats.activeUsers}
KPI 模板
{adminStats.totalKPIs}
啟用 KPI
{adminStats.activeKPIs}
審查問題
{adminStats.totalQuestions}
必填問題
{adminStats.requiredQuestions}
{/* Main Content */} 系統管理 管理用戶、模板和系統設定 用戶管理 KPI 模板 審查問題 系統設定 {/* Users Tab */}

用戶管理

用戶 部門/職位 角色 狀態 最後登入 操作 {users.map((user) => (
{user.name.charAt(0)}
{user.name}
{user.email}
{user.department}
{user.position}
{user.role === "executive" ? "高階主管" : user.role === "manager" ? "經理" : "HR"} {user.status === "active" ? "啟用" : "停用"} {user.lastLogin}
))}
{/* KPI Templates Tab */}

KPI 模板管理

{kpiTemplates.map((template) => (
{template.name} {template.isActive ? "啟用" : "停用"}
類別: {template.category}
預設權重: {template.defaultWeight}%
使用次數: {template.usageCount}
))}
{/* Questions Tab */}

審查問題管理

{questionTemplates.map((question) => (
{question.category} {question.type} {question.isRequired && ( 必填 )}

{question.question}

))}
{/* Settings Tab */}

系統設定

{systemSettings.map((setting) => (

{setting.name}

{setting.category}

{setting.description}

))}
{/* Dialog for various actions */} {dialogType === "user" ? "新增用戶" : dialogType === "kpi" ? "新增 KPI 模板" : dialogType === "question" ? "新增審查問題" : "備份資料"} {dialogType === "user" ? "建立新的系統用戶帳號" : dialogType === "kpi" ? "建立新的 KPI 模板" : dialogType === "question" ? "建立新的審查問題" : "備份系統資料到安全位置"}
{dialogType === "user" && ( <>
)} {dialogType === "kpi" && ( <>
)} {dialogType === "question" && ( <>