import React, { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/router"; // components import { DeleteModuleModal } from "components/modules"; // ui import { AssigneesList, Avatar, CustomMenu } from "components/ui"; // icons import { CalendarDaysIcon, TrashIcon } from "@heroicons/react/24/outline"; // helpers import { renderShortNumericDateFormat } from "helpers/date-time.helper"; // types import { IModule } from "types"; // common import { MODULE_STATUS } from "constants/module"; import useToast from "hooks/use-toast"; import { copyTextToClipboard } from "helpers/string.helper"; type Props = { module: IModule; handleEditModule: () => void; }; export const SingleModuleCard: React.FC = ({ module, handleEditModule }) => { const [moduleDeleteModal, setModuleDeleteModal] = useState(false); const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { setToastAlert } = useToast(); const handleDeleteModule = () => { if (!module) return; setModuleDeleteModal(true); }; const handleCopyText = () => { const originURL = typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; copyTextToClipboard(`${originURL}/${workspaceSlug}/projects/${projectId}/modules/${module.id}`) .then(() => { setToastAlert({ type: "success", title: "Module link copied to clipboard", }); }) .catch(() => { setToastAlert({ type: "error", title: "Some error occurred", }); }); }; return ( <>
Copy module link Edit module Delete module permanently
{module.name}
LEAD
MEMBERS
END DATE
{module.target_date ? renderShortNumericDateFormat(module?.target_date) : "N/A"}
STATUS
s.value === module.status)?.color, }} /> {module.status}
); };