diff --git a/resources/js/pages/api/docs.tsx b/resources/js/pages/api/docs.tsx index 7155f26e..6740c2b4 100644 --- a/resources/js/pages/api/docs.tsx +++ b/resources/js/pages/api/docs.tsx @@ -15,7 +15,7 @@ interface Endpoint { abilities: string[]; } -type Doc = 'guide' | 'zapier'; +type Tab = 'guide' | 'zapier' | 'endpoints'; interface Props { guide_html: string; @@ -35,7 +35,7 @@ const METHOD_TONE: Record = { export default function ApiDocs({ guide_html, zapier_html, endpoints, spec_url, version }: Props) { const { t } = useTranslation(); - const [doc, setDoc] = useState('guide'); + const [tab, setTab] = useState('guide'); const breadcrumbs: BreadcrumbItem[] = [{ title: t('API'), href: '/api/docs' }]; @@ -59,8 +59,32 @@ export default function ApiDocs({ guide_html, zapier_html, endpoints, spec_url, -
-

{t('Endpoints')}

+ {/* + * Three views of the same API, one at a time. The endpoint + * table is generated from the committed OpenAPI document; + * the other two are markdown files that ship with the + * application, converted server-side with HTML input + * escaped — see ApiDocsController. + * + * The guide and the Zapier page are separate because they + * are for different readers: one is writing code against + * the API, the other is filling in a form in Zapier and + * will read nothing else. + */} +
+ {(['guide', 'zapier', 'endpoints'] as const).map((key) => ( + + ))} +
+ + {tab === 'endpoints' && (
@@ -87,35 +111,11 @@ export default function ApiDocs({ guide_html, zapier_html, endpoints, spec_url,
-
+ )} - {/* - * Both are rendered server-side from files that ship with - * the application — see ApiDocsController, which converts - * them with HTML input escaped. - * - * Two documents rather than one long page because they are - * for two different readers: the guide for someone writing - * code against the API, the Zapier page for someone wiring - * up a Zap who will read nothing else. - */} -
- {(['guide', 'zapier'] as const).map((key) => ( - - ))} -
- -
+ {tab !== 'endpoints' && ( +
+ )} );