"use client" import { useState } from "react" import { useAuth } from "@/contexts/auth-context" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Alert, AlertDescription } from "@/components/ui/alert" import { Badge } from "@/components/ui/badge" import { CheckCircle, AlertTriangle, Loader2, User, Camera } from "lucide-react" interface ProfileDialogProps { open: boolean onOpenChange: (open: boolean) => void } export function ProfileDialog({ open, onOpenChange }: ProfileDialogProps) { const { user, updateProfile } = useAuth() const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState("") const [success, setSuccess] = useState("") const [profileData, setProfileData] = useState({ name: user?.name || "", email: user?.email || "", department: user?.department || "", bio: user?.bio || "", phone: user?.phone || "", location: user?.location || "", }) const departments = ["HQBU", "ITBU", "MBU1", "MBU2", "SBU", "財務部", "人資部", "法務部"] const handleSave = async () => { setError("") setSuccess("") setIsLoading(true) try { await updateProfile(profileData) setSuccess("個人資料更新成功!") setTimeout(() => setSuccess(""), 3000) } catch (err) { setError("更新失敗,請稍後再試") } finally { setIsLoading(false) } } return ( 個人資料 管理您的個人資料和帳號設定
{error && ( {error} )} {success && ( {success} )}
{user?.name?.charAt(0) || "U"}

{user?.name}

{user?.email}

{user?.department}
setProfileData({ ...profileData, name: e.target.value })} />
setProfileData({ ...profileData, email: e.target.value })} />
setProfileData({ ...profileData, phone: e.target.value })} placeholder="輸入電話號碼" />
setProfileData({ ...profileData, location: e.target.value })} placeholder="輸入工作地點" />
setProfileData({ ...profileData, bio: e.target.value })} placeholder="簡單介紹一下自己..." />
) }