'use client'; import { useEffect, useState } from 'react'; import { Copy, ExternalLink, KeyRound, Loader2, RefreshCw, Trash2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { OAuthClient } from '@/lib/api'; import { OAuthEndpoints, buildAuthorizeUrl } from '@/lib/oauth-url'; import { OAuthClientOneTapSection } from '@/components/id/oauth-client-one-tap-section'; function CopyRow({ label, value, onCopy }: { label: string; value: string; onCopy: (value: string, label: string) => void }) { return (
{label}
{value}
); } export function OAuthClientDetailDialog({ client, endpoints, frontendBase, projectName, open, onOpenChange, onCopy, onRotateSecret, onToggleActive, onDelete, onSaveRedirectUris }: { client: OAuthClient | null; endpoints: OAuthEndpoints; frontendBase: string; projectName: string; open: boolean; onOpenChange: (open: boolean) => void; onCopy: (value: string, label: string) => void; onRotateSecret: (clientId: string) => void; onToggleActive: (client: OAuthClient) => void; onDelete: (client: OAuthClient) => void; onSaveRedirectUris: (client: OAuthClient, redirectUris: string[]) => Promise; }) { const [redirectUrisDraft, setRedirectUrisDraft] = useState(''); const [savingRedirectUris, setSavingRedirectUris] = useState(false); useEffect(() => { if (!client) return; setRedirectUrisDraft(client.redirectUris.join('\n')); }, [client]); if (!client) return null; const primaryRedirect = client.redirectUris[0] ?? 'https://app.example.com/oauth/callback'; const scope = client.scopes.join(' '); const sampleAuthorizeUrl = buildAuthorizeUrl(endpoints.issuer, { clientId: client.clientId, redirectUri: primaryRedirect, scope }); return ( {client.name}
{client.type === 'PUBLIC' ? 'Public' : 'Confidential'} {client.isActive ? 'Активно' : 'Отключено'} {client.createdByDisplayName ? ( Создал: {client.createdByDisplayName} ) : null}

Данные клиента

{client.type !== 'PUBLIC' ? (

Client Secret выдаётся один раз при создании или после «Новый secret». Храните только на backend.

) : null}
Redirect URI {client.canManage ? null : ( )}
{client.canManage ? ( <>