fix(employees): error display через humanizeError, не «Request failed»
Найдено через UI-deep: EmployeesPage в catch'е save'a доставал
err.response.data.error || err.message и показывал в модалке. На 400-ках
с ProblemDetails (errors.{field}:[msg]) error отсутствовал и попадал
generic axios «Request failed with status code 400».
Фикс: используем общий humanizeError() (тот же что в toast'е).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
64cc5b0d10
commit
87e60e7309
|
|
@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
|
|||
import { useQuery } from '@tanstack/react-query'
|
||||
import { validateEmail, validatePhone } from '@/lib/validation'
|
||||
import { Plus, Trash2, Copy } from 'lucide-react'
|
||||
import { api } from '@/lib/api'
|
||||
import { api, humanizeError } from '@/lib/api'
|
||||
import { ListPageShell } from '@/components/ListPageShell'
|
||||
import { DataTable } from '@/components/DataTable'
|
||||
import { Pagination } from '@/components/Pagination'
|
||||
|
|
@ -146,8 +146,10 @@ export function EmployeesPage() {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
const err = e as { response?: { data?: { error?: string } }, message?: string }
|
||||
const msg = err.response?.data?.error ?? err.message ?? 'Не удалось сохранить'
|
||||
// Toast уже показал понятную ошибку через api interceptor; здесь
|
||||
// дублируем в модалке с тем же текстом для контекста (чтобы видеть
|
||||
// прямо в форме что не так — не убегая глазами в правый верхний угол).
|
||||
const msg = humanizeError(e as Error)
|
||||
setBlockedDelete({ title: 'Не удалось сохранить', body: msg })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue