fix(s18): audit-log employee filter — правильный endpoint и DTO
Some checks are pending
Some checks are pending
При первом деплое /api/employees вернул 404 — реальный endpoint /api/organization/employees. Также DTO содержит lastName/firstName/ middleName отдельно, не fullName — собираем строку на клиенте. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
9bd4375ae4
commit
3c731ba532
|
|
@ -38,7 +38,12 @@ const ENTITY_TYPES = [
|
||||||
|
|
||||||
/** Журнал мутаций tenant'а — кто, что и когда менял. Read-only.
|
/** Журнал мутаций tenant'а — кто, что и когда менял. Read-only.
|
||||||
* Запись делает OrgAuditInterceptor автоматически на каждом SaveChanges. */
|
* Запись делает OrgAuditInterceptor автоматически на каждом SaveChanges. */
|
||||||
interface EmployeeOption { userId: string | null; fullName: string }
|
interface EmployeeOption {
|
||||||
|
userId: string | null
|
||||||
|
lastName: string
|
||||||
|
firstName: string
|
||||||
|
middleName: string | null
|
||||||
|
}
|
||||||
|
|
||||||
export function OrgAuditLogPage() {
|
export function OrgAuditLogPage() {
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
|
|
@ -51,12 +56,21 @@ export function OrgAuditLogPage() {
|
||||||
|
|
||||||
// Список сотрудников для фильтра «Кто». Та же permission что и audit-log,
|
// Список сотрудников для фильтра «Кто». Та же permission что и audit-log,
|
||||||
// подгружается раз на сессию (staleTime). Кешируется в TanStack Query.
|
// подгружается раз на сессию (staleTime). Кешируется в TanStack Query.
|
||||||
|
// Endpoint реальный — /api/organization/employees (не /api/employees).
|
||||||
const employees = useQuery({
|
const employees = useQuery({
|
||||||
queryKey: ['/api/employees', 'audit-log-filter'],
|
queryKey: ['/api/organization/employees', 'audit-log-filter'],
|
||||||
queryFn: async () => (await api.get<{ items: EmployeeOption[] }>('/api/employees?pageSize=200')).data,
|
queryFn: async () => (await api.get<{ items: EmployeeOption[] }>('/api/organization/employees?pageSize=200&status=all')).data,
|
||||||
staleTime: 5 * 60 * 1000,
|
staleTime: 5 * 60 * 1000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const employeeOptions = (employees.data?.items ?? [])
|
||||||
|
.filter((u) => !!u.userId)
|
||||||
|
.map((u) => ({
|
||||||
|
userId: u.userId!,
|
||||||
|
fullName: [u.lastName, u.firstName, u.middleName].filter(Boolean).join(' ').trim(),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => a.fullName.localeCompare(b.fullName, 'ru'))
|
||||||
|
|
||||||
const params = new URLSearchParams({ page: String(page), pageSize: '50' })
|
const params = new URLSearchParams({ page: String(page), pageSize: '50' })
|
||||||
if (entityType) params.set('entityType', entityType)
|
if (entityType) params.set('entityType', entityType)
|
||||||
if (action) params.set('action', action)
|
if (action) params.set('action', action)
|
||||||
|
|
@ -113,9 +127,9 @@ export function OrgAuditLogPage() {
|
||||||
<Field label="Кто">
|
<Field label="Кто">
|
||||||
<Select value={userId} onChange={(e) => { setUserId(e.target.value); setPage(1) }}>
|
<Select value={userId} onChange={(e) => { setUserId(e.target.value); setPage(1) }}>
|
||||||
<option value="">Все</option>
|
<option value="">Все</option>
|
||||||
{(employees.data?.items ?? [])
|
{employeeOptions.map((u) => (
|
||||||
.filter((u) => u.userId)
|
<option key={u.userId} value={u.userId}>{u.fullName}</option>
|
||||||
.map((u) => <option key={u.userId!} value={u.userId!}>{u.fullName}</option>)}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Field>
|
</Field>
|
||||||
<Field label="Дата с">
|
<Field label="Дата с">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue