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.
|
||||
* Запись делает OrgAuditInterceptor автоматически на каждом SaveChanges. */
|
||||
interface EmployeeOption { userId: string | null; fullName: string }
|
||||
interface EmployeeOption {
|
||||
userId: string | null
|
||||
lastName: string
|
||||
firstName: string
|
||||
middleName: string | null
|
||||
}
|
||||
|
||||
export function OrgAuditLogPage() {
|
||||
const [page, setPage] = useState(1)
|
||||
|
|
@ -51,12 +56,21 @@ export function OrgAuditLogPage() {
|
|||
|
||||
// Список сотрудников для фильтра «Кто». Та же permission что и audit-log,
|
||||
// подгружается раз на сессию (staleTime). Кешируется в TanStack Query.
|
||||
// Endpoint реальный — /api/organization/employees (не /api/employees).
|
||||
const employees = useQuery({
|
||||
queryKey: ['/api/employees', 'audit-log-filter'],
|
||||
queryFn: async () => (await api.get<{ items: EmployeeOption[] }>('/api/employees?pageSize=200')).data,
|
||||
queryKey: ['/api/organization/employees', 'audit-log-filter'],
|
||||
queryFn: async () => (await api.get<{ items: EmployeeOption[] }>('/api/organization/employees?pageSize=200&status=all')).data,
|
||||
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' })
|
||||
if (entityType) params.set('entityType', entityType)
|
||||
if (action) params.set('action', action)
|
||||
|
|
@ -113,9 +127,9 @@ export function OrgAuditLogPage() {
|
|||
<Field label="Кто">
|
||||
<Select value={userId} onChange={(e) => { setUserId(e.target.value); setPage(1) }}>
|
||||
<option value="">Все</option>
|
||||
{(employees.data?.items ?? [])
|
||||
.filter((u) => u.userId)
|
||||
.map((u) => <option key={u.userId!} value={u.userId!}>{u.fullName}</option>)}
|
||||
{employeeOptions.map((u) => (
|
||||
<option key={u.userId} value={u.userId}>{u.fullName}</option>
|
||||
))}
|
||||
</Select>
|
||||
</Field>
|
||||
<Field label="Дата с">
|
||||
|
|
|
|||
Loading…
Reference in a new issue