import Link from "next/link"; // hooks import { useIssueDetail } from "hooks/store"; // components import { AssignedCompletedIssueListItem, AssignedIssuesEmptyState, AssignedOverdueIssueListItem, AssignedUpcomingIssueListItem, CreatedCompletedIssueListItem, CreatedIssuesEmptyState, CreatedOverdueIssueListItem, CreatedUpcomingIssueListItem, IssueListItemProps, } from "components/dashboard/widgets"; // ui import { getButtonStyling } from "@plane/ui"; // helpers import { cn } from "helpers/common.helper"; import { getRedirectionFilters } from "helpers/dashboard.helper"; // types import { TIssue, TIssuesListTypes } from "@plane/types"; export type WidgetIssuesListProps = { isLoading: boolean; issues: TIssue[]; tab: TIssuesListTypes; totalIssues: number; type: "assigned" | "created"; workspaceSlug: string; }; export const WidgetIssuesList: React.FC = (props) => { const { isLoading, issues, tab, totalIssues, type, workspaceSlug } = props; // store hooks const { setPeekIssue } = useIssueDetail(); const handleIssuePeekOverview = (issue: TIssue) => setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); const filterParams = getRedirectionFilters(tab); const ISSUE_LIST_ITEM: { [key: string]: { [key in TIssuesListTypes]: React.FC; }; } = { assigned: { pending: AssignedUpcomingIssueListItem, upcoming: AssignedUpcomingIssueListItem, overdue: AssignedOverdueIssueListItem, completed: AssignedCompletedIssueListItem, }, created: { pending: CreatedUpcomingIssueListItem, upcoming: CreatedUpcomingIssueListItem, overdue: CreatedOverdueIssueListItem, completed: CreatedCompletedIssueListItem, }, }; return ( <>
{isLoading ? ( <> ) : issues.length > 0 ? ( <>
Issues {totalIssues}
{["upcoming", "pending"].includes(tab) &&
Due date
} {tab === "overdue" &&
Due by
} {type === "assigned" && tab !== "completed" &&
Blocked by
} {type === "created" &&
Assigned to
}
{issues.map((issue) => { const IssueListItem = ISSUE_LIST_ITEM[type][tab]; if (!IssueListItem) return null; return ( ); })}
) : (
{type === "assigned" && } {type === "created" && }
)}
{issues.length > 0 && ( View all issues )} ); };