import { observer } from "mobx-react-lite"; import isToday from "date-fns/isToday"; // hooks import { useIssueDetail, useMember, useProject } from "hooks/store"; // ui import { Avatar, AvatarGroup, ControlLink, PriorityIcon } from "@plane/ui"; // helpers import { findTotalDaysInRange, getDate, renderFormattedDate } from "helpers/date-time.helper"; // types import { TIssue, TWidgetIssue } from "@plane/types"; export type IssueListItemProps = { issueId: string; onClick: (issue: TIssue) => void; workspaceSlug: string; }; export const AssignedUpcomingIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { getProjectById } = useProject(); const { issue: { getIssueById }, } = useIssueDetail(); // derived values const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined; if (!issueDetails) return null; const projectDetails = getProjectById(issueDetails.project_id); const blockedByIssues = issueDetails.issue_relation?.filter((issue) => issue.relation_type === "blocked_by") ?? []; const blockedByIssueProjectDetails = blockedByIssues.length === 1 ? getProjectById(blockedByIssues[0]?.project_id ?? "") : null; const targetDate = getDate(issueDetails.target_date); return ( onClick(issueDetails)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issueDetails.sequence_id}
{issueDetails.name}
{targetDate ? (isToday(targetDate) ? "Today" : renderFormattedDate(targetDate)) : "-"}
{blockedByIssues.length > 0 ? blockedByIssues.length > 1 ? `${blockedByIssues.length} blockers` : `${blockedByIssueProjectDetails?.identifier} ${blockedByIssues[0]?.sequence_id}` : "-"}
); }); export const AssignedOverdueIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { getProjectById } = useProject(); const { issue: { getIssueById }, } = useIssueDetail(); // derived values const issueDetails = getIssueById(issueId) as TWidgetIssue | undefined; if (!issueDetails) return null; const projectDetails = getProjectById(issueDetails.project_id); const blockedByIssues = issueDetails.issue_relation?.filter((issue) => issue.relation_type === "blocked_by") ?? []; const blockedByIssueProjectDetails = blockedByIssues.length === 1 ? getProjectById(blockedByIssues[0]?.project_id ?? "") : null; const dueBy = findTotalDaysInRange(getDate(issueDetails.target_date), new Date(), false) ?? 0; return ( onClick(issueDetails)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issueDetails.sequence_id}
{issueDetails.name}
{dueBy} {`day${dueBy > 1 ? "s" : ""}`}
{blockedByIssues.length > 0 ? blockedByIssues.length > 1 ? `${blockedByIssues.length} blockers` : `${blockedByIssueProjectDetails?.identifier} ${blockedByIssues[0]?.sequence_id}` : "-"}
); }); export const AssignedCompletedIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { issue: { getIssueById }, } = useIssueDetail(); const { getProjectById } = useProject(); // derived values const issueDetails = getIssueById(issueId); if (!issueDetails) return null; const projectDetails = getProjectById(issueDetails.project_id); return ( onClick(issueDetails)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issueDetails.sequence_id}
{issueDetails.name}
); }); export const CreatedUpcomingIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { getUserDetails } = useMember(); const { issue: { getIssueById }, } = useIssueDetail(); const { getProjectById } = useProject(); // derived values const issue = getIssueById(issueId); if (!issue) return null; const projectDetails = getProjectById(issue.project_id); return ( onClick(issue)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issue.sequence_id}
{issue.name}
{issue.target_date ? isToday(new Date(issue.target_date)) ? "Today" : renderFormattedDate(issue.target_date) : "-"}
{issue.assignee_ids && issue.assignee_ids?.length > 0 ? ( {issue.assignee_ids?.map((assigneeId) => { const userDetails = getUserDetails(assigneeId); if (!userDetails) return null; return ; })} ) : ( "-" )}
); }); export const CreatedOverdueIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { getUserDetails } = useMember(); const { issue: { getIssueById }, } = useIssueDetail(); const { getProjectById } = useProject(); // derived values const issue = getIssueById(issueId); if (!issue) return null; const projectDetails = getProjectById(issue.project_id); const dueBy = findTotalDaysInRange(getDate(issue.target_date), new Date(), false) ?? 0; return ( onClick(issue)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issue.sequence_id}
{issue.name}
{dueBy} {`day${dueBy > 1 ? "s" : ""}`}
{issue.assignee_ids.length > 0 ? ( {issue.assignee_ids?.map((assigneeId) => { const userDetails = getUserDetails(assigneeId); if (!userDetails) return null; return ; })} ) : ( "-" )}
); }); export const CreatedCompletedIssueListItem: React.FC = observer((props) => { const { issueId, onClick, workspaceSlug } = props; // store hooks const { getUserDetails } = useMember(); const { issue: { getIssueById }, } = useIssueDetail(); const { getProjectById } = useProject(); // derived values const issue = getIssueById(issueId); if (!issue) return null; const projectDetails = getProjectById(issue.project_id); return ( onClick(issue)} className="py-2 px-3 hover:bg-custom-background-80 rounded grid grid-cols-6 gap-1" >
{projectDetails?.identifier} {issue.sequence_id}
{issue.name}
{issue.assignee_ids.length > 0 ? ( {issue.assignee_ids?.map((assigneeId) => { const userDetails = getUserDetails(assigneeId); if (!userDetails) return null; return ; })} ) : ( "-" )}
); });