Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

1.5 KB
Raw Blame
'use client';

import { KeyRound, Trash2 } from 'lucide-react';
import { useTranslations } from 'next-intl';
import { formatShortDate } from '@/utils/dates';
import { Button } from '@/components/ui/button';
import {
  Item,
  ItemActions,
  ItemContent,
  ItemDescription,
  ItemMedia,
  ItemTitle,
} from '@/components/ui/item';
import type { ApiKeyRow } from '../services/apiKeys.service';

export default function ApiKeysItem({
  apiKey,
  onDelete,
}: {
  apiKey: ApiKeyRow;
  onDelete: () => void;
}) {
  const t = useTranslations('apiKeys');

  return (
    <Item
      size="sm"
      className="rounded-none border-0 border-b border-border px-1 last:border-b-0 hover:bg-accent/50"
    >
      <ItemMedia>
        <KeyRound className="size-4" />
      </ItemMedia>
      <ItemContent>
        <ItemTitle>{apiKey.name ?? t('fallbackName')}</ItemTitle>
        <ItemDescription>
          {apiKey.start ? `${apiKey.start}… · ` : ''}
          {t('createdAt', { date: formatShortDate(apiKey.createdAt) })}
          {' · '}
          {apiKey.expiresAt
            ? t('expiresAt', { date: formatShortDate(apiKey.expiresAt) })
            : t('noExpiry')}
        </ItemDescription>
      </ItemContent>
      <ItemActions>
        <Button
          variant="ghost"
          size="icon"
          className="size-7 text-muted-foreground hover:text-destructive"
          title={t('deleteAction')}
          onClick={onDelete}
        >
          <Trash2 className="size-4" />
        </Button>
      </ItemActions>
    </Item>
  );
}