diff --git a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts
index 93b130b0b..8dbd73aa7 100644
--- a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts
+++ b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts
@@ -127,11 +127,12 @@ export class BookMeetingModalPage implements OnInit {
private navParams: NavParams,
private processes:ProcessesService,
private attachmentsService: AttachmentsService,
- private calendarService: EventsService,
+ public calendarService: EventsService,
authService: AuthService,
private toastService: ToastService,
private activatedRoute: ActivatedRoute,
- public ThemeService: ThemeService
+ public ThemeService: ThemeService,
+
) {
this.taskParticipants = [];
this.loggeduser = authService.ValidatedUser;
@@ -149,6 +150,18 @@ export class BookMeetingModalPage implements OnInit {
this.postData.Category = 'Reunião'
+
+
+ if(this.calendarService.hasOwnCalendar == false || !this.calendarService.hasSharedCalendar == false) {
+
+ if(this.calendarService.hasOwnCalendar == false && this.calendarService.hasSharedCalendar == true) {
+ this.CalendarName = 'sharedCalendar'
+ } else if (this.calendarService.hasOwnCalendar == true && this.calendarService.hasSharedCalendar == false) {
+ this.CalendarName = 'myCalendar'
+ }
+
+ }
+
}
ngOnInit() {
@@ -265,19 +278,12 @@ export class BookMeetingModalPage implements OnInit {
if(this.task.FsId == '8') {
const loader = this.toastService.loading()
+
try {
- switch (this.loggeduser.Profile) {
- case 'MDGPR':
- await this.calendarService.postExpedientEvent(this.task.DocId, this.postData, "md",this.task.SerialNumber, this.task.FsId).toPromise();
- break;
-
- case 'PR':
- await this.calendarService.postExpedientEvent(this.task.DocId, this.postData, "pr",this.task.SerialNumber, this.task.FsId).toPromise()
- break;
- }
+ await this.calendarService.genericPostExpedientEvent(this.task.DocId, this.postData, "",this.task.SerialNumber, this.task.FsId, this.CalendarName).toPromise();
+
this.modalController.dismiss();
- // this.distartExpedientModal();
this.toastService._successMessage('Reunião criada');
} catch (error) {
@@ -293,15 +299,9 @@ export class BookMeetingModalPage implements OnInit {
const loader = this.toastService.loading()
try {
- switch (this.loggeduser.Profile) {
- case 'MDGPR':
- await this.calendarService.createTaskEvent(this.task.FolderID | this.task.FolderId, this.postData, "md",this.task.SerialNumber, this.task.FsId).toPromise();
- break;
- case 'PR':
- await this.calendarService.createTaskEvent(this.task.FolderID | this.task.FolderId, this.postData, "pr",this.task.SerialNumber, this.task.FsId).toPromise();
- break;
- }
+ await this.calendarService.genericCreateTaskEvent(this.task.FolderID | this.task.FolderId, this.postData, "",this.task.SerialNumber, this.task.FsId, this.CalendarName).toPromise();
+
this.close();
this.toastService._successMessage('Reunião criada');
diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts
index 91c84a74b..9033d6981 100644
--- a/src/app/services/events.service.ts
+++ b/src/app/services/events.service.ts
@@ -866,7 +866,7 @@ export class EventsService {
genericPostExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any, calendar: 'myCalendar' | 'sharedCalendar') {
- const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
+ const geturl = environment.apiURL + 'calendar/expediente';
let params = new HttpParams();
let options;
@@ -948,6 +948,51 @@ export class EventsService {
return this.http.post
(`${geturl}`, body, options)
}
+
+
+ genericCreateTaskEvent(folderId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any, calendar: 'myCalendar' | 'sharedCalendar') {
+ const geturl = environment.apiURL + 'calendar/dispatch';
+ let params = new HttpParams();
+ let options;
+
+ params = params.set("FolderId", folderId);
+ params = params.set("SerialNumber", serialNumber);
+ params = params.set("applicationID", applicationID);
+
+ if(calendar == 'myCalendar') {
+ if (body.CalendarName == 'Pessoal') {
+ options = {
+ headers: this.headerOwnPessoal,
+ params: params
+ }
+ }
+ else if (body.CalendarName == 'Oficial') {
+ options = {
+ headers: this.headerOwnOficial,
+ params: params
+ }
+ }
+ } else if (calendar == 'sharedCalendar') {
+ if (body.CalendarName == 'Pessoal') {
+ options = {
+ headers: this.headerSharedPessoal,
+ params: params
+ };
+ }
+ else if (body.CalendarName == 'Oficial') {
+ options = {
+ headers: this.headerSharedOficial,
+ params: params
+ };
+ }
+ }
+
+
+ return this.http.post(`${geturl}`, body, options)
+ }
+
+
+
postEventToApproveEdit(body: EventToApproveEdit) {
const geturl = environment.apiURL + 'Tasks/EditEventTask';