fix: rename name to displayName in AdminUser type and page
This commit is contained in:
@@ -17,14 +17,14 @@ export async function fetchAdminUsers(params?: {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createAdminUser(body: { email: string; name?: string | null }): Promise<AdminUser> {
|
export async function createAdminUser(body: { email: string; displayName?: string | null }): Promise<AdminUser> {
|
||||||
const { data } = await apiClient.post<AdminUser>('admin/users', body)
|
const { data } = await apiClient.post<AdminUser>('admin/users', body)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateAdminUser(
|
export async function updateAdminUser(
|
||||||
id: string,
|
id: string,
|
||||||
body: Partial<{ email: string; name: string | null }>,
|
body: Partial<{ email: string; displayName: string | null }>,
|
||||||
): Promise<AdminUser> {
|
): Promise<AdminUser> {
|
||||||
const { data } = await apiClient.patch<AdminUser>(`admin/users/${id}`, body)
|
const { data } = await apiClient.patch<AdminUser>(`admin/users/${id}`, body)
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export type AdminUser = {
|
export type AdminUser = {
|
||||||
id: string
|
id: string
|
||||||
email: string
|
email: string
|
||||||
name: string | null
|
displayName: string | null
|
||||||
avatar?: string | null
|
avatar?: string | null
|
||||||
avatarType?: string | null
|
avatarType?: string | null
|
||||||
avatarStyle?: string | null
|
avatarStyle?: string | null
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import { UserAvatar } from '@/shared/ui/UserAvatar'
|
|||||||
|
|
||||||
type UserFormState = {
|
type UserFormState = {
|
||||||
email: string
|
email: string
|
||||||
name: string
|
displayName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const emptyUserForm = (): UserFormState => ({ email: '', name: '' })
|
const emptyUserForm = (): UserFormState => ({ email: '', displayName: '' })
|
||||||
|
|
||||||
function formatDt(v: string) {
|
function formatDt(v: string) {
|
||||||
try {
|
try {
|
||||||
@@ -78,7 +78,7 @@ export function AdminUsersPage() {
|
|||||||
const v = userForm.getValues()
|
const v = userForm.getValues()
|
||||||
await createAdminUser({
|
await createAdminUser({
|
||||||
email: v.email.trim(),
|
email: v.email.trim(),
|
||||||
name: v.name.trim() || null,
|
displayName: v.displayName.trim() || null,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@@ -92,7 +92,7 @@ export function AdminUsersPage() {
|
|||||||
const v = userForm.getValues()
|
const v = userForm.getValues()
|
||||||
await updateAdminUser(editing!.id, {
|
await updateAdminUser(editing!.id, {
|
||||||
email: v.email.trim(),
|
email: v.email.trim(),
|
||||||
name: v.name.trim() || null,
|
displayName: v.displayName.trim() || null,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@@ -119,7 +119,7 @@ export function AdminUsersPage() {
|
|||||||
openEditDialog(u)
|
openEditDialog(u)
|
||||||
userForm.reset({
|
userForm.reset({
|
||||||
email: u.email,
|
email: u.email,
|
||||||
name: u.name ?? '',
|
displayName: u.displayName ?? '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ export function AdminUsersPage() {
|
|||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{u.email}</TableCell>
|
<TableCell>{u.email}</TableCell>
|
||||||
<TableCell>{u.name ?? '—'}</TableCell>
|
<TableCell>{u.displayName ?? '—'}</TableCell>
|
||||||
<TableCell>{formatDt(u.createdAt)}</TableCell>
|
<TableCell>{formatDt(u.createdAt)}</TableCell>
|
||||||
<TableCell>{formatDt(u.updatedAt)}</TableCell>
|
<TableCell>{formatDt(u.updatedAt)}</TableCell>
|
||||||
<TableCell align="right">
|
<TableCell align="right">
|
||||||
@@ -264,7 +264,7 @@ export function AdminUsersPage() {
|
|||||||
/>
|
/>
|
||||||
<Controller
|
<Controller
|
||||||
control={userForm.control}
|
control={userForm.control}
|
||||||
name="name"
|
name="displayName"
|
||||||
render={({ field }) => <TextField label="Имя/ник" fullWidth {...field} />}
|
render={({ field }) => <TextField label="Имя/ник" fullWidth {...field} />}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user