import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'checkmaxseat'
})
export class CheckmaxseatPipe implements PipeTransform {

    transform(arr: any): unknown {
        const ArraySeat = arr.testing_seat_subjects;
        let maxSeat = null;
        for (let i = 0; i < ArraySeat.length; i++ ){
            if(ArraySeat[i].start_seat_no > ArraySeat[i].end_seat_no){
                if (maxSeat < ArraySeat[i].start_seat_no){
                    maxSeat = ArraySeat[i].start_seat_no;
                }
            }else if(ArraySeat[i].start_seat_no < ArraySeat[i].end_seat_no){
                if (maxSeat < ArraySeat[i].end_seat_no){
                    maxSeat = ArraySeat[i].end_seat_no;
                }
            }else if(ArraySeat[i].start_seat_no === ArraySeat[i].end_seat_no){
                if (maxSeat < ArraySeat[i].start_seat_no ){
                    maxSeat = ArraySeat[i].start_seat_no;
                }
            }
        }
        return maxSeat;
    }


}
