'use client'
import { useState } from 'react'
import {
ChevronDown,
ChevronUp,
Key,
Pencil,
Trash2,
} from 'lucide-react'
import type { SSOConfig } from '../_types'
import { AVAILABLE_ROLES } from './constants'
import { formatDate } from './helpers'
import { CopyButton, StatusBadge } from './shared'
import { ConnectionTestPanel } from './ConnectionTestPanel'
export function SSOConfigCard({
config,
onEdit,
onDelete,
onToggle,
}: {
config: SSOConfig
onEdit: () => void
onDelete: () => void
onToggle: () => void
}) {
const [expanded, setExpanded] = useState(false)
return (
{/* Main Row */}
{config.name}
{config.provider_type}
{config.oidc_issuer_url}
Client ID: {(config.oidc_client_id || '').substring(0, 12)}...
Scopes: {(config.oidc_scopes || []).join(', ')}
Erstellt: {formatDate(config.created_at)}
{/* Actions */}
{/* Expanded Details */}
{expanded && (
{/* Config Details Grid */}
Redirect URI:
{config.oidc_redirect_uri}
Auto-Provisioning:
{config.auto_provision ? 'Aktiviert' : 'Deaktiviert'}
Standard-Rolle:
{config.default_role_id || 'Standard'}
Scopes:
{(config.oidc_scopes || []).map(scope => (
{scope}
))}
{/* Role Mappings */}
{config.role_mapping && Object.keys(config.role_mapping).length > 0 && (
Rollen-Mapping
{Object.entries(config.role_mapping).map(([group, role]) => (
{group}
→
{AVAILABLE_ROLES.find(r => r.value === role)?.label || role}
))}
)}
{/* Connection Test */}
)}
)
}