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