{
  "name": "4. Notificaci\u00f3n OJT Completado",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ojt-completed",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook OJT Completed",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://backend:8000/api/ojt/progress/={{ $json.person_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "name": "Obtener Progreso OJT",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        450,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.progress_percentage }}",
              "operation": "equal",
              "value2": 100
            }
          ]
        }
      },
      "name": "OJT 100% Completo?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "noreply@ontrackia.com",
        "toEmail": "={{ $json.supervisor_email }}",
        "subject": "\ud83c\udf93 OJT Completado - Validaci\u00f3n Requerida",
        "emailType": "html",
        "message": "<h2>\ud83c\udf93 Formaci\u00f3n OJT Completada</h2>\n<p><strong>Empleado:</strong> {{ $json.person_name }}</p>\n<p><strong>Progreso:</strong> {{ $json.validated_tasks }}/{{ $json.total_tasks }} tareas validadas</p>\n<p><strong>Estado:</strong> \u2705 100% Completo</p>\n<hr>\n<p>El empleado ha completado todas las tareas de formaci\u00f3n OJT.</p>\n<p><strong>ACCI\u00d3N REQUERIDA:</strong> Revisar y validar las tareas pendientes.</p>\n<a href=\"https://ontrackia.com/ojt/{{ $json.person_id }}\">Ver Progreso OJT</a>"
      },
      "name": "Email a Supervisor",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {
        "fromEmail": "noreply@ontrackia.com",
        "toEmail": "={{ $json.person_email }}",
        "subject": "\ud83c\udf89 \u00a1Felicitaciones! OJT Completado",
        "emailType": "html",
        "message": "<h2>\ud83c\udf89 \u00a1Felicitaciones!</h2>\n<p>Has completado todas las tareas de formaci\u00f3n OJT.</p>\n<p><strong>Progreso:</strong> {{ $json.validated_tasks }}/{{ $json.total_tasks }} tareas</p>\n<hr>\n<p>Tu supervisor revisar\u00e1 las tareas y proceder\u00e1 con la validaci\u00f3n final.</p>\n<p>Una vez validado, podr\u00e1s recibir tu autorizaci\u00f3n.</p>"
      },
      "name": "Email a Empleado",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        850,
        400
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"success\": true, \"message\": \"Notifications sent\" } }}"
      },
      "name": "Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1050,
        300
      ]
    }
  ],
  "connections": {
    "Webhook OJT Completed": {
      "main": [
        [
          {
            "node": "Obtener Progreso OJT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtener Progreso OJT": {
      "main": [
        [
          {
            "node": "OJT 100% Completo?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OJT 100% Completo?": {
      "main": [
        [
          {
            "node": "Email a Supervisor",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email a Empleado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email a Supervisor": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email a Empleado": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "id": "4"
}