Frontend: Added PersonCardComponent
This commit is contained in:
1 parent
996c445020
commit
02b4caa6ef
3 files changed
+141
No files matched your search
@@ -0,0 +1,65 @@
|
||||
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() {}
|
||||
|
||||
getProfileImageUrl(): string {
|
||||
if (!this.person) return this.defaultImage;
|
||||
|
||||
// First check if we have a local media
|
||||
// if (this.person.medias && this.person.medias.length > 0) {
|
||||
// const profileMedia = this.person.medias.find(m => m.type === 'profile');
|
||||
// if (profileMedia) {
|
||||
// return `${this.backendUrl}/images/people/profiles/${profileMedia.file_name}`;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Fallback to TMDB image if available
|
||||
if (this.person.profile_path) {
|
||||
return `https://image.tmdb.org/t/p/w185${this.person.profile_path}`;
|
||||
}
|
||||
|
||||
// Default image if nothing else is available
|
||||
return this.defaultImage;
|
||||
}
|
||||
|
||||
getGenderText(): string {
|
||||
if (!this.person || this.person.gender === undefined)
|
||||
return 'Not specified';
|
||||
|
||||
switch (this.person.gender) {
|
||||
case 0:
|
||||
return 'Not specified';
|
||||
case 1:
|
||||
return 'Female';
|
||||
case 2:
|
||||
return 'Male';
|
||||
case 3:
|
||||
return 'Non-binary';
|
||||
default:
|
||||
return 'Not specified';
|
||||
}
|
||||
}
|
||||
|
||||
navigateToDetails() {
|
||||
if (this.person && this.person.id) {
|
||||
this.router.navigate(['/people', this.person.id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user