refactor(auth): unify current user state usage across UI
This commit is contained in:
@@ -11,12 +11,11 @@ import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { Switch } from "@/components/ui/switch"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
import { currentUser } from "@/lib/mock"
|
||||
import type { UserRole } from "@/lib/types"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { currentRole, verifiedRoles, switchRole } = useAuthStore()
|
||||
const { currentRole, verifiedRoles, switchRole, user } = useAuthStore()
|
||||
|
||||
const isRoleVerified = (role: UserRole) => verifiedRoles.includes(role)
|
||||
|
||||
@@ -31,8 +30,8 @@ export default function SettingsPage() {
|
||||
<CardContent className="flex items-center gap-4">
|
||||
<div className="relative">
|
||||
<Avatar className="h-20 w-20">
|
||||
<AvatarImage src={currentUser.avatar} />
|
||||
<AvatarFallback className="text-lg">{currentUser.nickname[0]}</AvatarFallback>
|
||||
<AvatarImage src={user?.avatar} />
|
||||
<AvatarFallback className="text-lg">{user?.nickname?.[0] ?? "?"}</AvatarFallback>
|
||||
</Avatar>
|
||||
<button
|
||||
type="button"
|
||||
@@ -52,15 +51,15 @@ export default function SettingsPage() {
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nickname">昵称</Label>
|
||||
<Input id="nickname" defaultValue={currentUser.nickname} />
|
||||
<Input id="nickname" defaultValue={user?.nickname ?? ""} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="bio">个人简介</Label>
|
||||
<Textarea id="bio" defaultValue={currentUser.bio} rows={3} />
|
||||
<Textarea id="bio" defaultValue={user?.bio ?? ""} rows={3} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="phone">手机号</Label>
|
||||
<Input id="phone" defaultValue={currentUser.phone} disabled />
|
||||
<Input id="phone" defaultValue={user?.phone ?? ""} disabled />
|
||||
<p className="text-xs text-muted-foreground">如需更换手机号请联系客服</p>
|
||||
</div>
|
||||
<Button>保存修改</Button>
|
||||
|
||||
Reference in New Issue
Block a user