mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
list event to approve
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from './agenda-data.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { ListEventMapper } from './mapper/EventListMapper';
|
||||
import { EventMapper } from './mapper/EventDetailsMapper';
|
||||
import { Utils } from './utils';
|
||||
import { EventInputDTO } from './agendaDataModels';
|
||||
import { Event } from 'src/app/models/event.model';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { EventListToApproveMapper } from './mapper/eventToApproveListMapper';
|
||||
import { err, ok } from 'neverthrow';
|
||||
import { of } from 'rxjs';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -34,10 +38,11 @@ export class AgendaDataRepositoryService {
|
||||
))
|
||||
}
|
||||
|
||||
eventToApprove({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {
|
||||
eventToApproveList({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)
|
||||
return EventListToApproveMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||
}
|
||||
))
|
||||
}
|
||||
@@ -109,4 +114,15 @@ export class AgendaDataRepositoryService {
|
||||
console.log(error)
|
||||
}))
|
||||
}
|
||||
|
||||
async deleteEvent1(eventId) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.deleteEvent(eventId,false).toPromise()
|
||||
return ok (result)
|
||||
} catch (e) {
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EventOutputDTO } from './model/eventDTOOutput';
|
||||
import { EventInputDTO } from './model/eventInputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -34,7 +35,7 @@ export class AgendaDataService {
|
||||
}
|
||||
|
||||
// Events Endpoints
|
||||
createEvent(eventData: any): Observable<any> {
|
||||
createEvent(eventData: EventInputDTO): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { EventList } from "src/app/models/entiry/agenda/eventList"
|
||||
import { EventListOutputDTO } from "../model/eventListDTOOutput"
|
||||
import { EventToApproveListOutputDTO } from "../model/eventToApproveListOutputDTO";
|
||||
import { EventToApproveList } from "src/app/models/entiry/agenda/eventToApproveList";
|
||||
|
||||
|
||||
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 EventListToApproveMapper {
|
||||
static toDomain(dto: EventToApproveListOutputDTO, calendarOwnerName: string, userId: string): EventToApproveList {
|
||||
return dto.map((e) => ({
|
||||
serialNumber: e.id,
|
||||
taskStatus: e.status,
|
||||
taskStartDate: e.startDate,
|
||||
taskReceiveDate: e.startDate,
|
||||
deadline: null,
|
||||
workflowDisplayName: "",
|
||||
activityInstanceName: "",
|
||||
totalDocuments: 0,
|
||||
workflowInstanceDataFields: {
|
||||
Agenda: e.category,
|
||||
EndDate: e.endDate,
|
||||
StartDate: e.startDate,
|
||||
Subject: e.body,
|
||||
Location: e.location,
|
||||
Status: e.status,
|
||||
IsAllDayEvent: e.isAllDayEvent,
|
||||
InstanceId: "",
|
||||
originator: ""
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
static toDTO() {}
|
||||
}
|
||||
|
||||
|
||||
// "serialNumber": "47315_184",
|
||||
// "taskStatus": "Open",
|
||||
// "taskStartDate": "2024-04-24T11:27:12.527",
|
||||
// "taskReceiveDate": "2024-04-24T11:29:17.76",
|
||||
// "deadline": null,
|
||||
// "workflowDisplayName": "Agenda Oficial PR",
|
||||
// "activityInstanceName": "Comunicar Evento",
|
||||
// "totalDocuments": 0,
|
||||
// "workflowInstanceDataFields": {
|
||||
// "Agenda": "Oficial",
|
||||
// "EndDate": "2024-04-25 11:30:00",
|
||||
// "StartDate": "2024-04-24 11:30:00",
|
||||
// "Subject": "Event 2 After MERGE",
|
||||
// "Location": "lUANDA",
|
||||
// "Status": "Active",
|
||||
// "IsAllDayEvent": false,
|
||||
// "InstanceId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2Od9AAA=",
|
||||
// "originator": "dlima@gabinetedigital.local"
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// "id": "5b170417-df57-4b5c-9a5e-3c73726a116d",
|
||||
// "owner": null,
|
||||
// "ownerType": "PR",
|
||||
// "subject": "string",
|
||||
// "body": "string",
|
||||
// "location": "string",
|
||||
// "startDate": "2024-05-29T00:00:00+00:00",
|
||||
// "endDate": "2024-05-29T23:59:00+00:00",
|
||||
// "type": "Meeting",
|
||||
// "category": "Oficial",
|
||||
// "isRecurring": false,
|
||||
// "eventRecurrence": null,
|
||||
// "hasAttachments": false,
|
||||
// "isPrivate": false,
|
||||
// "isAllDayEvent": true,
|
||||
// "status": "Pending"
|
||||
// }
|
||||
@@ -0,0 +1,42 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const attendeeSchema = z.object({
|
||||
name: z.string(),
|
||||
emailAddress: z.string(),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number()
|
||||
});
|
||||
|
||||
const attachmentSchema = z.object({
|
||||
docId: z.number(),
|
||||
sourceName: z.string(),
|
||||
description: z.string(),
|
||||
applicationId: z.number()
|
||||
});
|
||||
|
||||
const recurrenceSchema = z.object({
|
||||
frequency: z.number(),
|
||||
occurrences: z.number()
|
||||
});
|
||||
|
||||
const EventInputDTOSchema = z.object({
|
||||
userId: z.number(),
|
||||
ownerType: z.number(),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
type: z.number(),
|
||||
category: z.number(),
|
||||
attendees: z.array(attendeeSchema),
|
||||
attachments: z.array(attachmentSchema),
|
||||
recurrence: recurrenceSchema,
|
||||
organizerId: z.number(),
|
||||
isAllDayEvent: z.boolean()
|
||||
});
|
||||
|
||||
|
||||
|
||||
export type EventInputDTO = z.infer<typeof EventInputDTOSchema>
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const EventToApproveList = z.object({
|
||||
const EventToApproveList = z.array(z.object({
|
||||
id: z.string().uuid(),
|
||||
owner: z.string().nullable(),
|
||||
ownerType: z.enum(["PR", "MD", "Other"]),
|
||||
@@ -17,4 +17,6 @@ const EventToApproveList = z.object({
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
status: z.enum(["Pending"])
|
||||
});
|
||||
}))
|
||||
|
||||
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>;
|
||||
Reference in New Issue
Block a user