ENCOA-281
This commit is contained in:
27
src/utils/excel.errors.ts
Normal file
27
src/utils/excel.errors.ts
Normal 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[] }>);
|
||||
}
|
||||
Reference in New Issue
Block a user