diff --git a/src/app/components/show-list/show-list.component.ts b/src/app/components/show-list/show-list.component.ts index 398397b..4b61511 100644 --- a/src/app/components/show-list/show-list.component.ts +++ b/src/app/components/show-list/show-list.component.ts @@ -4,6 +4,7 @@ import {FormsModule} from '@angular/forms'; import {ShowService} from '../../services/show.service'; import {Observable} from 'rxjs'; import {AsyncPipe} from '@angular/common'; +import {deleteDoc, doc, Firestore, updateDoc} from '@angular/fire/firestore'; @Component({ selector: 'app-show-list', @@ -17,6 +18,8 @@ import {AsyncPipe} from '@angular/common'; }) export class ShowListComponent { showService: ShowService = inject(ShowService); + fireStore: Firestore = inject(Firestore); + private seriesCollection = 'table_show'; shows: Observable = this.showService.getShows(); @Output() selectedShow = new EventEmitter(); @@ -37,13 +40,13 @@ export class ShowListComponent { } updateShow(show: Show) { - // this.shows = this.shows.filter(s => s !== show); - // this.shows.push(show); - // this.shows.sort((a, b) => (a.uid ?? 0) - (b.uid ?? 0)); + const showDocRef = doc(this.fireStore, `${this.seriesCollection}/${show.uid}`); + updateDoc(showDocRef, {id: show.uid, title: show.title,}); } delete(show: Show) { - // this.shows = this.shows.filter(s => s !== show); + const showDocRef = doc(this.fireStore, `${this.seriesCollection}/${show.uid}`); + deleteDoc(showDocRef); } isToEdit(show: Show): boolean {