mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 19:22:06 +00:00
26 lines
1 KiB
JavaScript
26 lines
1 KiB
JavaScript
import { get } from "../../../apiUtil";
|
|
import { API_URL } from "../../../constants";
|
|
|
|
export const fetchAccountsPaged = async ({ search = "", page = 1, pageSize = 12 }) => {
|
|
const res = await get(`${API_URL}/Account/GetAccountList?search=${encodeURIComponent(search)}&page=${page}&pageSize=${pageSize}`);
|
|
const rows = (res?.data || res?.Data || []).map(x => ({
|
|
id: x.id ?? x.Id,
|
|
name: x.name ?? x.Name ?? x.AccountName ?? "",
|
|
number: x.number ?? x.AccountNumber ?? "",
|
|
industry: x.industry ?? x.Industry ?? "",
|
|
website: x.website ?? x.Website ?? "",
|
|
primaryContact: x.primaryContact ?? x.PrimaryContact ?? "",
|
|
phoneNumber: x.phoneNumber ?? x.Phone ?? x.PhoneNumber ?? "",
|
|
owner: x.owner ?? x.Owner ?? "",
|
|
}));
|
|
return {
|
|
rows,
|
|
page: res?.pageNumber ?? 1,
|
|
pageSize: res?.pageSize ?? pageSize,
|
|
totalCount: res?.totalCount ?? rows.length,
|
|
totalPages: res?.totalPages ?? 1,
|
|
};
|
|
};
|
|
|
|
export const deleteAccount = (id) =>
|
|
get(`${API_URL}/Account/DeleteAccount?id=${id}`);
|