import { Component, Input } from '@angular/core';
import { Post } from '../entities';

@Component({
	selector: 'app-post-card',
	templateUrl: './post-card.component.html',
	styles: [`
		.post-card {
			margin-bottom: 50px;
			cursor: pointer;
		}
		.creation-date-area {
			color: #bdbdbd;
			font-style: italic;
		}
		.author-img {
			width: 60px;
			height: 60px;
			border-radius: 50%;
			margin-right: 15px;
		}
		#post-image {
			width: 100%;
		}
	`]
})
export class PostCardComponent {
	@Input() post: Post;

	getAvatarUrl(): string {
		return this.post.author.image
				? `/api/images/loadAvatar/${this.post.author.image}`
				: './assets/images/default_user.png';
	}
}
