"use client"; import React, { useState, useEffect } from "react"; import { db } from "@/lib/firebase"; import { collection, onSnapshot, addDoc, deleteDoc, doc } from "firebase/firestore"; import Link from "next/link"; interface Employee { id: string; name: string; position: string; salary: number; } export default function HRPage() { const [employees, setEmployees] = useState([]); const [isModalOpen, setIsModalOpen] = useState(false); const [newEmp, setNewEmp] = useState({ name: "", position: "", salary: 0 }); useEffect(() => { const unsub = onSnapshot(collection(db, "employees"), (snap) => { const data = snap.docs.map(doc => ({ id: doc.id, ...doc.data() } as Employee)); setEmployees(data); }); return () => unsub(); }, []); const handleAdd = async (e: React.FormEvent) => { e.preventDefault(); await addDoc(collection(db, "employees"), newEmp); setIsModalOpen(false); setNewEmp({ name: "", position: "", salary: 0 }); }; return (
← Panel Principal

Gestión Humana

{employees.map((e) => (
{e.name.charAt(0)}

{e.name}

{e.position}
Salario ${Number(e.salary).toLocaleString()}
))}
{isModalOpen && (

NEW STAFF /

setNewEmp({...newEmp, name: v.target.value})} className="w-full bg-white/5 border-b border-white/20 px-4 py-4 outline-none focus:border-cyan-500 transition-all font-medium text-lg"/>
setNewEmp({...newEmp, position: v.target.value})} className="w-full bg-white/5 border-b border-white/20 px-4 py-4 outline-none focus:border-cyan-500 transition-all font-medium text-lg"/>
setNewEmp({...newEmp, salary: Number(v.target.value)})} className="w-full bg-white/5 border-b border-white/20 px-4 py-4 outline-none focus:border-cyan-500 transition-all font-medium text-lg"/>
)}
); }