emloyee and user fixings
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Read-only audit trail (ERPCore Controllers/AuditLogsController.cs).
|
||||
import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { AuditLog } from "@/types/audit"
|
||||
|
||||
export interface ListAuditLogsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
entityType?: string
|
||||
entityId?: number
|
||||
userId?: number
|
||||
from?: string
|
||||
to?: string
|
||||
}
|
||||
|
||||
export const auditLogsApi = {
|
||||
list(params: ListAuditLogsParams = {}): Promise<PagedResponse<AuditLog>> {
|
||||
return apiRequest<PagedResponse<AuditLog>>(`/audit-logs${buildQuery(params)}`)
|
||||
},
|
||||
}
|
||||
@@ -59,6 +59,10 @@ export const employeesApi = {
|
||||
updateStatus(employeeId: number, status: EmployeeStatus): Promise<void> {
|
||||
return apiRequest<void>(`/employees/${employeeId}/status`, { method: "PATCH", body: { status } })
|
||||
},
|
||||
/** Permanently deletes the employee and every dependent HR record. Blocked (409) if payroll history exists. */
|
||||
remove(employeeId: number): Promise<void> {
|
||||
return apiRequest<void>(`/employees/${employeeId}`, { method: "DELETE" })
|
||||
},
|
||||
|
||||
/** Advisory: does a System User already exist with this email? */
|
||||
emailLookup(email: string): Promise<{ match: UserMatch | null }> {
|
||||
|
||||
@@ -28,5 +28,8 @@ export function createMasterApi<T, TCreate, TUpdate>(resource: string) {
|
||||
updateStatus(id: number, status: EntityStatus): Promise<void> {
|
||||
return apiRequest<void>(`/${resource}/${id}/status`, { method: "PATCH", body: { status } })
|
||||
},
|
||||
remove(id: number): Promise<void> {
|
||||
return apiRequest<void>(`/${resource}/${id}`, { method: "DELETE" })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// User management (ERPCore Controllers/UsersController.cs). Create orchestrates
|
||||
// account creation in both AuthHex and ERPCore's local shadow table server-side.
|
||||
import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { CreateUserRequest, ManagedUser, UpdateUserRoleRequest, UserTypeOption } from "@/types/users"
|
||||
import { EntityStatus, PagedResponse } from "@/types/common"
|
||||
import { LoginActivity } from "@/types/audit"
|
||||
import { CreateUserRequest, ManagedUser, UpdateUserRoleRequest, UpdateUserStatusRequest, UserTypeOption } from "@/types/users"
|
||||
|
||||
export interface ListUsersParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
q?: string
|
||||
status?: EntityStatus
|
||||
roleCode?: string
|
||||
}
|
||||
|
||||
export const usersApi = {
|
||||
@@ -27,7 +30,17 @@ export const usersApi = {
|
||||
return apiRequest<ManagedUser>(`/users/${userId}/role`, { method: "PUT", body: request })
|
||||
},
|
||||
|
||||
/** Revokes/restores standing inside ERPCore only — the auth-service credential itself is untouched. */
|
||||
updateStatus(userId: number, request: UpdateUserStatusRequest): Promise<ManagedUser> {
|
||||
return apiRequest<ManagedUser>(`/users/${userId}/status`, { method: "PATCH", body: request })
|
||||
},
|
||||
|
||||
userTypes(): Promise<UserTypeOption[]> {
|
||||
return apiRequest<UserTypeOption[]>("/users/user-types")
|
||||
},
|
||||
|
||||
/** Device/login history ERPCore captures itself — not a live "currently active sessions" view. */
|
||||
loginDevices(userId: number, params: { page?: number; pageSize?: number } = {}): Promise<PagedResponse<LoginActivity>> {
|
||||
return apiRequest<PagedResponse<LoginActivity>>(`/users/${userId}/login-devices${buildQuery(params)}`)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface ListWarehousesParams {
|
||||
pageSize?: number
|
||||
q?: string
|
||||
sort?: string
|
||||
branchId?: number
|
||||
}
|
||||
|
||||
export const warehousesApi = {
|
||||
|
||||
Reference in New Issue
Block a user