Files
encoach_ui_odoo19/src/utils/excel.errors.ts
Carlos-Mesquita bcf3cf0667 ENCOA-281
2024-12-13 21:29:54 +00:00

28 lines
656 B
TypeScript

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[] }>);
}