add message errors in new action.

This commit is contained in:
tiago.kayaya
2021-12-14 14:58:34 +01:00
parent e524062ed9
commit 7e5388e4e1
7 changed files with 41 additions and 28 deletions
@@ -66,7 +66,7 @@ export class NewActionPage implements OnInit {
private publication: PublicationsService,
private toastService: ToastService
) {
) {
this.folder = new PublicationFolder();
@@ -76,7 +76,7 @@ export class NewActionPage implements OnInit {
this.folder.DateBegin = new Date().toISOString()
this.folder.DateEnd = (new Date(new Date().getTime() + 15 * 60000)).toISOString()
}
ngOnInit() {
@@ -102,7 +102,13 @@ export class NewActionPage implements OnInit {
}
runValidation() {
this.validateFrom = true
this.validateFrom = true;
if(new Date(this.folder.DateBegin).toISOString() > new Date(this.folder.DateEnd).toISOString()){
this.toastService.badRequest("A data de início não pode ser superior a data de fim");
}
else if(this.folder.DateBegin > new Date().toISOString()){
this.toastService.badRequest("A data de início não pode ser superior a data actual");
}
}
injectValidation() {
@@ -134,8 +140,8 @@ export class NewActionPage implements OnInit {
DateEnd: this.folder.DateEnd,
ActionType: this.segment,
}
const loader = this.toastService.loading()
try {
@@ -144,7 +150,7 @@ export class NewActionPage implements OnInit {
this.toastService.successMessage("Ação presidencial criado");
this.close();
} catch (error) {
this.toastService.badRequest("Ação presidencial não criado");
} finally {
loader.remove()
@@ -156,5 +162,5 @@ export class NewActionPage implements OnInit {
close(){
this.modalController.dismiss();
}
}