Демо-прототип: от создания консолидации до сводной ОСВ #4

Merged
aep merged 29 commits from feat/3-demo-prototype into test 2026-10-08 09:58:39 +03:00
Showing only changes of commit 27828219c9 - Show all commits

View File

@ -2,9 +2,21 @@ import { api } from '../../../api/client';
import type { LegalEntityBrief, Page, RelatedGroupDetail, RelatedGroupOut } from '../../../types/api';
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
const CG_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 fetchRelatedGroups = (groupId: string) => api.get<RelatedGroupOut[]>(`/directories/company-groups/${groupId}/related-groups`);
export const fetchRelatedGroup = (id: string) => api.get<RelatedGroupDetail>(`/directories/related-groups/${id}`);