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