"use client"

import { TrendingUp } from "lucide-react"
import { PolarAngleAxis, PolarGrid, Radar, RadarChart } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

export const description = "Showing average growth for the last 6 months PREJEE"

const chartData = [
  { month: "January", desktop: 186, mobile: 80, },
  { month: "February", desktop: 305, mobile: 200, },
  { month: "March", desktop: 237, mobile: 120, },
  { month: "April", desktop: 73, mobile: 190, },
  { month: "May", desktop: 209, mobile: 130, },
  { month: "June", desktop: 214, mobile: 140, },
]

const chartConfig = {
  desktop: {
    label: "Maths",
    color: "var(--chart-2)",
  },
  mobile: {
    label: "Physics",
    color: "var(--chart-1)",
  },
} satisfies ChartConfig

export function RadarCard() {
  return (
    <Card className="border w-[400px] h-[400px] mx-auto shadow-lg">
      <CardHeader className="items-center pb-4">
        <CardTitle className="text-center">Study Report</CardTitle>
        <CardDescription className="text-center">
          Showing average growth for the last 6 months
        </CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={chartConfig}
          className="mx-auto aspect-square max-h-[200px]"
        >
          <RadarChart
            data={chartData}
            margin={{
              top: -40,
              bottom: -10,
            }}
          >
            <ChartTooltip
              cursor={false}
              content={<ChartTooltipContent indicator="line" />}
            />
            <PolarAngleAxis dataKey="month" />
            <PolarGrid />
            <Radar
              dataKey="desktop"
              fill="var(--color-desktop)"
              fillOpacity={0.6}
              stroke="var(--color-desktop)"
              strokeWidth={2}
            />
            <Radar dataKey="mobile" fill="var(--color-mobile)" fillOpacity={0.6}/>
            <ChartLegend className="mt-8" content={<ChartLegendContent />} />
          </RadarChart>
        </ChartContainer>
      </CardContent>
      <CardFooter className="flex-col gap-2 pt-4 text-sm">
        <div className="flex items-center gap-2 font-medium leading-none">
          Trending up by 5.2% this month <TrendingUp className="h-4 w-4" />
        </div>
      </CardFooter>
    </Card>
  )
}
