Files
doneit-web/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts
T

137 lines
3.7 KiB
TypeScript
Raw Normal View History

2024-06-13 16:47:51 +01:00
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus } from "../model/enums";
2024-05-29 15:45:34 +01:00
import { EventOutputDTO } from "../model/eventDTOOutput"
2024-06-03 13:28:18 +01:00
function getTextInsideParentheses(inputString) {
var startIndex = inputString.indexOf('(');
var endIndex = inputString.indexOf(')');
if (startIndex !== -1 && endIndex !== -1) {
return inputString.substring(startIndex + 1, endIndex);
} else {
return null;
}
}
2024-05-29 15:45:34 +01:00
export class EventMapper {
constructor() {}
2024-06-17 17:04:42 +01:00
static toDomain(_dto: EventOutputDTO) {
const dto = _dto.data;
2024-05-29 15:45:34 +01:00
2024-06-13 16:01:33 +01:00
let category;
2024-06-13 16:47:51 +01:00
if(dto.category == EEventCategory.Oficial) {
2024-06-13 16:01:33 +01:00
category = 'Oficial'
} else {
category = 'Pessoal'
}
let ownerType;
2024-06-13 16:47:51 +01:00
if(dto.ownerType == EEventOwnerType.PR) {
2024-06-13 16:01:33 +01:00
ownerType = 'PR'
2024-06-13 16:47:51 +01:00
} else if(dto.ownerType == EEventOwnerType.MD) {
2024-06-13 16:01:33 +01:00
ownerType = 'MD'
2024-06-13 16:47:51 +01:00
} else if(dto.ownerType == EEventOwnerType.Others) {
2024-06-13 16:01:33 +01:00
ownerType = 'Other'
}
let type;
let status;
2024-06-13 16:47:51 +01:00
if(dto.status == EEventStatus.Pending) {
2024-06-13 16:01:33 +01:00
status = 'Pending'
2024-06-13 16:47:51 +01:00
} else if(dto.status == EEventStatus.Revision) {
2024-06-13 16:01:33 +01:00
status = 'Revision'
}
2024-06-13 16:47:51 +01:00
function FEAttendeeType(num) {
if(num == EAttendeeType.Required) {
2024-06-13 16:01:33 +01:00
return 'Required'
2024-06-13 16:47:51 +01:00
} else if (num == EAttendeeType.Acknowledgment) {
2024-06-13 16:01:33 +01:00
return 'Acknowledgment'
2024-06-13 16:47:51 +01:00
} else if (num == EAttendeeType.Optional) {
2024-06-13 16:01:33 +01:00
return 'Optional'
}
}
2024-06-18 09:14:22 +01:00
2024-05-29 15:45:34 +01:00
return {
2024-06-18 09:14:22 +01:00
"owner": dto.owner,
2024-05-29 15:45:34 +01:00
"HasAttachments": dto.hasAttachments,
"EventComunicationId": 1682,
"EventId": dto.id,
"Subject": dto.subject,
"Body": {
"BodyType": 1,
"Text": dto.body
},
"Location": dto.location,
"CalendarId": "",
2024-06-13 16:01:33 +01:00
"CalendarName": category,
2024-05-29 15:45:34 +01:00
"StartDate": dto.startDate,
"EndDate": dto.endDate,
"EventType": "Single",
"Attendees": dto.attendees.map((e) => ({
2024-06-24 15:35:16 +01:00
Id: e.id,
2024-06-02 13:53:46 +01:00
wxUserId: e.wxUserId,
2024-05-29 15:45:34 +01:00
EmailAddress: e.emailAddress,
Name: e.name,
2024-06-13 16:47:51 +01:00
IsRequired: FEAttendeeType(e.attendeeType) == 'Required',
2024-05-29 15:45:34 +01:00
UserType: "GD",
// "IsPR": false,
2024-06-17 17:04:42 +01:00
attendeeType: FEAttendeeType(e.attendeeType)
2024-05-29 15:45:34 +01:00
// "RoleDescription": null,
// "RoleId": 0
})),
2024-06-13 16:01:33 +01:00
"IsMeeting": category,
2024-05-29 15:45:34 +01:00
"IsRecurring": dto.isRecurring,
"IsAllDayEvent": dto.isAllDayEvent,
"AppointmentState": 1,
2024-06-03 13:28:18 +01:00
"TimeZone": getTextInsideParentheses(new Date(dto.startDate)+ ''),
2024-05-29 15:45:34 +01:00
"Organizer": {
"Id": dto.organizer.wxUserId,
"EmailAddress": dto.organizer.wxeMail,
"Name": dto.organizer.wxFullName,
"IsRequired": true,
"UserType": 'GD',
2024-06-13 16:01:33 +01:00
"IsPR": ownerType == 'PR',
2024-05-29 15:45:34 +01:00
//"Entity": null,
"Acknowledgment": true,
//"RoleDescription": null,
//"RoleId": 0
},
"InstanceId": null,
"Category": dto.type,
"EventRecurrence": {
"Type": -1,
"Day": null,
"DayOfWeek": null,
"Month": null,
2024-06-10 09:55:23 +01:00
"LastOccurrence": null,
2024-06-18 14:24:29 +01:00
"frequency": dto?.eventRecurrence?.frequency,
"until": dto?.eventRecurrence?.until
2024-05-29 15:45:34 +01:00
},
"Attachments": dto.attachments.map( e => ({
2024-05-31 11:21:32 +01:00
"Id": e.id,
2024-05-29 15:45:34 +01:00
// "ParentId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2OeJAAA=",
// "Source": 1,
2024-05-31 11:21:32 +01:00
"SourceId": e.docId,
2024-05-29 15:45:34 +01:00
// "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 {}
}
}