ENCOA-281

This commit is contained in:
Carlos-Mesquita
2024-12-13 21:29:54 +00:00
parent fa0c257040
commit bcf3cf0667
4 changed files with 587 additions and 61 deletions

27
src/utils/excel.errors.ts Normal file
View File

@@ -0,0 +1,27 @@
export interface ExcelError {
type: string;
value: any;
error: string;
reason: string;
row: number;
column: string;
}
export const errorsByRows = (errors: ExcelError[] ) => {
return errors.reduce((acc, error) => {
if (!acc[error.row]) {
acc[error.row] = {
required: [],
other: []
};
}
if (error.error === 'required') {
acc[error.row].required.push(error.column);
} else {
acc[error.row].other.push(error);
}
return acc;
}, {} as Record<number, { required: string[], other: ExcelError[] }>);
}