// headless ui import { Disclosure } from "@headlessui/react"; // import { getStateGroupIcon } from "components/icons"; // hooks import useToast from "hooks/use-toast"; // icons import { Icon } from "components/ui"; import { copyTextToClipboard, addSpaceIfCamelCase } from "helpers/string.helper"; // types import { IIssue } from "types/issue"; // constants import { issueGroupFilter, issuePriorityFilter } from "constants/data"; import { useEffect } from "react"; import { renderDateFormat } from "constants/helpers"; import { IPeekMode } from "store/issue_details"; import { useRouter } from "next/router"; import { RootStore } from "store/root"; import { useMobxStore } from "lib/mobx/store-provider"; type Props = { issueDetails: IIssue; mode?: IPeekMode; }; const validDate = (date: any, state: string): string => { if (date === null || ["backlog", "unstarted", "cancelled"].includes(state)) return `bg-gray-500/10 text-gray-500 border-gray-500/50`; else { const today = new Date(); const dueDate = new Date(date); if (dueDate < today) return `bg-red-500/10 text-red-500 border-red-500/50`; else return `bg-green-500/10 text-green-500 border-green-500/50`; } }; export const PeekOverviewIssueProperties: React.FC = ({ issueDetails, mode }) => { const { setToastAlert } = useToast(); const { issueDetails: issueDetailStore }: RootStore = useMobxStore(); const router = useRouter(); const { workspaceSlug } = router.query; const startDate = issueDetails.start_date; const targetDate = issueDetails.target_date; const minDate = startDate ? new Date(startDate) : null; minDate?.setDate(minDate.getDate()); const maxDate = targetDate ? new Date(targetDate) : null; maxDate?.setDate(maxDate.getDate()); const state = issueDetails.state_detail; const stateGroup = issueGroupFilter(state.group); const priority = issueDetails.priority ? issuePriorityFilter(issueDetails.priority) : null; const handleCopyLink = () => { const originURL = typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; copyTextToClipboard( `${originURL}/${workspaceSlug}/projects/${issueDetails.project}/issues/${issueDetails.id}` ).then(() => { setToastAlert({ type: "success", title: "Link copied!", message: "Issue link copied to clipboard", }); }); }; return (
{mode === "full" && (
{/* {getStateGroupIcon(issue.state_detail.group, "16", "16", issue.state_detail.color)} */} {issueDetails.project_detail.identifier}-{issueDetails.sequence_id}
)}
State
{stateGroup && (
{addSpaceIfCamelCase(state?.name ?? "")}
)}
Priority
{priority && ( )} {priority?.title ?? "None"}
Due date
{issueDetails.target_date ? (
{renderDateFormat(issueDetails.target_date)}
) : ( Empty )}
); };