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