import { useState } from 'react' import Badge from '../UI/Badge' import { formatDate } from '../../utils/dateHelpers' import useFocusStore from '../../store/useFocusStore' import useProjectStore from '../../store/useProjectStore' import { deleteDeliverable } from '../../api/deliverables' import DeliverableModal from '../Deliverables/DeliverableModal' import ContextMenu from '../UI/ContextMenu' function DriveIcon() { return ( ) } export default function ProjectCard({ project, onEdit, onDelete }) { const openFocus = useFocusStore(s => s.openFocus) const { removeDeliverable } = useProjectStore() const [delModal, setDelModal] = useState({ open: false, deliverable: null }) const [ctxMenu, setCtxMenu] = useState(null) const openDelEdit = (d) => setDelModal({ open: true, deliverable: d }) const handleRowCtx = (e, d) => { e.preventDefault() e.stopPropagation() setCtxMenu({ x: e.clientX, y: e.clientY, items: [ { icon: '✎', label: 'Edit Deliverable', action: () => openDelEdit(d) }, { icon: '◎', label: 'Open Focus View', action: () => openFocus(project.id, d.id) }, { separator: true }, { icon: '✕', label: 'Delete Deliverable', danger: true, action: async () => { if (window.confirm(`Delete "${d.title}"?`)) { await deleteDeliverable(d.id) removeDeliverable(d.id) } }, }, ], }) } const handleHeaderCtx = (e) => { e.preventDefault() setCtxMenu({ x: e.clientX, y: e.clientY, items: [ { icon: '✎', label: 'Edit Project', action: () => onEdit(project) }, ...(project.drive_url ? [{ icon: '⬡', label: 'Open Drive', action: () => window.open(project.drive_url, '_blank') }] : []), { separator: true }, { icon: '✕', label: 'Delete Project', danger: true, action: () => onDelete(project) }, ], }) } return (
{project.description}
)} {/* Deliverable rows */}No deliverables
)}