import Position from "./Position";

export default class Employee {
    constructor(data) {
        this.id = data?.id;
        this.surname = data?.surname || '';
        this.name = data?.name || '';
        this.phoneNumber = data?.phoneNumber || '';
        this.positions = data?.positions.map((p) => new Position(p)) || '';  
        this.positionsString = '';
        if (this.positions !== '') {
            this.positions.forEach((p) => {this.positionsString += p.name + " "});
        }    
        this.company = data?.company || '';
    }
}

Employee.prototype.equals = function (obj){
    if(typeof obj != typeof this)
        return false;
    if (this.id === obj.id) {
        return true;
    }
    return false;
}