From 92360fdad9d94136738d2c4aab9d4e6fbbf465e7 Mon Sep 17 00:00:00 2001 From: Toast Date: Wed, 5 Feb 2025 02:20:40 +0100 Subject: [PATCH] Interfaces/show: make id optional --- src/interfaces/show.ts | 3 ++- src/pages/shows/shows.component.ts | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/interfaces/show.ts b/src/interfaces/show.ts index 9655a9c..bdb1933 100644 --- a/src/interfaces/show.ts +++ b/src/interfaces/show.ts @@ -1,5 +1,6 @@ export interface Show { - _id: string + // ID is assigned by the DB, so I don't want to have to specify it + _id?: string title: string date: Date seasons: number diff --git a/src/pages/shows/shows.component.ts b/src/pages/shows/shows.component.ts index 1788700..18356ae 100644 --- a/src/pages/shows/shows.component.ts +++ b/src/pages/shows/shows.component.ts @@ -72,17 +72,19 @@ export class ShowsComponent { modal.result.then( (result) => { if (result) { - this.api.deleteShw(show._id).subscribe({ - next: (response: ShowsApiDeletion) => { - // Do nothing - }, error: (err: any) => { - console.log(err) - }, complete: () => { - this.toastService.show({body: "Show deleted!"}) - this.shows = this.shows.filter(((s: Show) => s != show)) + if (show._id != null) { + this.api.deleteShw(show._id).subscribe({ + next: (response: ShowsApiDeletion) => { + // Do nothing + }, error: (err: any) => { + console.log(err) + }, complete: () => { + this.toastService.show({body: "Show deleted!"}) + this.shows = this.shows.filter(((s: Show) => s != show)) + } } - } - ) + ) + } } }, (result) => {