import { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { useLocation } from "react-router-dom"; import { Rocket, LayoutDashboard, Upload, ArrowLeftRight, Tags, SlidersHorizontal, PiggyBank, BarChart3, Wallet, Settings, Lightbulb, ListChecks, Footprints, Printer, Users, } from "lucide-react"; const SECTIONS = [ { key: "gettingStarted", icon: Rocket }, { key: "profiles", icon: Users }, { key: "dashboard", icon: LayoutDashboard }, { key: "import", icon: Upload }, { key: "transactions", icon: ArrowLeftRight }, { key: "categories", icon: Tags }, { key: "adjustments", icon: SlidersHorizontal }, { key: "budget", icon: PiggyBank }, { key: "reports", icon: BarChart3 }, { key: "balance", icon: Wallet }, { key: "settings", icon: Settings }, ] as const; export default function DocsContent() { const { t } = useTranslation(); const location = useLocation(); const sectionRefs = useRef>({}); const [activeSection, setActiveSection] = useState(SECTIONS[0].key); useEffect(() => { const observer = new IntersectionObserver( (entries) => { for (const entry of entries) { if (entry.isIntersecting) { setActiveSection(entry.target.id); } } }, { rootMargin: "-30% 0px -60% 0px", threshold: 0 }, ); for (const { key } of SECTIONS) { const el = sectionRefs.current[key]; if (el) observer.observe(el); } return () => observer.disconnect(); }, []); useEffect(() => { const hash = location.hash.replace("#", ""); if (hash && sectionRefs.current[hash]) { requestAnimationFrame(() => { sectionRefs.current[hash]?.scrollIntoView({ behavior: "smooth", block: "start", }); }); } }, [location.hash]); const scrollToSection = (key: string) => { sectionRefs.current[key]?.scrollIntoView({ behavior: "smooth", block: "start", }); }; return (

{t("docs.title")}

{SECTIONS.map(({ key, icon: Icon }) => (
{ sectionRefs.current[key] = el; }} className="bg-[var(--card)] border border-[var(--border)] rounded-xl p-6 space-y-4 scroll-mt-4" >

{t(`docs.${key}.title`)}

{t(`docs.${key}.overview`)}

{t("docs.features")}

    {( t(`docs.${key}.features`, { returnObjects: true }) as string[] ).map((item, i) => (
  • {item}
  • ))}

{key === "gettingStarted" ? t("docs.quickStart") : t("docs.howTo")}

    {( t(`docs.${key}.steps`, { returnObjects: true }) as string[] ).map((item, i) => (
  1. {item}
  2. ))}

{t("docs.tipsHeader")}

    {( t(`docs.${key}.tips`, { returnObjects: true }) as string[] ).map((item, i) => (
  • {item}
  • ))}
))}
); }