diff --git a/src/components/create-edit-modal/create-edit-modal.component.ts b/src/components/create-edit-modal/create-edit-modal.component.ts index 7dbc938..625b6e1 100644 --- a/src/components/create-edit-modal/create-edit-modal.component.ts +++ b/src/components/create-edit-modal/create-edit-modal.component.ts @@ -2,11 +2,11 @@ import {Component, inject} from '@angular/core'; import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap'; import {FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; import {ShowsApiService} from '../../services/shows/shows-api.service'; -import {ShowsApiCreation} from '../../interfaces/shows-api-creation'; +import {ApiCreationResponse} from '../../interfaces/api-creation-response'; import {ToastService} from '../../services/toast/toast.service'; import {Show} from '../../interfaces/show'; import {formatDate} from '@angular/common'; -import {ShowsApiDeletionEdit} from '../../interfaces/shows-api-deletion-edit'; +import {ApiDeletionEditResponse} from '../../interfaces/api-deletion-edit-response'; @Component({ selector: 'app-create-edit-modal', @@ -85,7 +85,7 @@ export class CreateEditModalComponent { if (!this.editMode) { this.showsService.sendShow(show).subscribe({ - next: (response: ShowsApiCreation) => { + next: (response: ApiCreationResponse) => { show._id = response.newId }, error: err => { this.showToast(true, "created") @@ -100,7 +100,7 @@ export class CreateEditModalComponent { // I add it here show._id = this.show?._id this.showsService.updateShow(show).subscribe({ - next: (response: ShowsApiDeletionEdit) => { + next: (response: ApiDeletionEditResponse) => { // Do nothing }, error: err => { this.showToast(true, "edited") diff --git a/src/interfaces/shows-api-creation.ts b/src/interfaces/api-creation-response.ts similarity index 57% rename from src/interfaces/shows-api-creation.ts rename to src/interfaces/api-creation-response.ts index bf97065..3493889 100644 --- a/src/interfaces/shows-api-creation.ts +++ b/src/interfaces/api-creation-response.ts @@ -1,4 +1,4 @@ -export interface ShowsApiCreation { +export interface ApiCreationResponse { status: string message: string newId: string diff --git a/src/interfaces/api-deletion-edit-response.ts b/src/interfaces/api-deletion-edit-response.ts new file mode 100644 index 0000000..abc7095 --- /dev/null +++ b/src/interfaces/api-deletion-edit-response.ts @@ -0,0 +1,4 @@ +export interface ApiDeletionEditResponse { + status: string + message: string +} diff --git a/src/interfaces/shows-api-id-response.ts b/src/interfaces/api-id-response.ts similarity index 62% rename from src/interfaces/shows-api-id-response.ts rename to src/interfaces/api-id-response.ts index 85307d7..415fa72 100644 --- a/src/interfaces/shows-api-id-response.ts +++ b/src/interfaces/api-id-response.ts @@ -1,6 +1,6 @@ import {Show} from './show'; -export interface ShowsApiIdResponse { +export interface ApiIdResponse { status: string show: Show } diff --git a/src/interfaces/shows-api-response.ts b/src/interfaces/api-response.ts similarity index 70% rename from src/interfaces/shows-api-response.ts rename to src/interfaces/api-response.ts index f0bf994..80645c0 100644 --- a/src/interfaces/shows-api-response.ts +++ b/src/interfaces/api-response.ts @@ -1,6 +1,6 @@ import {Show} from './show'; -export interface ShowsApiResponse { +export interface ApiResponse { status: string shows: Show[] totalShows: number diff --git a/src/interfaces/shows-api-deletion-edit.ts b/src/interfaces/shows-api-deletion-edit.ts deleted file mode 100644 index a39c6ca..0000000 --- a/src/interfaces/shows-api-deletion-edit.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ShowsApiDeletionEdit { - status: string - message: string -} diff --git a/src/pages/shows/shows.component.ts b/src/pages/shows/shows.component.ts index ae944f0..57708b6 100644 --- a/src/pages/shows/shows.component.ts +++ b/src/pages/shows/shows.component.ts @@ -1,7 +1,7 @@ import {Component, inject} from '@angular/core'; import {ShowsApiService} from '../../services/shows/shows-api.service'; import {Show} from '../../interfaces/show'; -import {ShowsApiResponse} from '../../interfaces/shows-api-response'; +import {ApiResponse} from '../../interfaces/api-response'; import {Toast} from '../../interfaces/toast'; import {ToastService} from '../../services/toast/toast.service'; import {NgbModal, NgbModalRef} from '@ng-bootstrap/ng-bootstrap'; @@ -29,7 +29,7 @@ export class ShowsComponent { let loadToast: Toast = {body: "Loading shows..."}; this.toastService.show(loadToast); this.api.getShows().subscribe({ - next: (response: ShowsApiResponse) => { + next: (response: ApiResponse) => { this.shows = response.shows; }, error: (err: any) => { console.error("Error: ", err); diff --git a/src/services/shows/shows-api.service.ts b/src/services/shows/shows-api.service.ts index c8c91d9..8d2fbd2 100644 --- a/src/services/shows/shows-api.service.ts +++ b/src/services/shows/shows-api.service.ts @@ -1,11 +1,11 @@ import {inject, Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Observable} from 'rxjs'; -import {ShowsApiResponse} from '../../interfaces/shows-api-response'; -import {ShowsApiCreation} from '../../interfaces/shows-api-creation'; -import {ShowsApiIdResponse} from '../../interfaces/shows-api-id-response'; -import {ShowsApiDeletionEdit} from '../../interfaces/shows-api-deletion-edit'; +import {ApiResponse} from '../../interfaces/api-response'; +import {ApiIdResponse} from '../../interfaces/api-id-response'; +import {ApiDeletionEditResponse} from '../../interfaces/api-deletion-edit-response'; import {Show} from '../../interfaces/show'; +import {ApiCreationResponse} from '../../interfaces/api-creation-response'; @Injectable({ providedIn: 'root' @@ -22,23 +22,23 @@ export class ShowsApiService { this.idEndpoint = this.showsEndpoint + "id/" } - getShows(): Observable { - return this.http.get(this.showsEndpoint) + getShows(): Observable { + return this.http.get(this.showsEndpoint) } - getShow(id: string): Observable { - return this.http.get(this.idEndpoint + id) + getShow(id: string): Observable { + return this.http.get(this.idEndpoint + id) } - sendShow(newShow: Show): Observable { - return this.http.post(this.showsEndpoint, newShow) + sendShow(newShow: Show): Observable { + return this.http.post(this.showsEndpoint, newShow) } - deleteShw(id: string): Observable { - return this.http.delete(this.idEndpoint + id) + deleteShw(id: string): Observable { + return this.http.delete(this.idEndpoint + id) } - updateShow(show: Show): Observable { - return this.http.put(this.idEndpoint + show._id, show) + updateShow(show: Show): Observable { + return this.http.put(this.idEndpoint + show._id, show) } }