'use client'

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

export function ComponentsSection() {
  return (
    <>
      <h2>Components</h2>
      <p>Verwalten Sie die Komponenten einer Maschine oder eines Produkts.</p>

      <ApiEndpoint method="POST" path="/sdk/v1/iace/projects/:id/components" description="Komponente hinzufuegen" />

      <h3>Request Body</h3>
      <ParameterTable
        parameters={[
          { name: 'name', type: 'string', required: true, description: 'Komponentenname' },
          { name: 'component_type', type: 'string', required: true, description: 'Typ (z.B. "actuator", "sensor", "controller", "structural")' },
          { name: 'is_safety_relevant', type: 'boolean', required: false, description: 'Sicherheitsrelevante Komponente (default: false)' },
        ]}
      />

      <CodeBlock language="bash" filename="cURL">
{`curl -X POST "https://api.breakpilot.io/sdk/v1/iace/projects/proj_a1b2c3d4/components" \\
  -H "Authorization: Bearer YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "name": "Servo-Antrieb Achse 1",
    "component_type": "actuator",
    "is_safety_relevant": true
  }'`}
      </CodeBlock>

      <h3>Response (201 Created)</h3>
      <CodeBlock language="json" filename="Response">
{`{
  "success": true,
  "data": {
    "id": "comp_1234abcd",
    "name": "Servo-Antrieb Achse 1",
    "component_type": "actuator",
    "is_safety_relevant": true,
    "created_at": "2026-03-16T10:05:00Z"
  }
}`}
      </CodeBlock>

      <ApiEndpoint method="GET" path="/sdk/v1/iace/projects/:id/components" description="Alle Komponenten des Projekts auflisten" />
      <ApiEndpoint method="PUT" path="/sdk/v1/iace/projects/:id/components/:cid" description="Komponente aktualisieren" />
      <ApiEndpoint method="DELETE" path="/sdk/v1/iace/projects/:id/components/:cid" description="Komponente loeschen" />
    </>
  )
}
