'use client';

import { useState } from "react";
import FilterTahunAngkatan from "@/components/FilterTahunAngkatan";
import FilterStatusKuliah from "@/components/FilterStatusKuliah";
import StatusMahasiswaFilterChart from "@/components/StatusMahasiswaFilterChart";
import StatusMahasiswaFilterPieChart from "@/components/StatusMahasiswaFilterPieChart";
import JenisPendaftaranStatusChart from "@/components/JenisPendaftaranStatusChart";
import JenisPendaftaranStatusPieChart from "@/components/JenisPendaftaranStatusPieChart";
import AsalDaerahStatusChart from '@/components/AsalDaerahStatusChart';
import IpkStatusChart from '@/components/IpkStatusChart';
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";

export default function StatusMahasiswaPage() {
    const [selectedYear, setSelectedYear] = useState<string>("all");
    const [selectedStatus, setSelectedStatus] = useState<string>("Aktif");
  
    return (
      <div className="container mx-auto p-4 space-y-6">
        <h1 className="text-3xl font-bold mb-4">Status Mahasiswa</h1>
        
        <div className="mb-4">
          <p className="text-gray-600 dark:text-gray-300">
            Mahasiswa status adalah status kuliah mahasiswa program studi Informatika Fakultas Teknik Universitas Tanjungpura.
          </p>
        </div>
  
        <Card className="bg-white dark:bg-slate-900 shadow-lg dark:text-white">
          <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
            <CardTitle className="text-sm font-medium dark:text-white">
              Filter Data
            </CardTitle>
          </CardHeader>
          <CardContent>
            <div className="flex flex-col sm:flex-row items-start sm:items-center gap-4 sm:space-x-4">
              <FilterTahunAngkatan 
                selectedYear={selectedYear}
                onYearChange={setSelectedYear}
              />
              <FilterStatusKuliah
                selectedStatus={selectedStatus}
                onStatusChange={setSelectedStatus}
              />
            </div>
          </CardContent>
        </Card>

        {selectedYear === "all" ? (
        <>
          <StatusMahasiswaFilterChart 
            selectedYear={selectedYear}
            selectedStatus={selectedStatus}
          />
          <JenisPendaftaranStatusChart
            selectedYear={selectedYear}
            selectedStatus={selectedStatus}
          />
        </>
        ) : (
          <>
            <StatusMahasiswaFilterPieChart
              selectedYear={selectedYear}
              selectedStatus={selectedStatus}
            />
            <JenisPendaftaranStatusPieChart
              selectedYear={selectedYear}
              selectedStatus={selectedStatus}
            />
          </>
        )}

        <AsalDaerahStatusChart
          selectedYear={selectedYear}
          selectedStatus={selectedStatus}
        />

        {selectedYear === "all" && (
          <IpkStatusChart
            selectedYear={selectedYear}
            selectedStatus={selectedStatus}
          />
        )}

      </div>
    );
  }