add either pattern

This commit is contained in:
Peter Maquiran
2024-07-09 12:36:46 +01:00
parent 06417ead0f
commit a26fbbddba
45 changed files with 985 additions and 701 deletions
@@ -143,27 +143,22 @@ export class ApproveEventPage implements OnInit {
const loader = this.toastService.loading()
try {
const result = await this.AgendaDataRepositoryService.approveEvent(serialNumber)//.subscribe(async (value) => {
this.AgendaDataRepositoryService.approveEvent(serialNumber).subscribe(async (value) => {
if(result.isOk()) {
await this.processes.PostTaskAction(body).toPromise()
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Evento aprovação')
this.TaskService.loadEventosParaAprovacao();
await this.processes.PostTaskAction(body).toPromise()
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Evento aprovação')
this.TaskService.loadEventosParaAprovacao();
} else {
}, ((error) => {
console.log('aprove event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
console.log('aprove event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove()
}
async emendTask(serialNumber: string) {
@@ -193,28 +188,25 @@ export class ApproveEventPage implements OnInit {
}
const loader = this.toastService.loading()
const loader = this.toastService.loading()
try {
this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Revision', res.data.note).subscribe((value) => {
const result = await this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Revision', res.data.note)//.subscribe((value) => {
if(result.isOk()) {
this.httpErrorHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
}, ((error) => {
console.log('send event to revision error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
this.offlineManager.storeRequestData('event-listRever', body);
}));
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
} finally {
} else {
console.log('send event to revision error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
this.offlineManager.storeRequestData('event-listRever', body);
}
loader.remove()
}
}
}, (error) => {
console.log(error)
});
@@ -227,22 +219,19 @@ export class ApproveEventPage implements OnInit {
let body = { "serialNumber": serialNumber, "action": "Descartar" }
const loader = this.toastService.loading()
try {
/* await this.processes.PostTaskAction(body).toPromise(); */
this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Declined', '').subscribe((value) => {
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
}, ((error) => {
console.log('reject event error: ', error)
this.httpErrorHandle.httpStatusHandle(error)
}))
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
/* await this.processes.PostTaskAction(body).toPromise(); */
const result = await this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Declined', '')//.subscribe((value) => {
if(result.isOk()) {
this.httpErrorHandle.httpsSucessMessagge('Rejeitar')
this.TaskService.loadEventosParaAprovacao();
this.goBack();
} else {
console.log('reject event error: ', result.error)
this.httpErrorHandle.httpStatusHandle(result.error)
}
loader.remove()
}
async viewDocument(DocId: string, Document) {
@@ -369,27 +369,29 @@ export class BookMeetingModalPage implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
try {
const value = await this.agendaDataRepository.createEvent(postData, this.documents, calendar.value, tracing).toPromise()
console.log(value)
const value = await this.agendaDataRepository.createEvent(postData, this.documents, calendar.value, tracing)
if(value.isOk()) {
console.log(value.value)
this.httpErroHandle.httpsSucessMessagge('new event')
loader.remove();
tracing.setAttribute('outcome', 'success')
this.close();
} catch (error) {
} else {
if(!isHttpError(error)) {
if(!isHttpError(value.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #1')
console.log(error)
console.log(value.error)
tracing.bugFlag()
} else {
this.httpErroHandle.httpStatusHandle(error.status)
this.httpErroHandle.httpStatusHandle(value.error.status)
}
console.log('create event error: ', error)
console.log('create event error: ', value.error)
tracing.setAttribute('outcome', 'failed')
}
} else {