import { cn } from '@/lib/utils' import { colors } from '@/lib/theme' import type { APIEndpoint } from '@/lib/docs/types' import CodeBlock from './CodeBlock' import { LuLock } from 'react-icons/lu' interface APIEndpointDocProps { endpoint: APIEndpoint className?: string } const methodStyles = { GET: { backgroundColor: 'rgba(16, 185, 129, 0.1)', color: colors.accents.success, borderColor: 'rgba(16, 185, 129, 0.3)', }, POST: { backgroundColor: 'rgba(59, 130, 246, 0.1)', color: colors.accents.info, borderColor: 'rgba(59, 130, 246, 0.3)', }, PUT: { backgroundColor: colors.accents.warningBg, color: colors.accents.warning, borderColor: 'rgba(245, 158, 11, 0.3)', }, DELETE: { backgroundColor: 'rgba(239, 68, 68, 0.1)', color: colors.accents.error, borderColor: 'rgba(239, 68, 68, 0.3)', }, PATCH: { backgroundColor: 'rgba(168, 85, 247, 0.1)', color: '#a855f7', borderColor: 'rgba(168, 85, 247, 0.3)', }, } as const export default function APIEndpointDoc({ endpoint, className, }: APIEndpointDocProps) { return (
{/* Header */}
{endpoint.method} {endpoint.path}

{endpoint.description}

{endpoint.auth?.required && (
Authentication required {endpoint.auth.type && `: ${endpoint.auth.type}`}
)}
{/* Query Parameters */} {endpoint.parameters?.query && endpoint.parameters.query.length > 0 && (

Query Parameters

{endpoint.parameters.query.map((param, index) => ( ))}
Name Type Description
{param.name} {!param.optional && ( * )} {param.type} {param.description}
)} {/* Request Body */} {endpoint.parameters?.body && endpoint.parameters.body.length > 0 && (

Request Body

{endpoint.parameters.body.map((param, index) => ( ))}
Field Type Description
{param.name} {!param.optional && ( * )} {param.type} {param.description}
)} {/* Responses */}

Responses

{endpoint.responses.map((response, index) => { const isSuccess = response.status >= 200 && response.status < 300 const isError = response.status >= 400 const statusStyle = isSuccess ? { backgroundColor: 'rgba(16, 185, 129, 0.1)', color: colors.accents.success } : isError ? { backgroundColor: 'rgba(239, 68, 68, 0.1)', color: colors.accents.error } : { backgroundColor: 'rgba(59, 130, 246, 0.1)', color: colors.accents.info } return (
{response.status} {response.description}
{response.example && ( )}
) })}
{/* Examples */} {endpoint.examples && endpoint.examples.length > 0 && (

Request Examples

{endpoint.examples.map((example, index) => (
{example.title && (
{example.title}
)}
))}
)}
) }