Merge branch 'feature/agenda-new-api-eudes' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/agenda-new-api-eudes

This commit is contained in:
Eudes Inácio
2024-06-14 09:19:13 +01:00
7 changed files with 136 additions and 57 deletions
@@ -1,3 +1,4 @@
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus } from "../model/enums";
import { EventOutputDTO } from "../model/eventDTOOutput" import { EventOutputDTO } from "../model/eventDTOOutput"
function getTextInsideParentheses(inputString) { function getTextInsideParentheses(inputString) {
@@ -16,36 +17,36 @@ export class EventMapper {
static toDomain(dto: EventOutputDTO) { static toDomain(dto: EventOutputDTO) {
let category; let category;
if(dto.category == 1) { if(dto.category == EEventCategory.Oficial) {
category = 'Oficial' category = 'Oficial'
} else { } else {
category = 'Pessoal' category = 'Pessoal'
} }
let ownerType; let ownerType;
if(dto.ownerType == 1) { if(dto.ownerType == EEventOwnerType.PR) {
ownerType = 'PR' ownerType = 'PR'
} else if(dto.ownerType == 2) { } else if(dto.ownerType == EEventOwnerType.MD) {
ownerType = 'MD' ownerType = 'MD'
} else if(dto.ownerType == 3) { } else if(dto.ownerType == EEventOwnerType.Others) {
ownerType = 'Other' ownerType = 'Other'
} }
let type; let type;
let status; let status;
if(dto.status == 1) { if(dto.status == EEventStatus.Pending) {
status = 'Pending' status = 'Pending'
} else if(dto.status == 2) { } else if(dto.status == EEventStatus.Revision) {
status = 'Revision' status = 'Revision'
} }
function EAttendeeType(num) { function FEAttendeeType(num) {
if(num == 1) { if(num == EAttendeeType.Required) {
return 'Required' return 'Required'
} else if (num == 2) { } else if (num == EAttendeeType.Acknowledgment) {
return 'Acknowledgment' return 'Acknowledgment'
} else if (num == 3) { } else if (num == EAttendeeType.Optional) {
return 'Optional' return 'Optional'
} }
} }
@@ -70,10 +71,10 @@ export class EventMapper {
wxUserId: e.wxUserId, wxUserId: e.wxUserId,
EmailAddress: e.emailAddress, EmailAddress: e.emailAddress,
Name: e.name, Name: e.name,
IsRequired: EAttendeeType(e.attendeeType) == 'Required', IsRequired: FEAttendeeType(e.attendeeType) == 'Required',
UserType: "GD", UserType: "GD",
// "IsPR": false, // "IsPR": false,
attendeeType: EAttendeeType(e.attendeeType) attendeeType: FEAttendeeType(e.attendeeType)
// "RoleDescription": null, // "RoleDescription": null,
// "RoleId": 0 // "RoleId": 0
})), })),
@@ -1,5 +1,6 @@
import { EventList } from "src/app/models/entiry/agenda/eventList" import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput" import { EventListOutputDTO } from "../model/eventListDTOOutput"
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from "../model/enums";
function getTextInsideParentheses(inputString): string { function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('('); var startIndex = inputString.indexOf('(');
@@ -17,33 +18,38 @@ export class ListEventMapper {
return dto.map((e) => { return dto.map((e) => {
let category; let category;
if(e.category == 1) { if(e.category == EEventCategory.Oficial) {
category = 'Oficial' category = 'Oficial'
} else { } else {
category = 'Pessoal' category = 'Pessoal'
} }
let ownerType; let ownerType;
if(e.ownerType == 1) { if(e.ownerType == EEventOwnerType.PR) {
ownerType = 'PR' ownerType = 'PR'
} else if(e.ownerType == 2) { } else if(e.ownerType == EEventOwnerType.MD) {
ownerType = 'MD' ownerType = 'MD'
} else if(e.ownerType == 3) { } else if(e.ownerType == EEventOwnerType.Others) {
ownerType = 'Other' ownerType = 'Other'
} }
let type; let type;
if(e.type == 1) { if(e.type == EEventType.Meeting) {
type = 'Meeting' type = 'Meeting'
} else { } else if (e.type == EEventType.Travel) {
type = 'Travel' type = 'Travel'
} }
let status; let status;
if(e.status == 1) { if(e.status == EEventStatus.Pending) {
status = 'Pending' status = 'Pending'
} else if(e.status == 2) { } else if(e.status == EEventStatus.Revision) {
status = 'Revision' status = 'Revision'
} else if(e.status == EEventStatus.Approved) {
status = 'Approved'
} else if(e.status == EEventStatus.Declined) {
status = 'Declined'
} }
return { return {
@@ -1,5 +1,6 @@
import { EventToApproveDetails } from "src/app/models/entiry/agenda/eventToApproveDetails" import { EventToApproveDetails } from "src/app/models/entiry/agenda/eventToApproveDetails"
import { EventOutputDTO } from "../model/eventDTOOutput" import { EventOutputDTO } from "../model/eventDTOOutput"
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus } from "../model/enums";
function getTextInsideParentheses(inputString) { function getTextInsideParentheses(inputString) {
var startIndex = inputString.indexOf('('); var startIndex = inputString.indexOf('(');
@@ -18,7 +19,7 @@ export class EventToApproveDetailsMapper {
static toDomain(dto: EventOutputDTO): EventToApproveDetails { static toDomain(dto: EventOutputDTO): EventToApproveDetails {
let category; let category;
if(dto.category == 1) { if(dto.category == EEventCategory.Oficial) {
category = 'Oficial' category = 'Oficial'
} else { } else {
category = 'Pessoal' category = 'Pessoal'
@@ -27,40 +28,44 @@ export class EventToApproveDetailsMapper {
let color; let color;
// if(dto.ownerType != 'PR') { // if(dto.ownerType != 'PR') {
if(dto.ownerType == 2) { let ownerType;
color = 'MDGPR' if(dto.ownerType == EEventOwnerType.PR) {
} else { ownerType = 'PR'
color = 'PR' } else if(dto.ownerType == EEventOwnerType.MD) {
ownerType = 'MD'
} else if(dto.ownerType == EEventOwnerType.Others) {
ownerType = 'Other'
} }
let activityInstanceName; let activityInstanceName;
let taskStatus; let taskStatus;
if(dto.status == 1) { if(dto.status == EEventStatus.Pending) {
activityInstanceName = 'Aprovar evento' activityInstanceName = 'Aprovar evento'
taskStatus = 'Pending' ////// taskStatus = 'Pending' //////
} else if(dto.status == 2) { } else if(dto.status == EEventStatus.Revision) {
activityInstanceName = 'Editar evento' activityInstanceName = 'Editar evento'
taskStatus = 'Revision' ////// taskStatus = 'Revision' //////
} else if (dto.status == 3) { } else if (dto.status == EEventStatus.Approved) {
activityInstanceName = 'Evento Aprovado' activityInstanceName = 'Evento Aprovado'
taskStatus = 'Approved' ////// taskStatus = 'Approved' //////
} else if (dto.status == 4) { } else if (dto.status == EEventStatus.Declined) {
activityInstanceName = 'Declined' activityInstanceName = 'Declined'
taskStatus = 'Declined' ////// taskStatus = 'Declined' //////
} else if (dto.status == 5) { } else if (dto.status == EEventStatus.Communicated) {
activityInstanceName = 'Communicated' activityInstanceName = 'Communicated'
taskStatus = 'Communicated' ////// taskStatus = 'Communicated' //////
} else if (dto.status == 6) { } else if (dto.status == EEventStatus.ToCommunicate) {
activityInstanceName = 'ToCommunicate' activityInstanceName = 'ToCommunicate'
taskStatus = 'ToCommunicate' ////// taskStatus = 'ToCommunicate' //////
} }
function EAttendeeType(num) { function FEAttendeeType(num) {
if(num == 1) { if(num == EAttendeeType.Required) {
return 'Required' return 'Required'
} else if (num == 2) { } else if (num == EAttendeeType.Acknowledgment) {
return 'Acknowledgment' return 'Acknowledgment'
} else if (num == 3) { } else if (num == EAttendeeType.Optional) {
return 'Optional' return 'Optional'
} }
} }
@@ -115,10 +120,10 @@ export class EventToApproveDetailsMapper {
...dto.attendees.map( e => ({ ...dto.attendees.map( e => ({
Name: e.name, Name: e.name,
EmailAddress: e.emailAddress, EmailAddress: e.emailAddress,
IsRequired: EAttendeeType(e.attendeeType) == 'Required', IsRequired: FEAttendeeType(e.attendeeType) == 'Required',
UserType: "GD", UserType: "GD",
wxUserId: e.wxUserId, wxUserId: e.wxUserId,
attendeeType: EAttendeeType(e.attendeeType) attendeeType: FEAttendeeType(e.attendeeType)
})) }))
], ],
//"EventOrganizer": "{\"$type\":\"GabineteDigital.k2RESTidentifier_EventPerson, GabineteDigital, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"EmailAddress\":\"agenda.mdgpr@gabinetedigital.local\",\"Name\":\"Agenda do Ministro e Director do Gabinete do PR\",\"IsRequired\":true}", //"EventOrganizer": "{\"$type\":\"GabineteDigital.k2RESTidentifier_EventPerson, GabineteDigital, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"EmailAddress\":\"agenda.mdgpr@gabinetedigital.local\",\"Name\":\"Agenda do Ministro e Director do Gabinete do PR\",\"IsRequired\":true}",
@@ -2,6 +2,7 @@ import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput" import { EventListOutputDTO } from "../model/eventListDTOOutput"
import { EventToApproveListOutputDTO } from "../model/eventToApproveListOutputDTO"; import { EventToApproveListOutputDTO } from "../model/eventToApproveListOutputDTO";
import { EventToApproveList } from "src/app/models/entiry/agenda/eventToApproveList"; import { EventToApproveList } from "src/app/models/entiry/agenda/eventToApproveList";
import { EEventCategory, EEventOwnerType, EEventStatus } from "../model/enums";
function getTextInsideParentheses(inputString): string { function getTextInsideParentheses(inputString): string {
@@ -19,11 +20,18 @@ export class EventListToApproveMapper {
return dtoList.map((dto) => { return dtoList.map((dto) => {
const category = dto.category
let category;
if(dto.category == EEventCategory.Oficial) {
category = 'Oficial'
} else {
category = 'Pessoal'
}
let color; let color;
let workflowDisplayName; let workflowDisplayName;
if(dto.ownerType == 'PR') { if(dto.ownerType == EEventOwnerType.PR) {
color = 'PR' color = 'PR'
workflowDisplayName = `Agenda ${category} ${color}` workflowDisplayName = `Agenda ${category} ${color}`
} else { } else {
@@ -35,25 +43,31 @@ export class EventListToApproveMapper {
// } // }
let activityInstanceName; let activityInstanceName;
let taskStatus;
if(dto.status == 'Pending') { if(dto.status == EEventStatus.Pending) {
activityInstanceName = 'Aprovar evento' activityInstanceName = 'Aprovar evento'
} else if(dto.status == 'Revision') { taskStatus = 'Pending' //////
} else if(dto.status == EEventStatus.Revision) {
activityInstanceName = 'Editar evento' activityInstanceName = 'Editar evento'
} else if (dto.status == 'Approved') { taskStatus = 'Revision' //////
} else if (dto.status == EEventStatus.Approved) {
activityInstanceName = 'Evento Aprovado' activityInstanceName = 'Evento Aprovado'
} else if (dto.status == 'Evento Rejeitado') { taskStatus = 'Approved' //////
} else if (dto.status == EEventStatus.Declined) {
activityInstanceName = 'Declined' activityInstanceName = 'Declined'
} else if (dto.status == 'Evento comunicado') { taskStatus = 'Declined' //////
} else if (dto.status == EEventStatus.Communicated) {
activityInstanceName = 'Communicated' activityInstanceName = 'Communicated'
} else if (dto.status == 'Comunicar evento') { taskStatus = 'Communicated' //////
} else if (dto.status == EEventStatus.ToCommunicate) {
activityInstanceName = 'ToCommunicate' activityInstanceName = 'ToCommunicate'
taskStatus = 'ToCommunicate' //////
} }
return { return {
serialNumber: dto.id, serialNumber: dto.id,
taskStatus: dto.status, taskStatus: taskStatus,
taskStartDate: dto.startDate, taskStartDate: dto.startDate,
taskReceiveDate: dto.startDate, taskReceiveDate: dto.startDate,
deadline: null, deadline: null,
@@ -61,12 +75,12 @@ export class EventListToApproveMapper {
activityInstanceName, activityInstanceName,
totalDocuments: 0, totalDocuments: 0,
workflowInstanceDataFields: { workflowInstanceDataFields: {
Agenda: dto.category, Agenda: category,
EndDate: dto.endDate, EndDate: dto.endDate,
StartDate: dto.startDate, StartDate: dto.startDate,
Subject: dto.subject, Subject: dto.subject,
Location: dto.location, Location: dto.location,
Status: dto.status, Status: "Active",
IsAllDayEvent: dto.isAllDayEvent, IsAllDayEvent: dto.isAllDayEvent,
InstanceId: "", InstanceId: "",
originator: "" originator: ""
@@ -0,0 +1,51 @@
export enum EEventFilterStatus {
All = -1,
Pending = 1,
Revision,
Approved,
Declined,
Communicated,
ToCommunicate,
AllToCommunicate,
PendingEvents,
}
// Define your TypeScript enum
export enum EEventStatus {
Pending = 1,
Revision,
Approved,
Declined,
Communicated,
ToCommunicate,
}
export enum EEventCategory
{
Oficial = 1,
Pessoal
}
export enum EEventOwnerType {
PR = 1,
MD,
Others
}
export enum EEventType
{
Meeting = 1,
Travel,
Conference,
}
export enum EAttendeeType {
Required,
Acknowledgment,
Optional
}
@@ -1,24 +1,25 @@
import { z } from 'zod'; import { z } from 'zod';
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
const EventSchema = z.array(z.object({ const EventSchema = z.array(z.object({
id: z.string(), id: z.string(),
owner: z.string().nullable(), owner: z.string().nullable(),
ownerType: z.number(),// ['MD','PR', 'Other'] // Assuming "MD" is the only valid option based on provided data ownerType: z.nativeEnum(EEventOwnerType),// ['MD','PR', 'Other'] // Assuming "MD" is the only valid option based on provided data
subject: z.string(), subject: z.string(),
body: z.string(), body: z.string(),
location: z.string(), location: z.string(),
startDate: z.string().datetime({ offset: true }), startDate: z.string().datetime({ offset: true }),
endDate: z.string().datetime({ offset: true }), endDate: z.string().datetime({ offset: true }),
type: z.number(), // ['Meeting', 'Travel'] = [1,2 ] type: z.nativeEnum(EEventType), // ['Meeting', 'Travel'] = [1,2 ]
// category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data // category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data
category: z.number(), category: z.nativeEnum(EEventCategory),
isRecurring: z.boolean(), isRecurring: z.boolean(),
eventRecurrence: z.null(), eventRecurrence: z.null(),
hasAttachments: z.boolean(), hasAttachments: z.boolean(),
isPrivate: z.boolean(), isPrivate: z.boolean(),
isAllDayEvent: z.boolean(), isAllDayEvent: z.boolean(),
// status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data // status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data
status: z.number(), // Assuming "Approved" is the only valid option based on provided data status: z.nativeEnum(EEventStatus), // Assuming "Approved" is the only valid option based on provided data
})) }))
export type EventListOutputDTO = z.infer<typeof EventSchema>; export type EventListOutputDTO = z.infer<typeof EventSchema>;
@@ -1,22 +1,23 @@
import { z } from "zod"; import { z } from "zod";
import { EEventOwnerType, EEventType, EEventCategory, EEventStatus } from "./enums";
const EventToApproveList = z.array(z.object({ const EventToApproveList = z.array(z.object({
id: z.string().uuid(), id: z.string().uuid(),
owner: z.string().nullable(), owner: z.string().nullable(),
ownerType: z.enum(["PR", "MD", "Other"]), ownerType: z.nativeEnum(EEventOwnerType),
subject: z.string(), subject: z.string(),
body: z.string(), body: z.string(),
location: z.string(), location: z.string(),
startDate: z.string().datetime(), startDate: z.string().datetime(),
endDate: z.string().datetime(), endDate: z.string().datetime(),
type: z.enum(["Meeting"]), type: z.nativeEnum(EEventType),
category: z.enum(["Oficial", "Pessoal"]), category: z.nativeEnum(EEventCategory),
isRecurring: z.boolean(), isRecurring: z.boolean(),
eventRecurrence: z.any().nullable(), eventRecurrence: z.any().nullable(),
hasAttachments: z.boolean(), hasAttachments: z.boolean(),
isPrivate: z.boolean(), isPrivate: z.boolean(),
isAllDayEvent: z.boolean(), isAllDayEvent: z.boolean(),
status: z.enum(["Pending"]) status: z.nativeEnum(EEventStatus)
})) }))
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>; export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>;