import { Injectable } from '@angular/core';
import { CustomTaskPipe } from '../pipes/custom-task.pipe';
import { ProcessesService } from '../services/processes.service';

@Injectable({
  providedIn: 'root'
})
export class DeplomaService {

  activityInstanceName = {
    'Revisar Diploma': [
      'Solicitar assinatura do Presidente',
      'Solicitar alteração',
      'Marcar Reunião'
    ],
    'Diploma Assinado': [
      'Concluir'
    ],
    'Assinar Diploma': [
      'Assinado'
    ]
  }

  customTaskPipe = new CustomTaskPipe()

  constructor(
    private processes: ProcessesService,
  ) { }


  async askSignature({note, documents, serialNumber, activityInstanceName}) {
    let body = {
      "serialNumber": serialNumber,
      "action": "Aprovar",
      "ActionTypeId": 99999840,
      "dataFields": {
        "ReviewUserComment": note,
      },
      "AttachmentList" :documents,
    }

    return  this.processes.CompleteTask(body)
  }

  async askToChange({note, documents, serialNumber, activityInstanceName}) {
    let body = {
      "serialNumber": serialNumber,
      "action": "Retificar",
      "ActionTypeId": 99999841,
      "dataFields": {
        "ReviewUserComment": note,
      },
      "AttachmentList" :documents,
    }

    return this.processes.CompleteTask(body)

  }

  async finish({note, documents, serialNumber, activityInstanceName}) {

    let body = {
      "serialNumber": serialNumber,
      "action": "Concluir",
      "ActionTypeId": 95,
      "dataFields": {
        "ReviewUserComment": note,
      },
      "AttachmentList" :documents,
    }
    
    return this.processes.CompleteTask(body);
  }

  async sign({note, documents, serialNumber, activityInstanceName}) {
    let body = {
      "serialNumber": serialNumber,
      "action": "Assinado",
      "ActionTypeId": 99999842,
      "dataFields": {
        "ReviewUserComment": note,
      },
      "AttachmentList" :documents,
    }

    return this.processes.CompleteTask(body)
  }


  async getList() {

  }

}
