recurence added

This commit is contained in:
Eudes Inácio
2024-06-10 09:55:23 +01:00
parent e0a7323bb0
commit c28d17fa64
11 changed files with 322 additions and 67 deletions
@@ -21,7 +21,7 @@ export class AgendaDataRepositoryService {
private agendaDataService: AgendaDataService,
private utils: Utils,
private agendaLocalDataSourceService: AgendaLocalDataSourceService
) {}
) { }
createOwnCalendar() {
const currentUserCalendar = {
@@ -39,14 +39,14 @@ export class AgendaDataRepositoryService {
async getEventById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
console.log('Response',response.data)
console.log('Output',EventMapper.toDomain(response.data))
console.log('Response', response.data)
console.log('Output', EventMapper.toDomain(response.data))
return EventMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
@@ -55,42 +55,42 @@ export class AgendaDataRepositoryService {
async getEventToApproveById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventToApproveDetailsMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
async EventList({userId, startDate , endDate , status= 2, category= null, type= null, calendarOwnerName = ''}) {
async EventList({ userId, startDate, endDate, status = 2, category = null, type = null, calendarOwnerName = '' }) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
}
)).toPromise()
return ok (result)
)).toPromise()
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
async eventToApproveList({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {
async eventToApproveList({ userId, startDate = null, endDate = null, status = 0, category = null, type = null, calendarOwnerName = '' }) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category= null, type= null).pipe(
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null).pipe(
map((response) => {
return EventListToApproveMapper.toDomain(response.data, calendarOwnerName, userId)
}
)).toPromise()
)).toPromise()
return ok (result)
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
@@ -122,9 +122,6 @@ export class AgendaDataRepositoryService {
}
updateEvent(eventId, eventData) {
console.log(eventData.StartDate)
console.log(eventData.EndDate)
let eventInput = {
subject: eventData.Subject,
body: eventData.Body.Text || eventData.Body,
@@ -133,39 +130,41 @@ export class AgendaDataRepositoryService {
endDate: eventData.EndDate,
isAllDayEvent: eventData.IsAllDayEvent,
updateAllEvents: false,
type: this.utils.calendarTypeSeleted(eventData.Category),
category: this.utils.calendarCategorySeleted(eventData.CalendarName),
recurrence: {
frequency: 0,
occurrences: 0
frequency: this.utils.eventRecurence(eventData.EventRecurrence.frequency),
until: eventData.EventRecurrence.until
}
}
return this.agendaDataService.updateEvent(eventId, eventInput)
}
addEventAttendee(id,attendeeData,) {
addEventAttendee(id, attendeeData,) {
console.log(attendeeData)
console.log(this.utils.attendeesEdit(attendeeData))
return this.agendaDataService.addEventAttendee(id,{ attendees: this.utils.attendeesAdded(attendeeData) });
return this.agendaDataService.addEventAttendee(id, { attendees: this.utils.attendeesAdded(attendeeData) });
}
addEventAttachment(id,attachmentData) {
addEventAttachment(id, attachmentData) {
console.log(attachmentData)
console.log('post attachment',this.utils.documentAdded(attachmentData))
return this.agendaDataService.addEventAttachment(id,{ attachments: this.utils.documentAdded(attachmentData) });
console.log('post attachment', this.utils.documentAdded(attachmentData))
return this.agendaDataService.addEventAttachment(id, { attachments: this.utils.documentAdded(attachmentData) });
}
deleteEvent(eventId) {
return this.agendaDataService.deleteEvent(eventId, false)
}
removeEventAttachment(eventId,attachmentData) {
return this.agendaDataService.removeEventAttachment(eventId,attachmentData);
removeEventAttachment(eventId, attachmentData) {
return this.agendaDataService.removeEventAttachment(eventId, attachmentData);
}
async deleteEvent1(eventId) {
try {
const result = await this.agendaDataService.deleteEvent(eventId,false).toPromise()
return ok (result)
const result = await this.agendaDataService.deleteEvent(eventId, false).toPromise()
return ok(result)
} catch (e) {
return err(e as HttpErrorResponse)
}
@@ -177,20 +176,20 @@ export class AgendaDataRepositoryService {
status: this.utils.statusEventAproval(status),
comment: ""
}
return this.agendaDataService.updateEventStatus(eventId,statusObject)
return this.agendaDataService.updateEventStatus(eventId, statusObject)
}
getDocumentAttachments(applicationId,userId,subject,pageNumber,pageSize) {
return this.agendaDataService.getDocumentAttachment(applicationId,userId,subject,pageNumber,pageSize)
getDocumentAttachments(applicationId, userId, subject, pageNumber, pageSize) {
return this.agendaDataService.getDocumentAttachment(applicationId, userId, subject, pageNumber, pageSize)
}
async getSharedCalendar() {
const result = await this.agendaDataService.getSharedCalendar()
if(result.isOk()) {
if (result.isOk()) {
if(result.value?.data) {
if (result.value?.data) {
await this.agendaLocalDataSourceService.clearSharedCalendar()
await this.createOwnCalendar()
@@ -206,7 +205,7 @@ export class AgendaDataRepositoryService {
}
async clearSharedCalendar() {
return await this.agendaLocalDataSourceService.clearSharedCalendar()
return await this.agendaLocalDataSourceService.clearSharedCalendar()
}
getShareCalendarItemsLive() {
@@ -66,7 +66,9 @@ export class EventMapper {
"Day": null,
"DayOfWeek": null,
"Month": null,
"LastOccurrence": null
"LastOccurrence": null,
"frequency": dto.eventRecurrence.frequency,
"until": dto.eventRecurrence.until
},
"Attachments": dto.attachments.map( e => ({
"Id": e.id,
@@ -37,6 +37,16 @@ const OrganizerSchema = z.object({
userPhoto: z.string(),
});
const EventRecurrenceSchema = z.object({
Type: z.number(),
Day: null,
DayOfWeek: null,
Month: null,
LastOccurrence: null,
frequency: z.number(),
until: z.string()
});
export const EventOutputDTOSchema = z.object({
id: z.string(),
owner: OwnerSchema,
@@ -47,12 +57,12 @@ export const EventOutputDTOSchema = z.object({
startDate: z.string(),
endDate: z.string(),
type: z.string(),
category: z.enum(['Oficial','Pessoal']),
category: z.enum(['Oficial', 'Pessoal']),
attendees: z.array(AttendeeSchema),
isRecurring: z.boolean(),
eventRecurrence: z.null(),
eventRecurrence: EventRecurrenceSchema,
hasAttachments: z.boolean(),
attachments:z.array(AttachmentInputDTOSchema),
attachments: z.array(AttachmentInputDTOSchema),
comments: z.array(CommentSchema),
isPrivate: z.boolean(),
isAllDayEvent: z.boolean(),
@@ -165,4 +165,15 @@ export class Utils {
}
return selectedType[type];
}
recurenceTypeSeleted(recurenceType) {
var selectedType = {
0: 'never',
1: 'daily',
2: 'weekly',
3: 'monthly',
4: 'yearly'
}
return selectedType[recurenceType];
}
}