"use client"; import { useState, useEffect } from "react"; import { Plus } from "lucide-react"; import { Button } from "@/components/ui/button"; import { fetchPositions } from "@/lib/supabase/recruitment-actions"; import type { PositionWithRelations, PositionStatus } from "@/lib/supabase/recruitment-types"; import { POSITION_STATUS_LABELS } from "@/lib/supabase/recruitment-types"; import PageSkeleton from "./PageSkeleton"; const STATUS_BADGE_COLORS: Record = { draft: "bg-gray-100 text-gray-600 border-gray-200", open: "bg-teal-50 text-teal-700 border-teal-200", closed: "bg-red-50 text-red-700 border-red-200", }; export default function RecruitmentPage({ onNavigate }: { onNavigate?: (view: "list" | "new" | "detail", id?: string) => void }) { const [positions, setPositions] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { let cancelled = false; fetchPositions() .then((data) => { if (!cancelled) setPositions(data); }) .catch(() => {}) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, []); if (loading) return ; return (
{/* Header */}

Open Positions

Track internal hiring requisitions and applicant pipelines

{/* Table */}
{positions.length === 0 ? (

No open positions yet

Add a position to start tracking applicants

) : (
{positions.map((pos) => ( onNavigate?.("detail", pos.id)} className="hover:bg-gray-50/50 transition-colors duration-150 cursor-pointer" > ))}
Title Department Type Applicants Status

{pos.title}

{new Date(pos.created_at).toLocaleDateString()}

{pos.department?.name || "—"} {pos.employment_type.replace("_", " ")} {pos.applicant_count} {POSITION_STATUS_LABELS[pos.status]}
)}
); }