import { userPreferencesService } from '@/services/core/user-preferences';
import { IntegrationsSettingsPageClient } from '@/components/settings/IntegrationsSettingsPageClient';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';

// Force dynamic rendering for real-time data
export const dynamic = 'force-dynamic';

export default async function IntegrationsSettingsPage() {
  const session = await getServerSession(authOptions);
  if (!session?.user?.id) {
    return <div>Non authentifié</div>;
  }

  // Fetch data server-side
  // Preferences are now available via context
  const [jiraConfig, tfsConfig] = await Promise.all([
    userPreferencesService.getJiraConfig(session.user.id),
    userPreferencesService.getTfsConfig(session.user.id),
  ]);

  return (
    <IntegrationsSettingsPageClient
      initialJiraConfig={jiraConfig}
      initialTfsConfig={tfsConfig}
    />
  );
}
