'use client'

import { ApiEndpoint, CodeBlock } from '@/components/DevPortalLayout'

export function MonitoringLibrariesSection() {
  return (
    <>
      <h2>Monitoring</h2>
      <p>Post-Market-Surveillance: Monitoring-Ereignisse erfassen und verfolgen.</p>

      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects/:id/monitoring" description="Monitoring-Ereignis erstellen" />

      <CodeBlock language="bash" filename="cURL">
{`curl -X POST "https://api.breakpilot.io/sdk/v1/iace/projects/proj_a1b2c3d4/monitoring" \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "event_type": "incident",
    "title": "Schutzgitter-Sensor Fehlausloesung",
    "description": "Sicherheitssensor hat ohne erkennbaren Grund ausgeloest",
    "severity": "medium",
    "occurred_at": "2026-03-15T14:30:00Z"
  }'`}
      </CodeBlock>

      <h3>Response (201 Created)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": {
    "id": "mon_evt001",
    "event_type": "incident",
    "title": "Schutzgitter-Sensor Fehlausloesung",
    "severity": "medium",
    "status": "open",
    "occurred_at": "2026-03-15T14:30:00Z",
    "created_at": "2026-03-16T08:00:00Z"
  }
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects/:id/monitoring" description="Monitoring-Ereignisse auflisten" />
      <ApiEndpoint method="PUT" path="/sdk/v1/iace/projects/:id/monitoring/:eid" description="Monitoring-Ereignis aktualisieren" />

      <h2>Libraries (projektunabhaengig)</h2>
      <p>
        Stammdaten-Bibliotheken fuer die Gefahrenanalyse. Diese Endpoints sind
        projektunabhaengig und liefern die Referenzdaten fuer die gesamte IACE-Engine.
      </p>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/hazard-library" description="Gefahrenbibliothek (102 Eintraege)" />

      <CodeBlock language="bash" filename="cURL">
{`curl -X GET "https://api.breakpilot.io/sdk/v1/iace/hazard-library" \\
  -H "Authorization: Bearer YOUR_API_KEY"`}
      </CodeBlock>

      <h3>Response (200 OK)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": [
    {
      "id": "HP001",
      "title": "Crushing hazard from closing mechanisms",
      "category": "mechanical",
      "iso_reference": "ISO 12100 Anhang A.1",
      "typical_components": ["actuator", "press", "clamp"],
      "severity_range": "medium-critical"
    },
    {
      "id": "HP045",
      "title": "Electric shock from exposed conductors",
      "category": "electrical",
      "iso_reference": "ISO 12100 Anhang A.2",
      "typical_components": ["power_supply", "motor", "controller"],
      "severity_range": "high-critical"
    }
  ],
  "meta": {
    "total": 102,
    "categories": { "mechanical": 28, "electrical": 15, "thermal": 10, "noise": 8, "vibration": 7, "radiation": 9, "materials": 12, "ergonomic": 13 }
  }
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/controls-library" description="Controls-Bibliothek" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/component-library" description="Komponentenbibliothek (C001-C120)" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/energy-sources" description="Energiequellen (EN01-EN20)" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/lifecycle-phases" description="ISO 12100 Lebenszyklusphasen" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/roles" description="Betroffene Personenrollen" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/evidence-types" description="Evidenz-Typen" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/protective-measures-library" description="Schutzmassnahmen-Bibliothek" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/hazard-patterns" description="Hazard-Pattern-Katalog" />
      <ApiEndpoint method="GET" path="/sdk/v1/iace/tags" description="Tag-Taxonomie" />
    </>
  )
}
