'use client'

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

export function ProjectManagementSection() {
  return (
    <>
      <h2>Project Management</h2>
      <p>Erstellen und verwalten Sie IACE-Projekte fuer einzelne Maschinen oder Produkte.</p>

      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects" description="Neues IACE-Projekt erstellen" />

      <h3>Request Body</h3>
      <ParameterTable
        parameters={[
          { name: 'machine_name', type: 'string', required: true, description: 'Name der Maschine / des Produkts' },
          { name: 'machine_type', type: 'string', required: true, description: 'Maschinentyp (z.B. "CNC-Fraesmaschine", "Industrieroboter")' },
          { name: 'manufacturer', type: 'string', required: false, description: 'Hersteller-Name' },
          { name: 'description', type: 'string', required: false, description: 'Beschreibung des Produkts und seiner Einsatzzwecke' },
        ]}
      />

      <CodeBlock language="bash" filename="cURL">
{`curl -X POST "https://api.breakpilot.io/sdk/v1/iace/projects" \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "machine_name": "RoboArm X500",
    "machine_type": "Industrieroboter",
    "manufacturer": "TechCorp GmbH",
    "description": "6-Achsen-Industrieroboter fuer Montagearbeiten"
  }'`}
      </CodeBlock>

      <h3>Response (201 Created)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": {
    "id": "proj_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "machine_name": "RoboArm X500",
    "machine_type": "Industrieroboter",
    "manufacturer": "TechCorp GmbH",
    "description": "6-Achsen-Industrieroboter fuer Montagearbeiten",
    "status": "draft",
    "completeness_score": 0,
    "created_at": "2026-03-16T10:00:00Z"
  }
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects" description="Alle Projekte des Tenants auflisten" />

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

      <h3>Response (200 OK)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": [
    {
      "id": "proj_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "machine_name": "RoboArm X500",
      "machine_type": "Industrieroboter",
      "status": "in_progress",
      "completeness_score": 72,
      "hazard_count": 14,
      "created_at": "2026-03-16T10:00:00Z"
    }
  ]
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects/:id" description="Projektdetails inkl. Komponenten und Klassifizierungen laden" />

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

      <ApiEndpoint method="PUT" path="/sdk/v1/iace/projects/:id" description="Projektfelder aktualisieren" />
      <ApiEndpoint method="DELETE" path="/sdk/v1/iace/projects/:id" description="Projekt archivieren (Soft Delete)" />
    </>
  )
}
