// pages/rh/relatorio_fgts.tsx
import { useState } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

export default function RelatorioFGTS() {
  const [competencia, setCompetencia] = useState("");
  const [dados, setDados] = useState<any[]>([]);

  const handleBuscar = () => {
    // Simulação - substitua por integração com folha
    setDados([
      { nome: "João da Silva", salario: 3000, fgts: 240 },
      { nome: "Maria Oliveira", salario: 2500, fgts: 200 },
    ]);
  };

  return (
    <div className="p-6">
      <h1 className="text-xl font-bold mb-4">Relatório de FGTS</h1>
      <Card className="mb-4">
        <CardContent className="flex gap-4 pt-4">
          <Input
            type="month"
            value={competencia}
            onChange={(e) => setCompetencia(e.target.value)}
          />
          <Button onClick={handleBuscar}>Buscar</Button>
        </CardContent>
      </Card>

      <Card>
        <CardContent className="pt-4">
          <Table>
            <TableHeader>
              <TableRow>
                <TableHead>Funcionário</TableHead>
                <TableHead>Salário</TableHead>
                <TableHead>FGTS (8%)</TableHead>
              </TableRow>
            </TableHeader>
            <TableBody>
              {dados.map((item, i) => (
                <TableRow key={i}>
                  <TableCell>{item.nome}</TableCell>
                  <TableCell>R$ {item.salario.toFixed(2)}</TableCell>
                  <TableCell>R$ {item.fgts.toFixed(2)}</TableCell>
                </TableRow>
              ))}
            </TableBody>
          </Table>
        </CardContent>
      </Card>
    </div>
  );
}
