"use client"; import { formatDistanceToNow } from "date-fns"; import { Key, MoreVertical, Pencil, Trash2 } from "lucide-react"; import { Badge, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "../../../shadcnui"; import { OAuthClientInterface } from "../interfaces/oauth.interface"; export interface OAuthClientCardProps { /** The OAuth client to display */ client: OAuthClientInterface; /** Called when card is clicked */ onClick?: () => void; /** Called when edit is clicked */ onEdit?: () => void; /** Called when delete is clicked */ onDelete?: () => void; } /** * Card component for displaying an OAuth client in a list */ export function OAuthClientCard({ client, onClick, onEdit, onDelete }: OAuthClientCardProps) { // Truncate client ID for display const truncatedId = client.clientId.length > 12 ? `${client.clientId.slice(0, 8)}...${client.clientId.slice(-4)}` : client.clientId; const createdAgo = client.createdAt ? formatDistanceToNow(new Date(client.createdAt), { addSuffix: true }) : "Unknown"; return (
{client.name}
{client.isActive ? "Active" : "Inactive"} {(onEdit || onDelete) && ( e.stopPropagation()}> {onEdit && ( { e.stopPropagation(); onEdit(); }} > Edit )} {onDelete && ( { e.stopPropagation(); onDelete(); }} className="text-destructive" > Delete )} )}
{client.description && {client.description}}
{truncatedId} Created {createdAgo} {client.isConfidential ? "Confidential" : "Public"}
); }