34 lines
811 B
TypeScript
34 lines
811 B
TypeScript
import type { AuditLog } from './dto/audit-log'
|
|
|
|
export type AuditLogFilters = {
|
|
employeeId?: number
|
|
from?: string
|
|
to?: string
|
|
entityType?: string
|
|
page?: number
|
|
}
|
|
|
|
export type AuditLogPage = {
|
|
items: AuditLog[]
|
|
total: number
|
|
page: number
|
|
perPage: number
|
|
}
|
|
|
|
export const fetchAuditLogs = async (filters: AuditLogFilters = {}): Promise<AuditLogPage> => {
|
|
const api = useApi()
|
|
const params: Record<string, string> = {}
|
|
|
|
if (filters.employeeId) params.employeeId = String(filters.employeeId)
|
|
if (filters.from) params.from = filters.from
|
|
if (filters.to) params.to = filters.to
|
|
if (filters.entityType) params.entityType = filters.entityType
|
|
if (filters.page) params.page = String(filters.page)
|
|
|
|
return api.get<AuditLogPage>(
|
|
'/audit-logs',
|
|
params,
|
|
{ toast: false }
|
|
)
|
|
}
|