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:
nns 2026-05-30 12:59:37 +05:00
parent 64cc5b0d10
commit 87e60e7309

View file

@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { useQuery } from '@tanstack/react-query' import { useQuery } from '@tanstack/react-query'
import { validateEmail, validatePhone } from '@/lib/validation' import { validateEmail, validatePhone } from '@/lib/validation'
import { Plus, Trash2, Copy } from 'lucide-react' import { Plus, Trash2, Copy } from 'lucide-react'
import { api } from '@/lib/api' import { api, humanizeError } from '@/lib/api'
import { ListPageShell } from '@/components/ListPageShell' import { ListPageShell } from '@/components/ListPageShell'
import { DataTable } from '@/components/DataTable' import { DataTable } from '@/components/DataTable'
import { Pagination } from '@/components/Pagination' import { Pagination } from '@/components/Pagination'
@ -146,8 +146,10 @@ export function EmployeesPage() {
} }
} }
} catch (e) { } catch (e) {
const err = e as { response?: { data?: { error?: string } }, message?: string } // Toast уже показал понятную ошибку через api interceptor; здесь
const msg = err.response?.data?.error ?? err.message ?? 'Не удалось сохранить' // дублируем в модалке с тем же текстом для контекста (чтобы видеть
// прямо в форме что не так — не убегая глазами в правый верхний угол).
const msg = humanizeError(e as Error)
setBlockedDelete({ title: 'Не удалось сохранить', body: msg }) setBlockedDelete({ title: 'Не удалось сохранить', body: msg })
} }
} }