Демо-прототип: от создания консолидации до сводной ОСВ #4
@ -2,9 +2,21 @@ import { api } from '../../../api/client';
|
|||||||
import type { LegalEntityBrief, Page, RelatedGroupDetail, RelatedGroupOut } from '../../../types/api';
|
import type { LegalEntityBrief, Page, RelatedGroupDetail, RelatedGroupOut } from '../../../types/api';
|
||||||
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
|
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
|
||||||
|
|
||||||
|
const CG_PAGE = 200;
|
||||||
const LE_PAGE = 200;
|
const LE_PAGE = 200;
|
||||||
|
|
||||||
export const fetchCompanyGroups = () => api.get<ICompanyGroup[]>('/directories/company-groups');
|
/** Все видимые ГК — дочитываем страницы, пока не получим total. */
|
||||||
|
export async function fetchCompanyGroups(): Promise<ICompanyGroup[]> {
|
||||||
|
const all: ICompanyGroup[] = [];
|
||||||
|
for (let offset = 0; ; offset += CG_PAGE) {
|
||||||
|
const page = await api.get<Page<ICompanyGroup>>(`/directories/company-groups?limit=${CG_PAGE}&offset=${offset}`);
|
||||||
|
all.push(...page.items);
|
||||||
|
if (all.length >= page.total || page.items.length === 0) {
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const fetchOneCompanyGroup = (id: string) => api.get<ICompanyGroup>(`/directories/company-groups/${id}`);
|
export const fetchOneCompanyGroup = (id: string) => api.get<ICompanyGroup>(`/directories/company-groups/${id}`);
|
||||||
export const fetchRelatedGroups = (groupId: string) => api.get<RelatedGroupOut[]>(`/directories/company-groups/${groupId}/related-groups`);
|
export const fetchRelatedGroups = (groupId: string) => api.get<RelatedGroupOut[]>(`/directories/company-groups/${groupId}/related-groups`);
|
||||||
export const fetchRelatedGroup = (id: string) => api.get<RelatedGroupDetail>(`/directories/related-groups/${id}`);
|
export const fetchRelatedGroup = (id: string) => api.get<RelatedGroupDetail>(`/directories/related-groups/${id}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user