mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
36 lines
911 B
JavaScript
36 lines
911 B
JavaScript
|
|
import { get } from "../../../apiUtil";
|
||
|
|
import { API_URL } from "../../../constants";
|
||
|
|
|
||
|
|
export const fetchEmployeesPaged = async ({
|
||
|
|
search = "",
|
||
|
|
page = 1,
|
||
|
|
pageSize = 12,
|
||
|
|
}) => {
|
||
|
|
const res = await get(
|
||
|
|
`${API_URL}/Employee/GetEmployeeList?search=${encodeURIComponent(
|
||
|
|
search
|
||
|
|
)}&page=${page}&pageSize=${pageSize}`
|
||
|
|
);
|
||
|
|
|
||
|
|
const rows = (res?.data || res?.Data || []).map((x) => ({
|
||
|
|
id: x.Id,
|
||
|
|
name: `${x.FirstName ?? ""} ${x.LastName ?? ""}`.trim(),
|
||
|
|
jobTitle: x.JobTitle ?? "",
|
||
|
|
email: x.Email ?? "",
|
||
|
|
phone: x.Phone ?? "",
|
||
|
|
department: x.Department ?? "",
|
||
|
|
status: x.Status ?? "",
|
||
|
|
}));
|
||
|
|
|
||
|
|
return {
|
||
|
|
rows,
|
||
|
|
page: res?.PageNumber ?? 1,
|
||
|
|
pageSize: res?.PageSize ?? pageSize,
|
||
|
|
totalCount: res?.TotalCount ?? rows.length,
|
||
|
|
totalPages: res?.TotalPages ?? 1,
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
export const deleteEmployee = (id) =>
|
||
|
|
get(`${API_URL}/Employee/DeleteEmployee?id=${id}`);
|