Skip to content

Commit

Permalink
Update list animaux
Browse files Browse the repository at this point in the history
  • Loading branch information
FazCodeFR committed Dec 12, 2023
1 parent 5daf624 commit 7e40b75
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<img [src]="chat.photos[0].url" loading="lazy" decoding="async" class="object-cover w-full h-64" alt="" />
<div class="p-5 border border-t-0">
<p class="mb-3 text-xs font-semibold tracking-wide uppercase">
<a href="/assos/1"
<a href="/associations/1"
class="transition-colors duration-200 text-blue-gray-900 hover:text-deep-purple-accent-700"
aria-label="Catégorie" title="Association de Chats">Association : {{chat.association.nom}}</a>
<span class="text-gray-600">— 28 Dec 2020</span>
aria-label="Association" title="L'association">Association : {{chat.association.nom}}</a>
<span class="text-gray-600"> - {{formatDate(chat.createdAt)}}</span>
</p>
<div href="/animaux/1" aria-label="Animaux" title="En savoir plus"
class="inline-block mb-3 text-2xl font-bold leading-5 transition-colors duration-200 hover:text-deep-purple-accent-700">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import { Component } from '@angular/core';
import { faMars, faVenus } from '@fortawesome/free-solid-svg-icons';
import { AppService } from '../../../services/app.service';
import { Chat } from '../../../interfaces/interfaces';
import { DatePipe } from '@angular/common';

@Component({
selector: 'app-animaux-list',
templateUrl: './animaux-list.component.html',
styleUrls: ['./animaux-list.component.scss'],
providers: [DatePipe],
})
export class AnimauxListComponent {
faMars = faMars;
faVenus = faVenus;
constructor(private appService: AppService) {}
constructor(private appService: AppService, private datePipe: DatePipe) {}

chats: Chat[] = [];

Expand All @@ -22,10 +24,12 @@ export class AnimauxListComponent {
getCats() {
this.appService.getAllCats().subscribe((chats) => {
this.chats = chats;
console.log(
'🚀 ~ AnimauxListComponent ~ this.appService.getAllCats ~ this.chats:',
this.chats
);
});
}

formatDate(date: string): string {
// Assuming chat.createdAt is a string representing a date
const formattedDate = this.datePipe.transform(date, 'dd MMM yyyy');
return formattedDate || ''; // return an empty string if the date is not valid
}
}
2 changes: 1 addition & 1 deletion src/app/services/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class AppService {
getbyId(id: number) {
throw new Error('Method not implemented.');
}
api = 'http://localhost:4520/v1';
api = 'http://localhost:3000/v1';

constructor(private http: HttpClient) {}

Expand Down

0 comments on commit 7e40b75

Please sign in to comment.