mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
list events
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgendaDataRepositoryService } from './agenda-data-repository.service';
|
||||
|
||||
describe('AgendaDataRepositoryService', () => {
|
||||
let service: AgendaDataRepositoryService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(AgendaDataRepositoryService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from './agenda-data.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ListEventMapper } from './mapper/EventListMapper';
|
||||
import { EventMapper } from './mapper/EventDetailsMapper';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AgendaDataRepositoryService {
|
||||
|
||||
constructor(
|
||||
private agendaDataService: AgendaDataService
|
||||
) {}
|
||||
|
||||
createEvent(eventData: any) {
|
||||
return this.agendaDataService.createEvent(eventData).pipe(map(EventMapper.toDomain))
|
||||
}
|
||||
|
||||
getEventById(id: string) {
|
||||
return this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
return EventMapper.toDomain(response.data)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
|
||||
return this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
|
||||
map((response) => {
|
||||
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
eventToApprove({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {
|
||||
return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category= null, type= null).pipe(
|
||||
map((response) => {
|
||||
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,98 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EventOutputDTO } from './model/eventDTOOutput';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AgendaDataService {
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
|
||||
|
||||
constructor() { }
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
// Contacts Endpoints
|
||||
getContacts(value: string): Observable<any> {
|
||||
const params = new HttpParams().set('value', value);
|
||||
return this.http.get<any>(`${this.baseUrl}/Contacts`, { params });
|
||||
}
|
||||
|
||||
// Documents Endpoints
|
||||
getAttachments(subject: string, applicationType: number): Observable<any> {
|
||||
const params = new HttpParams()
|
||||
.set('Subject', subject)
|
||||
.set('ApplicationType', applicationType.toString());
|
||||
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
|
||||
}
|
||||
|
||||
viewDocument(userId: number, docId: number, applicationId: number): Observable<any> {
|
||||
const params = new HttpParams()
|
||||
.set('userId', userId.toString())
|
||||
.set('docId', docId.toString())
|
||||
.set('applicationId', applicationId.toString());
|
||||
return this.http.get<any>(`${this.baseUrl}/Documents/view`, { params });
|
||||
}
|
||||
|
||||
// Events Endpoints
|
||||
createEvent(eventData: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||
}
|
||||
|
||||
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> {
|
||||
const params = new HttpParams()
|
||||
.set('UserId', userId)
|
||||
.set('Status', status)
|
||||
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
|
||||
}
|
||||
|
||||
updateEvent(id: string, eventData: any): Observable<any> {
|
||||
return this.http.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
|
||||
}
|
||||
|
||||
approveEvent(id: string): Observable<any> {
|
||||
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
|
||||
}
|
||||
|
||||
getEvent(id: string): Observable<any> {
|
||||
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
|
||||
}
|
||||
|
||||
deleteEvent(id: string, deleteAllEvents: boolean): Observable<any> {
|
||||
const params = new HttpParams().set('DeleteAllEvents', deleteAllEvents.toString());
|
||||
return this.http.delete<any>(`${this.baseUrl}/Events/${id}`, { params });
|
||||
}
|
||||
|
||||
updateEventStatus(id: string, statusData: any): Observable<any> {
|
||||
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
|
||||
}
|
||||
|
||||
addEventAttendee(id: string, attendeeData: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attendee`, attendeeData);
|
||||
}
|
||||
|
||||
removeEventAttendee(id: string, attendeeData: any): Observable<any> {
|
||||
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attendee`, { body: attendeeData });
|
||||
}
|
||||
|
||||
addEventAttachment(id: string, attachmentData: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Attachment`, attachmentData);
|
||||
}
|
||||
|
||||
removeEventAttachment(id: string, attachmentData: any): Observable<any> {
|
||||
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attachment`, { body: attachmentData });
|
||||
}
|
||||
|
||||
communicateEvent(id: string, communicationData: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Communicate`, communicationData);
|
||||
}
|
||||
|
||||
// Users Endpoints
|
||||
getUsers(value: string): Observable<any> {
|
||||
const params = new HttpParams().set('value', value);
|
||||
return this.http.get<any>(`${this.baseUrl}/Users`, { params });
|
||||
}
|
||||
|
||||
getToken(): Observable<any> {
|
||||
return this.http.get<any>(`${this.baseUrl}/Users/token`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,103 +1,105 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const AttachCommunicationInputModel = z.object({
|
||||
export const AttachCommunicationInputDTOSchema = z.object({
|
||||
attachmentId: z.string().uuid(),
|
||||
description: z.string().nullable().optional(),
|
||||
typeSharing: z.number().int(),
|
||||
dateViewExpire: z.string().datetime().nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const AttachmentInputModel = z.object({
|
||||
sourceId: z.string().nullable().optional(),
|
||||
sourceName: z.string().nullable().optional(),
|
||||
description: z.string().nullable().optional(),
|
||||
|
||||
export const AttachmentInputDTOSchema = z.object({
|
||||
sourceId: z.string().nullable(),
|
||||
sourceName: z.string().nullable(),
|
||||
description: z.string().nullable(),
|
||||
applicationId: z.number().int(),
|
||||
}).strict();
|
||||
|
||||
const AttendeeCommunicationInputModel = z.object({
|
||||
|
||||
export const AttendeeCommunicationInputDTOSchema = z.object({
|
||||
attendeeId: z.string().uuid(),
|
||||
message: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const AttendeeExternalInputModel = z.object({
|
||||
export const AttendeeExternalInputDTOSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
emailAddress: z.string().email().nullable().optional(),
|
||||
message: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const AttendeeInputModel = z.object({
|
||||
export const AttendeeInputDTOSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
emailAddress: z.string().nullable().optional(),
|
||||
attendeeType: z.enum(["0", "1", "2"]),
|
||||
wxUserId: z.number().int(),
|
||||
}).strict();
|
||||
|
||||
const EAttendeeType = z.enum(["0", "1", "2"]);
|
||||
const EAttendeeTypeDTO = z.enum(["0", "1", "2"]);
|
||||
|
||||
const EEventCategory = z.enum(["1", "2"]);
|
||||
const EEventCategoryDTO = z.enum(["1", "2"]);
|
||||
|
||||
const EEventFilterCategory = z.enum(["1", "2", "3"]);
|
||||
const EEventFilterCategoryDTO = z.enum(["1", "2", "3"]);
|
||||
|
||||
const EEventFilterStatus = z.enum(["0", "1", "2", "3", "4", "5"]);
|
||||
const EEventFilterStatusDTO = z.enum(["0", "1", "2", "3", "4", "5"]);
|
||||
|
||||
const EEventFilterType = z.enum(["1", "2", "3", "4"]);
|
||||
const EEventFilterTypeDTO = z.enum(["1", "2", "3", "4"]);
|
||||
|
||||
const EEventOwnerType = z.enum(["1", "2", "3"]);
|
||||
const EEventOwnerTypeDTO = z.enum(["1", "2", "3"]);
|
||||
|
||||
const EEventStatus = z.enum(["0", "1", "2", "3", "4"]);
|
||||
const EEventStatusDTO = z.enum(["0", "1", "2", "3", "4"]);
|
||||
|
||||
const EEventType = z.enum(["1", "2", "3"]);
|
||||
const EEventTypeDTO = z.enum(["1", "2", "3"]);
|
||||
|
||||
const ERecurringType = z.enum(["0", "1", "2", "3", "4"]);
|
||||
const ERecurringTypeDTO = z.enum(["0", "1", "2", "3", "4"]);
|
||||
|
||||
const EventAddAttachmentModel = z.object({
|
||||
attachments: z.array(AttachmentInputModel),
|
||||
const EventAddAttachmentDTOSchema = z.object({
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
}).strict();
|
||||
|
||||
const EventAddAttendeeModel = z.object({
|
||||
attendees: z.array(AttendeeInputModel),
|
||||
const EventAddAttendeeDTOSchema = z.object({
|
||||
attendees: z.array(AttendeeInputDTOSchema),
|
||||
}).strict();
|
||||
|
||||
const EventCommunicationInputModel = z.object({
|
||||
attachs: z.array(AttachCommunicationInputModel).nullable().optional(),
|
||||
attendees: z.array(AttendeeCommunicationInputModel).nullable().optional(),
|
||||
externalAttendees: z.array(AttendeeExternalInputModel).nullable().optional(),
|
||||
export const EventCommunicationInputDTOSchema = z.object({
|
||||
attachs: z.array(AttachCommunicationInputDTOSchema).nullable().optional(),
|
||||
attendees: z.array(AttendeeCommunicationInputDTOSchema).nullable().optional(),
|
||||
externalAttendees: z.array(AttendeeExternalInputDTOSchema).nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const EventInputModel = z.object({
|
||||
export const EventInputDTOSchema = z.object({
|
||||
userId: z.number().int(),
|
||||
ownerType: EEventOwnerType,
|
||||
ownerType: EEventOwnerTypeDTO,
|
||||
subject: z.string().min(1),
|
||||
body: z.string().min(1),
|
||||
location: z.string().nullable().optional(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
type: EEventType,
|
||||
category: EEventCategory,
|
||||
attendees: z.array(AttendeeInputModel).nullable().optional(),
|
||||
attachments: z.array(AttachmentInputModel).nullable().optional(),
|
||||
type: EEventTypeDTO,
|
||||
category: EEventCategoryDTO,
|
||||
attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
|
||||
attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
|
||||
recurrence: z.object({
|
||||
frequency: ERecurringType,
|
||||
frequency: ERecurringTypeDTO,
|
||||
occurrences: z.number().int(),
|
||||
}),
|
||||
organizerId: z.number().int(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
}).strict();
|
||||
|
||||
const EventRecurrenceInputModel = z.object({
|
||||
frequency: ERecurringType,
|
||||
export const EventRecurrenceInputDTOSchema = z.object({
|
||||
frequency: ERecurringTypeDTO,
|
||||
occurrences: z.number().int(),
|
||||
}).strict();
|
||||
|
||||
const EventRemoveAttachmentModel = z.object({
|
||||
export const EventRemoveAttachmentDTOSchema = z.object({
|
||||
attachments: z.array(z.string().uuid()),
|
||||
}).strict();
|
||||
|
||||
const EventRemoveAttendeeModel = z.object({
|
||||
export const EventRemoveAttendeeDTOSchema = z.object({
|
||||
attendees: z.array(z.string().uuid()),
|
||||
}).strict();
|
||||
|
||||
const EventUpdateModel = z.object({
|
||||
export const EventUpdateDTOSchema = z.object({
|
||||
subject: z.string().min(1),
|
||||
body: z.string().min(1),
|
||||
location: z.string().min(1),
|
||||
@@ -106,17 +108,17 @@ const EventUpdateModel = z.object({
|
||||
isAllDayEvent: z.boolean(),
|
||||
updateAllEvents: z.boolean(),
|
||||
recurrence: z.object({
|
||||
frequency: ERecurringType,
|
||||
frequency: ERecurringTypeDTO,
|
||||
occurrences: z.number().int(),
|
||||
}),
|
||||
}).strict();
|
||||
|
||||
const EventUpdateStatusModel = z.object({
|
||||
status: EEventStatus,
|
||||
export const EventUpdateStatusDTOSchema = z.object({
|
||||
status: EEventStatusDTO,
|
||||
comment: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const ProblemDetails = z.object({
|
||||
export const ProblemDetailsDTOSchema = z.object({
|
||||
type: z.string().nullable().optional(),
|
||||
title: z.string().nullable().optional(),
|
||||
status: z.number().int().nullable().optional(),
|
||||
@@ -124,43 +126,77 @@ const ProblemDetails = z.object({
|
||||
instance: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
|
||||
const ResponseSimpleModel = z.object({
|
||||
export const ResponseSimpleDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().nullable().optional(),
|
||||
data: z.any().nullable().optional(),
|
||||
}).strict();
|
||||
})
|
||||
|
||||
const Bearer = z.object({
|
||||
type: z.literal('http'),
|
||||
description: z.string().optional(),
|
||||
scheme: z.literal('bearer'),
|
||||
}).strict();
|
||||
|
||||
export {
|
||||
AttachCommunicationInputModel,
|
||||
AttachmentInputModel,
|
||||
AttendeeCommunicationInputModel,
|
||||
AttendeeExternalInputModel,
|
||||
AttendeeInputModel,
|
||||
EAttendeeType,
|
||||
EEventCategory,
|
||||
EEventFilterCategory,
|
||||
EEventFilterStatus,
|
||||
EEventFilterType,
|
||||
EEventOwnerType,
|
||||
EEventStatus,
|
||||
EEventType,
|
||||
ERecurringType,
|
||||
EventAddAttachmentModel,
|
||||
EventAddAttendeeModel,
|
||||
EventCommunicationInputModel,
|
||||
EventInputModel,
|
||||
EventRecurrenceInputModel,
|
||||
EventRemoveAttachmentModel,
|
||||
EventRemoveAttendeeModel,
|
||||
EventUpdateModel,
|
||||
EventUpdateStatusModel,
|
||||
ProblemDetails,
|
||||
ResponseSimpleModel,
|
||||
Bearer,
|
||||
};
|
||||
const CommentSchema = z.object({
|
||||
message: z.string(),
|
||||
createdAt: z.string(),
|
||||
});
|
||||
|
||||
const AttendeeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
attendeeType: EAttendeeTypeDTO,
|
||||
emailAddress: z.string(),
|
||||
wxUserId: z.number(),
|
||||
});
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
const OrganizerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
const EventOutputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.string(),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.string(),
|
||||
category: z.string(),
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: z.null(),
|
||||
hasAttachments: z.boolean(),
|
||||
attachments:z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.string(),
|
||||
});
|
||||
|
||||
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
|
||||
export type AttachCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttachmentInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeExternalInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventAddAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventAddAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventRecurrenceInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventRemoveAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventRemoveAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventUpdateDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventUpdateStatusDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type ProblemDetailsDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type ResponseSimpleDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import { EventOutputDTO } from "../model/eventDTOOutput"
|
||||
|
||||
export class EventMapper {
|
||||
|
||||
constructor() {}
|
||||
static toDomain(dto: EventOutputDTO) {
|
||||
|
||||
return {
|
||||
"HasAttachments": dto.hasAttachments,
|
||||
"EventComunicationId": 1682,
|
||||
"EventId": dto.id,
|
||||
"Subject": dto.subject,
|
||||
"Body": {
|
||||
"BodyType": 1,
|
||||
"Text": dto.body
|
||||
},
|
||||
"Location": dto.location,
|
||||
"CalendarId": "",
|
||||
"CalendarName": dto.category,
|
||||
"StartDate": dto.startDate,
|
||||
"EndDate": dto.endDate,
|
||||
"EventType": "Single",
|
||||
"Attendees": dto.attendees.map((e) => ({
|
||||
Id: e.id,
|
||||
EmailAddress: e.emailAddress,
|
||||
Name: e.name,
|
||||
IsRequired: e.attendeeType == '0' ? true : false,
|
||||
UserType: "GD",
|
||||
// "IsPR": false,
|
||||
Acknowledgment: e.attendeeType == '0' ? true : false,
|
||||
// "RoleDescription": null,
|
||||
// "RoleId": 0
|
||||
})),
|
||||
"IsMeeting": dto.category,
|
||||
"IsRecurring": dto.isRecurring,
|
||||
"IsAllDayEvent": dto.isAllDayEvent,
|
||||
"AppointmentState": 1,
|
||||
"TimeZone": "UTC",
|
||||
"Organizer": {
|
||||
"Id": dto.organizer.wxUserId,
|
||||
"EmailAddress": dto.organizer.wxeMail,
|
||||
"Name": dto.organizer.wxFullName,
|
||||
"IsRequired": true,
|
||||
"UserType": 'GD',
|
||||
"IsPR": dto.ownerType == 'PR',
|
||||
//"Entity": null,
|
||||
"Acknowledgment": true,
|
||||
//"RoleDescription": null,
|
||||
//"RoleId": 0
|
||||
},
|
||||
"InstanceId": null,
|
||||
"Category": dto.type,
|
||||
"EventRecurrence": {
|
||||
"Type": -1,
|
||||
"Day": null,
|
||||
"DayOfWeek": null,
|
||||
"Month": null,
|
||||
"LastOccurrence": null
|
||||
},
|
||||
"Attachments": dto.attachments.map( e => ({
|
||||
"Id": e.sourceId,
|
||||
// "ParentId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2OeJAAA=",
|
||||
// "Source": 1,
|
||||
"SourceId": e.sourceId,
|
||||
// "Description": "teste pp",
|
||||
"SourceName": e.sourceName,
|
||||
// "CreateDate": "2024-05-24 16:41",
|
||||
// "Stakeholders": "",
|
||||
// "Link": "",
|
||||
// "Data": null,
|
||||
"ApplicationId": e.applicationId,
|
||||
// "FileSize": 301208
|
||||
|
||||
})),
|
||||
"IsPrivate": dto.isPrivate
|
||||
}
|
||||
}
|
||||
|
||||
static toDTO(data: any): any {
|
||||
return {}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { EventList } from "src/app/models/entiry/agenda/eventList"
|
||||
import { EventListOutputDTO } from "../model/eventListDTOOutput"
|
||||
|
||||
|
||||
function getTextInsideParentheses(inputString): string {
|
||||
var startIndex = inputString.indexOf('(');
|
||||
var endIndex = inputString.indexOf(')');
|
||||
if (startIndex !== -1 && endIndex !== -1) {
|
||||
return inputString.substring(startIndex + 1, endIndex);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListEventMapper {
|
||||
static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): EventList {
|
||||
return dto.map((e) => ({
|
||||
"HasAttachments": e.hasAttachments,
|
||||
"IsAllDayEvent": e.isAllDayEvent,
|
||||
"EventId": e.id,
|
||||
"Subject": e.subject,
|
||||
"Location": e.location,
|
||||
"CalendarId": userId,
|
||||
"CalendarName": e.category,
|
||||
"StartDate": new Date(e.startDate) + '',
|
||||
"EndDate": new Date(e.endDate)+ '',
|
||||
"Schedule": calendarOwnerName,
|
||||
"RequiredAttendees": null as any,
|
||||
"OptionalAttendees": null as any,
|
||||
"HumanDate": "2 semanas atrás" as any,
|
||||
"TimeZone": getTextInsideParentheses(new Date(e.startDate)+ ''),
|
||||
"IsPrivate": false as any
|
||||
}))
|
||||
}
|
||||
|
||||
static toDTO() {}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const AttachmentInputDTOSchema = z.object({
|
||||
sourceId: z.string().nullable(),
|
||||
sourceName: z.string().nullable(),
|
||||
description: z.string().nullable(),
|
||||
applicationId: z.number().int(),
|
||||
}).strict();
|
||||
const EAttendeeTypeDTO = z.enum(["0", "1", "2"]);
|
||||
|
||||
|
||||
const CommentSchema = z.object({
|
||||
message: z.string(),
|
||||
createdAt: z.string(),
|
||||
});
|
||||
|
||||
const AttendeeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
attendeeType: EAttendeeTypeDTO,
|
||||
emailAddress: z.string(),
|
||||
wxUserId: z.number(),
|
||||
});
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
const OrganizerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
export const EventOutputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.string(),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.string(),
|
||||
category: z.string(),
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: z.null(),
|
||||
hasAttachments: z.boolean(),
|
||||
attachments:z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.string(),
|
||||
});
|
||||
|
||||
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
|
||||
@@ -0,0 +1,22 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const EventSchema = z.array(z.object({
|
||||
id: z.string(),
|
||||
owner: z.string().nullable(),
|
||||
ownerType: z.enum(['MD','PR', 'Other']), // Assuming "MD" is the only valid option based on provided data
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string().datetime({ offset: true }),
|
||||
endDate: z.string().datetime({ offset: true }),
|
||||
type: z.enum(['Meeting', 'Travel']),
|
||||
category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: z.null(),
|
||||
hasAttachments: z.boolean(),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data
|
||||
}))
|
||||
|
||||
export type EventListOutputDTO = z.infer<typeof EventSchema>;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const EventToApproveList = z.object({
|
||||
id: z.string().uuid(),
|
||||
owner: z.string().nullable(),
|
||||
ownerType: z.enum(["PR", "MD", "Other"]),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
type: z.enum(["Meeting"]),
|
||||
category: z.enum(["Oficial", "Pessoal"]),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: z.any().nullable(),
|
||||
hasAttachments: z.boolean(),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
status: z.enum(["Pending"])
|
||||
});
|
||||
Reference in New Issue
Block a user