150 lines
5.7 KiB
TypeScript
150 lines
5.7 KiB
TypeScript
"use client"
|
||
|
||
import { useState } from "react"
|
||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||
import { Button } from "@/components/ui/button"
|
||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||
import { Input } from "@/components/ui/input"
|
||
import { Label } from "@/components/ui/label"
|
||
import { Textarea } from "@/components/ui/textarea"
|
||
import { Badge } from "@/components/ui/badge"
|
||
import { Calendar } from "@/components/ui/calendar"
|
||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
||
import { Camera, CalendarIcon, Save } from "lucide-react"
|
||
import { cn } from "@/lib/utils"
|
||
import { format } from "date-fns"
|
||
|
||
export default function Page() {
|
||
const [date, setDate] = useState<Date>()
|
||
const [profileData, setProfileData] = useState({
|
||
name: "张三",
|
||
email: "zhangsan@example.com",
|
||
phone: "+86 138 0013 8000",
|
||
bio: "这是我的个人简介,我是一名前端开发工程师,热爱技术和创新。",
|
||
location: "北京市朝阳区",
|
||
website: "https://zhangsan.dev",
|
||
company: "科技有限公司",
|
||
})
|
||
|
||
return (
|
||
<div className="space-y-6 p-4">
|
||
<div>
|
||
<h2 className="text-2xl font-bold tracking-tight">个人资料</h2>
|
||
<p className="text-muted-foreground">管理您的个人信息和公开资料</p>
|
||
</div>
|
||
|
||
<Card>
|
||
<CardHeader>
|
||
<CardTitle>基本信息</CardTitle>
|
||
<CardDescription>更新您的个人资料信息</CardDescription>
|
||
</CardHeader>
|
||
<CardContent className="space-y-6">
|
||
<div className="flex items-center space-x-4">
|
||
<Avatar className="h-20 w-20">
|
||
<AvatarImage src="/placeholder.svg?height=80&width=80" />
|
||
<AvatarFallback>张三</AvatarFallback>
|
||
</Avatar>
|
||
<div className="space-y-2">
|
||
<Button variant="outline" size="sm" className="gap-2 bg-transparent">
|
||
<Camera className="h-4 w-4" />
|
||
更换头像
|
||
</Button>
|
||
<p className="text-sm text-muted-foreground">推荐尺寸:400x400px,支持 JPG、PNG 格式</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||
<div className="space-y-2">
|
||
<Label htmlFor="name">姓名</Label>
|
||
<Input
|
||
id="name"
|
||
value={profileData.name}
|
||
onChange={(e) => setProfileData({ ...profileData, name: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<Label htmlFor="email">邮箱</Label>
|
||
<div className="flex items-center space-x-2">
|
||
<Input
|
||
id="email"
|
||
type="email"
|
||
value={profileData.email}
|
||
onChange={(e) => setProfileData({ ...profileData, email: e.target.value })}
|
||
/>
|
||
<Badge variant="secondary">已验证</Badge>
|
||
</div>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<Label htmlFor="phone">手机号</Label>
|
||
<Input
|
||
id="phone"
|
||
value={profileData.phone}
|
||
onChange={(e) => setProfileData({ ...profileData, phone: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<Label htmlFor="company">公司</Label>
|
||
<Input
|
||
id="company"
|
||
value={profileData.company}
|
||
onChange={(e) => setProfileData({ ...profileData, company: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<Label htmlFor="location">所在地</Label>
|
||
<Input
|
||
id="location"
|
||
value={profileData.location}
|
||
onChange={(e) => setProfileData({ ...profileData, location: e.target.value })}
|
||
/>
|
||
</div>
|
||
<div className="space-y-2">
|
||
<Label htmlFor="website">个人网站</Label>
|
||
<Input
|
||
id="website"
|
||
value={profileData.website}
|
||
onChange={(e) => setProfileData({ ...profileData, website: e.target.value })}
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="space-y-2">
|
||
<Label htmlFor="bio">个人简介</Label>
|
||
<Textarea
|
||
id="bio"
|
||
placeholder="介绍一下您自己..."
|
||
className="min-h-[100px]"
|
||
value={profileData.bio}
|
||
onChange={(e) => setProfileData({ ...profileData, bio: e.target.value })}
|
||
/>
|
||
<p className="text-sm text-muted-foreground">{profileData.bio.length}/500 字符</p>
|
||
</div>
|
||
|
||
<div className="space-y-2">
|
||
<Label>生日</Label>
|
||
<Popover>
|
||
<PopoverTrigger asChild>
|
||
<Button
|
||
variant="outline"
|
||
className={cn("w-full justify-start text-left font-normal", !date && "text-muted-foreground")}
|
||
>
|
||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||
{date ? format(date, "yyyy年MM月dd日") : "选择日期"}
|
||
</Button>
|
||
</PopoverTrigger>
|
||
<PopoverContent className="w-auto p-0">
|
||
<Calendar mode="single" selected={date} onSelect={setDate} initialFocus />
|
||
</PopoverContent>
|
||
</Popover>
|
||
</div>
|
||
|
||
<Button className="gap-2">
|
||
<Save className="h-4 w-4" />
|
||
保存更改
|
||
</Button>
|
||
</CardContent>
|
||
</Card>
|
||
</div>
|
||
)
|
||
}
|