"use client"; import { useState } from "react"; import Badge from "@/components/ui/Badge"; export default function ProjectStatusDropdownDebug({ project, size = "md", showDropdown = true, }) { const [status, setStatus] = useState(project.project_status); const [loading, setLoading] = useState(false); const [isOpen, setIsOpen] = useState(false); const statusConfig = { registered: { label: "Registered", variant: "secondary", }, in_progress_design: { label: "In Progress (Design)", variant: "primary", }, in_progress_construction: { label: "In Progress (Construction)", variant: "primary", }, fulfilled: { label: "Completed", variant: "success", }, cancelled: { label: "Cancelled", variant: "danger", }, }; const handleChange = async (newStatus) => { if (newStatus === status) { setIsOpen(false); return; } setStatus(newStatus); setLoading(true); setIsOpen(false); try { await fetch(`/api/projects/${project.project_id}`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...project, project_status: newStatus }), }); window.location.reload(); } catch (error) { console.error("Failed to update status:", error); setStatus(project.project_status); } finally { setLoading(false); } }; const currentConfig = statusConfig[status] || { label: "Unknown", variant: "default", }; if (!showDropdown) { return ( {currentConfig.label} ); } return (
{/* Simple visible dropdown for debugging */} {isOpen && (
DEBUG: Project Status Dropdown is visible
{Object.entries(statusConfig).map(([statusKey, config]) => ( ))}
)} {/* Backdrop */} {isOpen && (
{ console.log("Project Status Backdrop clicked"); setIsOpen(false); }} /> )}
); }