import { ownerRoleAtLeast } from '@nexumi/shared';
import { PresenceForm } from '@/components/owner/presence-form';
import { getLocale, t } from '@/lib/i18n';
import { requireOwnerOrRedirect } from '@/lib/owner-auth';
import { getPresenceConfig } from '@/lib/owner-presence';

export default async function OwnerPresencePage() {
  const session = await requireOwnerOrRedirect('VIEWER');
  const [locale, config] = await Promise.all([getLocale(), getPresenceConfig()]);
  const canEdit = ownerRoleAtLeast(session.ownerRole, 'ADMIN');

  return (
    <div className="space-y-6">
      <div>
        <h1 className="text-2xl font-semibold">{t(locale, 'owner.presence.title')}</h1>
        <p className="text-sm text-muted-foreground">{t(locale, 'owner.presence.subtitle')}</p>
      </div>
      <PresenceForm initialValue={config} canEdit={canEdit} />
    </div>
  );
}
