import type { ComponentType } from 'react'; import { Table } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { DownOutlined, RightOutlined } from '@ant-design/icons'; import EndpointRow from './EndpointRow'; import type { Endpoint } from './EndpointRow'; import { safeInlineHtml } from './endpoints.js'; import './EndpointSection.css'; interface SubHeader { name: string; desc?: string; } export interface Section { id: string; title: string; description?: string; endpoints: Endpoint[]; subHeader?: SubHeader[]; } interface EndpointSectionProps { section: Section; icon?: ComponentType<{ className?: string }> | null; collapsed?: boolean; onToggle?: () => void; } const subHeaderColumns: ColumnsType = [ { title: 'Header', dataIndex: 'name', key: 'name', width: 240 }, { title: 'Description', dataIndex: 'desc', key: 'desc', render: (value: string) => ( ), }, ]; export default function EndpointSection({ section, icon: Icon = null, collapsed = false, onToggle, }: EndpointSectionProps) { const endpointLabel = section.endpoints.length === 1 ? '1 endpoint' : `${section.endpoints.length} endpoints`; return (
{collapsed ? : } {Icon && }

{section.title}

{endpointLabel}
{section.description && !collapsed && (

)} {section.subHeader && !collapsed && (

Response headers
)}
{section.endpoints.map((endpoint, idx) => ( ))}
); }