فهرست منبع

acciones del modal de solicitudes de workflow implementadas con error por encrypt user

EmilianoOrtiz 1 ماه پیش
والد
کامیت
ca0bfe9e7a

+ 42 - 7
src/app/components/template/notification-dialog/validate-applications-modal/validate-applications-modal.component.ts

@@ -1,6 +1,9 @@
 import { Component, Inject } from '@angular/core';
 import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
 import { ValidateApplication } from '../../../../interfaces/process-managementv/workflow-management.interface';
+import { ProcessManagementService } from '../../../../services/process-management/process-management.service';
+import { ResourcesService } from '../../../../services/resources.service';
+import { lastValueFrom } from 'rxjs';
 
 @Component({
   selector: 'app-validate-applications-modal',
@@ -13,7 +16,9 @@ export class ValidateApplicationsModalComponent {
 
   constructor(
     @Inject(MAT_DIALOG_DATA) public data: { applications: ValidateApplication[] },
-    private dialogRef: MatDialogRef<ValidateApplicationsModalComponent>
+    private dialogRef: MatDialogRef<ValidateApplicationsModalComponent>,
+    private processManagementService: ProcessManagementService,
+    private resourcesService: ResourcesService
   ) {
     this.applications = data.applications;
   }
@@ -22,13 +27,43 @@ export class ValidateApplicationsModalComponent {
     this.dialogRef.close();
   }
 
-  validateApplication(app: ValidateApplication) {
-    console.log('Validar aplicación:', app);
-    // TODO: Implementar lógica de validación
+  async validateApplication(app: ValidateApplication) {
+    try {
+      const idUser = localStorage.getItem('idusuario')!;
+      await lastValueFrom(
+        this.processManagementService.assignStateToApplication({
+          USUARIO: idUser,
+          NUMERO_LINEA: 1,
+          ID_APPLICATION: app.ID_APPLICATION,
+          STATE: 'Validado'
+        })
+      );
+      this.resourcesService.openSnackBar('Aplicación validada correctamente.');
+      app.ESTADO_SOLICITUD = 'Validado';
+    } catch (error: any) {
+      this.resourcesService.openSnackBar(
+        error?.error?.msg || 'Error al validar la aplicación.'
+      );
+    }
   }
 
-  rejectApplication(app: ValidateApplication) {
-    console.log('Rechazar aplicación:', app);
-    // TODO: Implementar lógica de rechazo
+  async rejectApplication(app: ValidateApplication) {
+    try {
+      const idUser = localStorage.getItem('idusuario')!;
+      await lastValueFrom(
+        this.processManagementService.assignStateToApplication({
+          USUARIO: idUser,
+          NUMERO_LINEA: 1,
+          ID_APPLICATION: app.ID_APPLICATION,
+          STATE: 'Rechazado'
+        })
+      );
+      this.resourcesService.openSnackBar('Aplicación rechazada correctamente.');
+      app.ESTADO_SOLICITUD = 'Rechazado';
+    } catch (error: any) {
+      this.resourcesService.openSnackBar(
+        error?.error?.msg || 'Error al rechazar la aplicación.'
+      );
+    }
   }
 }

+ 1 - 0
src/app/interfaces/process-managementv/workflow-management.interface.ts

@@ -351,6 +351,7 @@ export interface AssignStateToApplicationRequest {
 }
 
 export interface ValidateApplication {
+  ID_APPLICATION: number;
   FECHA_SOLICITUD: string;
   ESTADO_SOLICITUD: string;
   NOMBRE_TAREA: string;