import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; import { Office } from '../../office.model'; import { User } from '../../../user/user.model'; @Component({ selector: 'civ-district-edit', templateUrl: './district-edit.component.html', styleUrls: ['./district-edit.component.scss'] }) export class DistrictEditComponent implements OnInit, OnChanges { @Input() district: Office; @Input() representative: User; editing = { name: false, repName: false, repIcon: false }; updated = { name: '', repName: '', repIcon: '' }; ngOnChanges(changes: SimpleChanges): void { if (changes['district'] && !!this.district){ this.updated.name = this.district.name; } if (changes['representative'] && !!this.representative){ this.updated.repName = `${ this.representative.firstName} ${this.representative.lastName}`; this.updated.repIcon = this.representative.icon; } } constructor() { } ngOnInit() { } }