"use client"

import {
  resolveCompteSettingsSection,
  type CompteSettingsSectionId,
} from "@/lib/compte-settings/settings-nav"
import { CompteHomeSection } from "@/components/compte/sections/compte-home-section"
import { ComptePersonalInfoSection } from "@/components/compte/sections/compte-personal-info-section"
import { CompteSecuritySection } from "@/components/compte/sections/compte-security-section"
import { CompteAiUsageSection } from "@/components/compte/sections/compte-ai-usage-section"

const SECTIONS: Record<CompteSettingsSectionId, React.ComponentType> = {
  home: CompteHomeSection,
  "personal-info": ComptePersonalInfoSection,
  security: CompteSecuritySection,
  "usage-ia": CompteAiUsageSection,
}

export function CompteSettingsSectionView({
  sectionId,
}: {
  sectionId: CompteSettingsSectionId
}) {
  const Section = SECTIONS[sectionId]
  return <Section />
}

export function CompteSettingsSectionFromSegments({
  segments,
}: {
  segments?: string[]
}) {
  const sectionId = resolveCompteSettingsSection(segments)
  return <CompteSettingsSectionView sectionId={sectionId} />
}
