import { api } from '../../api/client'; import type { DocumentOut, EntryOut, Page, StatementOut, StatementPatch } from '../../types/api'; const ENTRIES_PAGE = 2000; export const getDocument = (id: string) => api.get(`/documents/${id}`); export const confirmDocument = (id: string) => api.post(`/documents/${id}/confirm`); export const getStatement = (id: string) => api.get(`/documents/${id}/statement`); export const patchStatement = (id: string, body: StatementPatch) => api.patch(`/documents/${id}/statement`, body); export const acceptChecks = (id: string, comment: string) => api.post(`/documents/${id}/statement/checks/accept`, { comment }); /** Все строки ОСВ-документа (страницами по 2000). */ export async function getAllEntries(id: string): Promise { const all: EntryOut[] = []; for (let offset = 0; ; offset += ENTRIES_PAGE) { const page = await api.get>(`/documents/${id}/entries?limit=${ENTRIES_PAGE}&offset=${offset}`); all.push(...page.items); if (all.length >= page.total || page.items.length === 0) { return all; } } }