Export production orders with missing data
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s

This commit is contained in:
Cauê Faleiros
2026-08-12 11:41:37 -03:00
parent cfdcc4f2f4
commit e7edb5c483
5 changed files with 117 additions and 5 deletions

View File

@@ -321,6 +321,24 @@ export const fetchProductionOrderImportData = async (): Promise<ProductionOrderI
return data as ProductionOrderImportData;
};
export const exportMissingProductionOrderDataCsv = async (): Promise<number> => {
const response = await authFetch('/olist/production-order-imports/pending-csv', { cache: 'no-store' });
const data = await response.json().catch(() => null);
if (!response.ok || !data?.csv || !data?.filename) {
throw new Error(data?.error || 'Não foi possível exportar as pendências das OPs.');
}
const url = URL.createObjectURL(new Blob([data.csv], { type: 'text/csv;charset=utf-8' }));
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = data.filename;
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
URL.revokeObjectURL(url);
return Number(data.totalRows) || 0;
};
export const importFinalizedProductionOrderCsv = async (filename: string, csv: string): Promise<ProductionOrderImportData & { runId: number; totalRows: number; imported: number; updated: number; skipped: number; failed: number; issues: Array<{ line?: number; number?: string; message: string }> }> => {
const response = await authFetch('/olist/production-order-imports', {
method: 'POST',