Export production orders with missing data
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user