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 { Loader, getButtonStyling } from "@plane/ui"; // helpers import { cn } from "helpers/common.helper"; import { getRedirectionFilters } from "helpers/dashboard.helper"; // types import { TDurationFilterOptions, TIssue, TIssuesListTypes } from "@plane/types"; export type WidgetIssuesListProps = { filter: TDurationFilterOptions | undefined; isLoading: boolean; issues: TIssue[]; tab: TIssuesListTypes; totalIssues: number; type: "assigned" | "created"; workspaceSlug: string; }; export const WidgetIssuesList: React.FC = (props) => { const { filter, 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 in string]: { [key in TIssuesListTypes]: React.FC; }; } = { assigned: { upcoming: AssignedUpcomingIssueListItem, overdue: AssignedOverdueIssueListItem, completed: AssignedCompletedIssueListItem, }, created: { upcoming: CreatedUpcomingIssueListItem, overdue: CreatedOverdueIssueListItem, completed: CreatedCompletedIssueListItem, }, }; return ( <>
{isLoading ? ( ) : issues.length > 0 ? ( <>
Issues {totalIssues}
{tab === "upcoming" &&
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" && }
)}
{totalIssues > issues.length && ( View all issues )} ); };