import { tagsService } from '@/services/task-management/tags';
import { GeneralSettingsPageClient } from '@/components/settings/GeneralSettingsPageClient';
import { getServerSession } from 'next-auth/next';
import { authOptions } from '@/lib/auth';

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

export default async function GeneralSettingsPage() {
  const session = await getServerSession(authOptions);

  if (!session?.user?.id) {
    return (
      <div className="min-h-screen bg-[var(--background)] flex items-center justify-center">
        <div className="text-center">
          <h1 className="text-2xl font-bold text-[var(--foreground)] mb-2">
            Accès non autorisé
          </h1>
          <p className="text-[var(--muted-foreground)]">
            Vous devez être connecté pour accéder aux paramètres.
          </p>
        </div>
      </div>
    );
  }

  // Fetch data server-side
  const tags = await tagsService.getTags(session.user.id);

  return <GeneralSettingsPageClient initialTags={tags} />;
}
