Skip to content

Commit

Permalink
task/WG-295: improve error message when duplicate syncing project (#255)
Browse files Browse the repository at this point in the history
* Improve error message when duplicate syncing project

* Add type and do some minor cleanup

* Remove import
  • Loading branch information
nathanfranklin authored Sep 17, 2024
1 parent f318a7c commit 785bb9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit, AfterContentChecked } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { BsModalRef } from 'ngx-foundation';
import { FormGroup, FormControl } from '@angular/forms';
import { ProjectsService } from '../../services/projects.service';
Expand Down Expand Up @@ -87,9 +88,13 @@ export class ModalCreateProjectComponent implements OnInit, AfterContentChecked
(project) => {
this.close(project);
},
(err) => {
this.errorMessage = err.error && err.error.message ? err.error.message : 'That folder is already syncing with a different map!';

(err: HttpErrorResponse) => {
if (err.status === 409) {
this.errorMessage = 'That folder is already syncing with a different map!';
} else {
this.errorMessage =
err.error && err.error.message ? err.error.message : 'An error occurred while creating the project. Please contact support.';
}
this.submitting = false;
}
);
Expand Down
13 changes: 4 additions & 9 deletions angular/src/app/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,10 @@ export class ProjectsService {

create(data: ProjectRequest): Observable<Project> {
return this.http.post<Project>(this.envService.apiUrl + `/projects/`, data).pipe(
tap(
(proj) => {
// Spread operator, just pushes the new project into the array
this._projects.next([...this._projects.value, proj]);
},
(error) => {
console.log(error);
}
)
tap((proj) => {
// Spread operator, just pushes the new project into the array
this._projects.next([...this._projects.value, proj]);
})
);
}

Expand Down

0 comments on commit 785bb9f

Please sign in to comment.