import { Component, Input } from '@angular/core';

import { MatCardModule } from '@angular/material/card';

import { Errors } from 'src/app/core';

@Component({
    selector: 'app-list-errors',
    templateUrl: './list-errors.component.html',
    imports: [MatCardModule],
})
export class ListErrorsComponent {
    errorList: string[] = [];

    @Input() set errors(errorList: Errors | null) {
        this.errorList = errorList
            ? Object.keys(errorList.errors || {}).map((key) => `${key} ${errorList.errors[key]}`)
            : [];
    }
}
