import { useState } from 'react'; import { ClipboardCheck, Trash2, UsersRound } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import type { Project } from '../../../../types/project.types'; import { useArchiveProject, useCompleteProject } from '../../../../hooks/useProjects'; import { customToast } from '../../../utils/showToast'; import ArchiveProjectDialog from './ArchiveProjectDialog'; import CompleteProjectDialog from './CompleteProjectDialog'; import { getProjectIcon } from '../../../../lib/ProjectIcons'; interface MentorProjectCardProps extends Project { onArchived?: () => void; onCompleted?: () => void; } export default function MentorProjectCard({ onArchived, onCompleted, ...project }: MentorProjectCardProps) { const navigate = useNavigate(); const { archive, loading: archiveLoading } = useArchiveProject(); const { complete, loading: completeLoading } = useCompleteProject(); const [showArchiveDialog, setShowArchiveDialog] = useState(false); const [showCompleteDialog, setShowCompleteDialog] = useState(false); const handleCardClick = () => { navigate(`/mentor/projects/${project.slug}`); }; const Icon = getProjectIcon(project.project_icon); /* ── Archive ─────────────────────────────────────────────── */ const handleArchiveButtonClick = (e: React.MouseEvent) => { e.stopPropagation(); setShowArchiveDialog(true); }; const handleArchiveConfirm = async () => { const result = await archive(project.id); setShowArchiveDialog(false); if (result) { customToast.success("Berhasil!", "Projek berubah status menjadi Archived (Diarsipkan"); onArchived?.(); } else { customToast.error("Gagal!", "Projek gagal diarsipkan (archived)"); } }; /* ── Complete ────────────────────────────────────────────── */ const handleCompleteButtonClick = (e: React.MouseEvent) => { e.stopPropagation(); setShowCompleteDialog(true); }; const handleCompleteConfirm = async () => { const result = await complete(project.id); setShowCompleteDialog(false); if (result) { customToast.success("Berhasil!", "Projek berubah status menjadi completed (selesai)"); onCompleted?.(); } else { customToast.error("Gagal!", "Projek gagal diselesaikan (completed)"); } }; return ( <> {/* Archive Confirmation Dialog */} setShowArchiveDialog(false)} /> {/* Complete Confirmation Dialog */} setShowCompleteDialog(false)} /> {/* Card */}
{/* Thumbnail */}
{/* Content */}

{project.project_name}

{/* Interns Count */}
{project.total_members}/{project.total_members}
{/* Status Badge */}
{project.status === "active" ? ( Active ) : project.status === "completed" ? ( Completed ) : project.status === "archived" ? ( Archived ) : ( Inactive )}
{/* Footer Actions */}
{/* Complete Button */} {/* Archive Button */}
); }