display error message on creation if any

This commit is contained in:
tykayn 2022-03-21 15:40:08 +01:00 committed by Baptiste Lemoine
parent 0c24b2e602
commit 83e00d57f8

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { PollService } from '../../../core/services/poll.service'; import { PollService } from '../../../core/services/poll.service';
import { ToastService } from 'src/app/core/services/toast.service';
@Component({ @Component({
selector: 'app-nav-steps', selector: 'app-nav-steps',
@ -26,7 +27,7 @@ export class NavStepsComponent implements OnInit {
@Input() @Input()
next_is_disabled: any = false; next_is_disabled: any = false;
constructor(private router: Router, public pollService: PollService) {} constructor(private router: Router, private toastService: ToastService, public pollService: PollService) {}
ngOnInit(): void {} ngOnInit(): void {}
@ -45,11 +46,13 @@ export class NavStepsComponent implements OnInit {
createPoll() { createPoll() {
this.pollService.createPoll().then( this.pollService.createPoll().then(
(resp) => { (resp) => {
this.router.navigate(['/administration/success']); console.log('resp', resp);
this.router.navigate(['/administration/success/']);
this.pollService.step_current = null; this.pollService.step_current = null;
}, },
(err) => { (err: any) => {
console.error('oops err', err); console.error('oops err', err);
this.toastService.display(err.message);
} }
); );
} }