import { Pipe, PipeTransform } from '@angular/core';
import { ExpedienteTask } from '../models/dailyworktask.model';
import { ExpedienteFullTask } from '../models/Expediente';

@Pipe({
  name: 'expedienteTask'
})
export class ExpedienteTaskPipe implements PipeTransform {

  transform(fullTask: ExpedienteFullTask): ExpedienteTask {
    let date = new Date(fullTask.taskStartDate);
    date.setMonth(date.getMonth() + 1);
    let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();

    return {
      "SerialNumber": fullTask.serialNumber,
      "taskStartDate": fullTask.taskStartDate,
      "Subject": fullTask.workflowInstanceDataFields.Subject,
      "Senders": fullTask.workflowInstanceDataFields.Sender,
      "CreateDate": taskDate,
      "DocumentsQty": fullTask.totalDocuments,
      "WorkflowName": fullTask.workflowDisplayName,
      "activityInstanceName": fullTask.activityInstanceName,
      "Status": fullTask.workflowInstanceDataFields.Status,
    }
  }

}
