refactor: rename name→displayName across client
This commit is contained in:
@@ -37,7 +37,7 @@ export type AdminOrderDetailResponse = {
|
||||
comment: string | null
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
user: { id: string; email: string; name: string | null; phone: string | null }
|
||||
user: { id: string; email: string; displayName: string | null; phone: string | null }
|
||||
items: Array<{
|
||||
id: string
|
||||
productId: string
|
||||
|
||||
@@ -7,7 +7,7 @@ export type AdminReview = {
|
||||
status: string
|
||||
createdAt: string
|
||||
moderatedAt: string | null
|
||||
user: { id: string; email: string; name: string | null }
|
||||
user: { id: string; email: string; displayName: string | null }
|
||||
product: { id: string; title: string }
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ export function UserMenu({ user, onNavigate, onLogout }: Props) {
|
||||
{user ? (
|
||||
<>
|
||||
<MenuItem onClick={() => go('/me')}>
|
||||
<ListItemText primary={(user.name && user.name.trim()) || user.email} secondary="Профиль" />
|
||||
<ListItemText primary={(user.displayName && user.displayName.trim()) || user.email} secondary="Профиль" />
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleLogout}>Выход</MenuItem>
|
||||
</>
|
||||
|
||||
@@ -12,7 +12,10 @@ import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { apiClient } from '@/shared/api/client'
|
||||
import { $user, tokenSet } from '@/shared/model/auth'
|
||||
|
||||
type AuthResponse = { token: string; user: { id: string; email: string; name?: string | null; phone?: string | null } }
|
||||
type AuthResponse = {
|
||||
token: string
|
||||
user: { id: string; email: string; displayName?: string | null; phone?: string | null }
|
||||
}
|
||||
|
||||
function getApiErrorMessage(err: unknown): string | null {
|
||||
if (!err || typeof err !== 'object') return null
|
||||
|
||||
@@ -81,7 +81,7 @@ export function MeLayoutPage() {
|
||||
Кабинет
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{user.name?.trim() || user.email}
|
||||
{user.displayName?.trim() || user.email}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Divider sx={{ my: 1 }} />
|
||||
|
||||
@@ -38,8 +38,8 @@ export function MePage() {
|
||||
mode: 'onChange',
|
||||
})
|
||||
|
||||
const profileForm = useForm<{ name: string }>({
|
||||
defaultValues: { name: user?.name ? String(user.name) : '' },
|
||||
const profileForm = useForm<{ displayName: string }>({
|
||||
defaultValues: { displayName: user?.displayName ? String(user.displayName) : '' },
|
||||
mode: 'onChange',
|
||||
})
|
||||
|
||||
@@ -80,15 +80,15 @@ export function MePage() {
|
||||
label="Имя или ник"
|
||||
helperText="До 40 символов"
|
||||
slotProps={{ htmlInput: { maxLength: 40 } }}
|
||||
{...profileForm.register('name')}
|
||||
{...profileForm.register('displayName')}
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={pendingProfile}
|
||||
onClick={() => {
|
||||
const raw = profileForm.getValues('name')
|
||||
const raw = profileForm.getValues('displayName')
|
||||
const name = raw.trim()
|
||||
updateProfileFx({ name: name.length ? name : null })
|
||||
updateProfileFx({ displayName: name.length ? name : null })
|
||||
}}
|
||||
>
|
||||
Сохранить имя
|
||||
|
||||
@@ -38,8 +38,11 @@ export function SettingsPage() {
|
||||
mode: 'onChange',
|
||||
})
|
||||
|
||||
const profileForm = useForm<{ name: string; phone: string }>({
|
||||
defaultValues: { name: user?.name ? String(user.name) : '', phone: user?.phone ? String(user.phone) : '' },
|
||||
const profileForm = useForm<{ displayName: string; phone: string }>({
|
||||
defaultValues: {
|
||||
displayName: user?.displayName ? String(user.displayName) : '',
|
||||
phone: user?.phone ? String(user.phone) : '',
|
||||
},
|
||||
mode: 'onChange',
|
||||
})
|
||||
|
||||
@@ -80,7 +83,7 @@ export function SettingsPage() {
|
||||
label="Имя или ник"
|
||||
helperText="До 40 символов"
|
||||
slotProps={{ htmlInput: { maxLength: 40 } }}
|
||||
{...profileForm.register('name')}
|
||||
{...profileForm.register('displayName')}
|
||||
/>
|
||||
<TextField
|
||||
label="Телефон"
|
||||
@@ -91,11 +94,11 @@ export function SettingsPage() {
|
||||
variant="contained"
|
||||
disabled={pendingProfile}
|
||||
onClick={() => {
|
||||
const raw = profileForm.getValues('name')
|
||||
const raw = profileForm.getValues('displayName')
|
||||
const name = raw.trim()
|
||||
const phoneRaw = profileForm.getValues('phone')
|
||||
const phone = phoneRaw.trim()
|
||||
updateProfileFx({ name: name.length ? name : null, phone: phone.length ? phone : null })
|
||||
updateProfileFx({ displayName: name.length ? name : null, phone: phone.length ? phone : null })
|
||||
}}
|
||||
>
|
||||
Сохранить
|
||||
|
||||
Reference in New Issue
Block a user