Started implementation of all posts

This commit is contained in:
2026-05-14 11:19:48 +01:00
parent e483bc4e57
commit 6a1ed5abeb
9 changed files with 87 additions and 76 deletions
@@ -1,13 +1,43 @@
import {Component} from '@angular/core';
import {IonicModule} from "@ionic/angular";
import {Component, inject, signal} from '@angular/core';
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
import {GetPostDto, PostsService} from "../../services/api";
import {firstValueFrom} from "rxjs";
import {PostComponent} from "../../components/post/post.component";
@Component({
selector: 'app-publication',
templateUrl: './publication.component.html',
styleUrls: ['./publication.component.scss'],
imports: [
IonicModule
IonicModule,
PostComponent
]
})
export class PublicationComponent {
private postsService = inject(PostsService);
private loadCtrl = inject(LoadingController);
private toastCtrl = inject(ToastController);
posts = signal<GetPostDto[]>([]);
async ionViewWillEnter() {
const loading = await this.loadCtrl.create({
message: 'Chargement...',
spinner: 'lines-sharp-small'
});
await loading.present();
try {
const posts = await firstValueFrom(this.postsService.getAllPostsEndpoint());
this.posts.set(posts);
} catch {
const toast = await this.toastCtrl.create({
message: 'Impossible de charger les publications.',
duration: 2000,
color: 'danger'
});
await toast.present();
}
await loading.dismiss();
}
}