fix view event in some component

This commit is contained in:
Peter Maquiran
2024-05-31 13:59:51 +01:00
parent 2159692018
commit a89b9dd4b6
5 changed files with 60 additions and 71 deletions
@@ -19,6 +19,7 @@ import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle} from 'src/app/services/http-error-handle.service'
import { AttachmentsService } from 'src/app/services/attachments.service';
import { DateService } from 'src/app/services/date.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-view-event',
@@ -71,7 +72,8 @@ export class ViewEventPage implements OnInit {
private RouteService: RouteService,
private httpErrorHandle: HttpErrorHandle,
private attachmentsService: AttachmentsService,
private dateService: DateService
private dateService: DateService,
private agendaDataRepository: AgendaDataRepositoryService
) {
@@ -187,65 +189,25 @@ export class ViewEventPage implements OnInit {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
}
loadEvent() {
async loadEvent() {
const loader = this.toastService.loading();
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
let res = await this.agendaDataRepository.getEventById(this.eventId)
console.log('Loaded Event', res)
res = this.dateService.fixDate(res as any)
this.loadedEvent = res;
this.setTimeZone()
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
this.getFromDb();
} else {
this.httpErrorHandle.httpStatusHandle(error)
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
});
if(res.isOk()) {
console.log('Loaded Event', res.value)
loader.remove()
let changeDate = this.dateService.fixDate(res.value as any) as any
this.loadedEvent = changeDate as any;
this.setTimeZone()
} else {
if(this.CalendarId) {
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
console.log('Loaded Event', res)
/* const div = document.createElement("div")
div.innerHTML = res.Body.Text
res.Body.Text = div.innerText */
res = this.dateService.fixDate(res as any)
this.loadedEvent = res;
console.log('pass,',res)
this.setTimeZone()
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
this.getFromDb();
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
});
}
this.httpErrorHandle.httpStatusHandle(res.error)
loader.remove()
this.toastService.badRequest('Este evento já não existe na sua agenda')
this.RouteService.goBack();
}
}
loadEvent1() {
+17 -8
View File
@@ -233,18 +233,27 @@ export class EventsPage implements OnInit {
let end = date.getFullYear() + "-" + month + "-" + date.getDate() + " 23:59:59";
if(SessionStore.user) {
let onwEvent:any = await this.eventService.getAllOwnEvents(start, end).catch((error) => {
this.showLoader = false;
this.showAgendaLoader = false;
console.error(error)
const response = await this.AgendaDataRepositoryService.EventList({
userId: SessionStore.user.UserId,
calendarOwnerName: SessionStore.user.FullName,
startDate: date.toISOString(),
endDate: new Date(end).toISOString()
})
this.listToPresent = onwEvent;
if(onwEvent?.length) {
this.totalEvent = onwEvent.length;
if(response.isOk()) {
this.listToPresent = response.value;
if(response.value?.length) {
this.totalEvent = response.value.length;
}
} else {
}
this.storage.set('events', this.listToPresent)
this.showLoader = false;
this.showAgendaLoader = false;
this.storage.set('events', this.listToPresent)
}
this.showLoader = false;