"use client"; import { useState, useEffect, useRef } from "react"; import { ArrowLeft, UserPlus, Download } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Label } from "@/components/ui/label"; import { fetchPosition, fetchApplicants, updateApplicantStage, updateApplicantNotes, createApplicant, uploadResume, } from "@/lib/supabase/recruitment-actions"; import type { PositionWithRelations, Applicant, ApplicantStage, } from "@/lib/supabase/recruitment-types"; import { STAGE_LABELS, getInitials } from "@/lib/supabase/recruitment-types"; import PageSkeleton from "./PageSkeleton"; const ALL_STAGES: ApplicantStage[] = ["applied", "screening", "interview", "offer", "hired", "rejected"]; const AVATAR_COLORS = [ "bg-teal-500", "bg-blue-500", "bg-purple-500", "bg-orange-500", "bg-pink-500", "bg-indigo-500", ]; function ApplicantCard({ applicant, index, onNotesChange, onDragStart, }: { applicant: Applicant; index: number; onNotesChange: (id: string, notes: string) => void; onDragStart: (e: React.DragEvent, applicantId: string) => void; }) { const [notes, setNotes] = useState(applicant.notes || ""); const [notesSaving, setNotesSaving] = useState(false); const notesTimeoutRef = useRef | null>(null); const handleNotesChange = (value: string) => { setNotes(value); if (notesTimeoutRef.current) clearTimeout(notesTimeoutRef.current); setNotesSaving(true); notesTimeoutRef.current = setTimeout(() => { onNotesChange(applicant.id, value); setNotesSaving(false); }, 800); }; return (
onDragStart(e, applicant.id)} className="bg-white rounded-lg border border-gray-200 p-3 mb-2 shadow-sm cursor-grab active:cursor-grabbing hover:shadow-md transition-shadow" >
{getInitials(applicant.first_name, applicant.last_name)}

{applicant.first_name} {applicant.last_name}

{applicant.email}

{applicant.phone && (

{applicant.phone}

)}

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

{applicant.resume_url && ( Resume )}