"use client";

import { useEffect, useState } from "react";
import { fetchAPI } from "@/lib/api";
import type { SectorData } from "@/lib/api";
import SectorHeatmap from "@/components/sector-heatmap";

export default function SectorsPage() {
  const [sectors, setSectors] = useState<SectorData[]>([]);

  useEffect(() => {
    fetchAPI<SectorData[]>("/api/sectors/hot?limit=20").then(setSectors);
  }, []);

  return (
    <div className="max-w-5xl mx-auto px-4 md:px-8 pt-6 pb-20 md:pb-10">
      <div className="mb-5 animate-fade-in-up">
        <h1 className="text-lg font-bold tracking-tight">板块分析</h1>
        <p className="text-xs text-text-muted mt-0.5">基于资金流向和涨跌表现的热度排名</p>
      </div>
      <SectorHeatmap sectors={sectors} />
    </div>
  );
}
