Files
IdP/apps/docs/components/oauth-code-tabs.tsx
2026-06-25 14:40:05 +03:00

31 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import { useEffect, useMemo, useState } from 'react';
import { buildOAuthExamples } from '@/lib/oauth-examples';
import { fetchPublicSettingsClient } from '@/lib/api';
import { resolveOAuthApiBase } from '@/lib/oauth-url';
import { CodeExampleTabs } from '@/components/code-example-tabs';
export function OAuthCodeTabs() {
const [apiBase, setApiBase] = useState('http://localhost:3000');
useEffect(() => {
void fetchPublicSettingsClient()
.then((settings) => setApiBase(resolveOAuthApiBase(settings)))
.catch(() => undefined);
}, []);
const examples = useMemo(() => buildOAuthExamples(apiBase), [apiBase]);
return (
<div className="space-y-3">
<p className="text-sm text-zinc-500 dark:text-zinc-400">
Базовый URL API (issuer): <code className="rounded bg-zinc-100 px-1.5 py-0.5 dark:bg-zinc-800">{apiBase}</code>
{' — '}
берётся из настройки <strong>PUBLIC_API_URL</strong> или <strong>Домен IdP</strong> в админ-панели.
</p>
<CodeExampleTabs examples={examples} />
</div>
);
}