import { ChangelogManager } from '@/components/owner/owner-forms';
import { getLocale, t } from '@/lib/i18n';
import { prisma } from '@/lib/prisma';

export default async function OwnerChangelogPage() {
  const [locale, entries] = await Promise.all([
    getLocale(),
    prisma.changelogEntry.findMany({ orderBy: { publishedAt: 'desc' } })
  ]);

  return (
    <div className="space-y-6">
      <div>
        <h1 className="text-2xl font-semibold">{t(locale, 'owner.changelog.title')}</h1>
        <p className="text-sm text-muted-foreground">{t(locale, 'owner.changelog.subtitle')}</p>
      </div>
      <ChangelogManager
        initialEntries={entries.map((entry) => ({
          id: entry.id,
          version: entry.version,
          title: entry.title,
          body: entry.body,
          publishedAt: entry.publishedAt.toISOString()
        }))}
      />
    </div>
  );
}
