Files
Showy/frontend/src/app/features/people/person-card/person-card.component.ts
T

42 lines
1.1 KiB
TypeScript

import { Component, Input, OnInit } from '@angular/core';
import { Person } from '../../../shared/models/person.model';
import { Router } from '@angular/router';
import { ConfigService } from '../../../core/services/config.service';
@Component({
selector: 'app-person-card',
templateUrl: './person-card.component.html',
styleUrls: ['./person-card.component.css'],
})
export class PersonCardComponent implements OnInit {
@Input() person: Person | null = null;
backendUrl: string;
defaultImage = 'assets/images/default-profile.png';
constructor(private router: Router, private configService: ConfigService) {
this.backendUrl = this.configService.getBackendApiUrl();
}
ngOnInit() {}
getGenderText(): string {
if (!this.person || this.person.gender === undefined)
return 'Not specified';
switch (this.person.gender) {
case 1:
return 'Female';
case 2:
return 'Male';
default:
return 'Not specified';
}
}
navigateToDetails() {
if (this.person && this.person.id) {
this.router.navigate(['/people', this.person.id]);
}
}
}