global update and global fix
This commit is contained in:
31
apps/docs/components/bot-code-tabs.tsx
Normal file
31
apps/docs/components/bot-code-tabs.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { buildBotExamples } from '@/lib/bot-examples';
|
||||
import { fetchPublicSettingsClient } from '@/lib/api';
|
||||
import { resolveOAuthApiBase } from '@/lib/oauth-url';
|
||||
import { CodeExampleTabs } from '@/components/code-example-tabs';
|
||||
|
||||
export function BotCodeTabs() {
|
||||
const [apiBase, setApiBase] = useState('http://localhost:3000');
|
||||
|
||||
useEffect(() => {
|
||||
void fetchPublicSettingsClient()
|
||||
.then((settings) => setApiBase(resolveOAuthApiBase(settings)))
|
||||
.catch(() => undefined);
|
||||
}, []);
|
||||
|
||||
const examples = useMemo(() => buildBotExamples(apiBase), [apiBase]);
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<p className="text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Базовый URL Bot API:{' '}
|
||||
<code className="rounded bg-zinc-100 px-1.5 py-0.5 dark:bg-zinc-800">{apiBase}/bot{'{token}'}/{'{method}'}</code>
|
||||
{' — '}
|
||||
подставляется из <strong>PUBLIC_API_URL</strong> (как для OAuth).
|
||||
</p>
|
||||
<CodeExampleTabs examples={examples} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user