fix: use mutation variables in onSuccess, fix null displayName handling
This commit is contained in:
@@ -72,13 +72,12 @@ export function AdminSettingsPage() {
|
||||
avatarType?: string | null
|
||||
avatarStyle?: string | null
|
||||
}) => apiClient.patch('admin/profile', params),
|
||||
onSuccess: () => {
|
||||
const name = profileForm.getValues('displayName').trim()
|
||||
const p: UpdateProfileParams = { displayName: name.length ? name : null }
|
||||
if (hasUnsavedPreview) {
|
||||
p.avatar = previewSrc
|
||||
p.avatarType = 'generated'
|
||||
p.avatarStyle = previewStyle
|
||||
onSuccess: (_data, variables) => {
|
||||
const p: UpdateProfileParams = { displayName: variables.displayName ?? null }
|
||||
if (variables.avatar !== undefined) {
|
||||
p.avatar = variables.avatar
|
||||
p.avatarType = variables.avatarType ?? null
|
||||
p.avatarStyle = variables.avatarStyle ?? null
|
||||
}
|
||||
updateProfileFx(p)
|
||||
void qc.invalidateQueries({ queryKey: ['admin', 'profile'] })
|
||||
|
||||
Reference in New Issue
Block a user