Interfaces: make names generic
This commit is contained in:
parent
b44fe2e51d
commit
1dd0333bc3
8 changed files with 27 additions and 27 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export interface ShowsApiCreation {
|
||||
export interface ApiCreationResponse {
|
||||
status: string
|
||||
message: string
|
||||
newId: string
|
||||
4
src/interfaces/api-deletion-edit-response.ts
Normal file
4
src/interfaces/api-deletion-edit-response.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export interface ApiDeletionEditResponse {
|
||||
status: string
|
||||
message: string
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {Show} from './show';
|
||||
|
||||
export interface ShowsApiIdResponse {
|
||||
export interface ApiIdResponse {
|
||||
status: string
|
||||
show: Show
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {Show} from './show';
|
||||
|
||||
export interface ShowsApiResponse {
|
||||
export interface ApiResponse {
|
||||
status: string
|
||||
shows: Show[]
|
||||
totalShows: number
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
export interface ShowsApiDeletionEdit {
|
||||
status: string
|
||||
message: string
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<ShowsApiResponse> {
|
||||
return this.http.get<ShowsApiResponse>(this.showsEndpoint)
|
||||
getShows(): Observable<ApiResponse> {
|
||||
return this.http.get<ApiResponse>(this.showsEndpoint)
|
||||
}
|
||||
|
||||
getShow(id: string): Observable<ShowsApiIdResponse> {
|
||||
return this.http.get<ShowsApiIdResponse>(this.idEndpoint + id)
|
||||
getShow(id: string): Observable<ApiIdResponse> {
|
||||
return this.http.get<ApiIdResponse>(this.idEndpoint + id)
|
||||
}
|
||||
|
||||
sendShow(newShow: Show): Observable<ShowsApiCreation> {
|
||||
return this.http.post<ShowsApiCreation>(this.showsEndpoint, newShow)
|
||||
sendShow(newShow: Show): Observable<ApiCreationResponse> {
|
||||
return this.http.post<ApiCreationResponse>(this.showsEndpoint, newShow)
|
||||
}
|
||||
|
||||
deleteShw(id: string): Observable<ShowsApiDeletionEdit> {
|
||||
return this.http.delete<ShowsApiDeletionEdit>(this.idEndpoint + id)
|
||||
deleteShw(id: string): Observable<ApiDeletionEditResponse> {
|
||||
return this.http.delete<ApiDeletionEditResponse>(this.idEndpoint + id)
|
||||
}
|
||||
|
||||
updateShow(show: Show): Observable<ShowsApiDeletionEdit> {
|
||||
return this.http.put<ShowsApiDeletionEdit>(this.idEndpoint + show._id, show)
|
||||
updateShow(show: Show): Observable<ApiDeletionEditResponse> {
|
||||
return this.http.put<ApiDeletionEditResponse>(this.idEndpoint + show._id, show)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue