import { observer } from "mobx-react-lite"; import { TIssue, TIssueMap, TPaginationData } from "@plane/types"; // components import { CalendarQuickAddIssueForm, CalendarIssueBlockRoot } from "@/components/issues"; // helpers import { renderFormattedPayloadDate } from "@/helpers/date-time.helper"; import { useIssuesStore } from "@/hooks/use-issue-layout-store"; import { TRenderQuickActions } from "../list/list-view-types"; // types type Props = { date: Date; issues: TIssueMap | undefined; loadMoreIssues: (dateString: string) => void; getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; getGroupIssueCount: (groupId: string | undefined) => number | undefined; issueIdList: string[]; quickActions: TRenderQuickActions; isDragDisabled?: boolean; enableQuickIssueCreate?: boolean; disableIssueCreation?: boolean; quickAddCallback?: (projectId: string | null | undefined, data: TIssue) => Promise; addIssuesToView?: (issueIds: string[]) => Promise; readOnly?: boolean; isMobileView?: boolean; }; export const CalendarIssueBlocks: React.FC = observer((props) => { const { date, issues, issueIdList, quickActions, loadMoreIssues, isDragDisabled = false, enableQuickIssueCreate, disableIssueCreation, quickAddCallback, addIssuesToView, readOnly, isMobileView = false, } = props; const formattedDatePayload = renderFormattedPayloadDate(date); const { issues: { getGroupIssueCount, getPaginationData, getIssueLoader }, } = useIssuesStore(); if (!formattedDatePayload) return null; const dayIssueCount = getGroupIssueCount(formattedDatePayload, undefined, false); const nextPageResults = getPaginationData(formattedDatePayload, undefined)?.nextPageResults; const isPaginating = !!getIssueLoader(formattedDatePayload); const shouldLoadMore = nextPageResults === undefined && dayIssueCount !== undefined ? issueIdList?.length < dayIssueCount : !!nextPageResults; return ( <> {issueIdList?.map((issueId) => (
))} {isPaginating && (
)} {enableQuickIssueCreate && !disableIssueCreation && !readOnly && (
)} {shouldLoadMore && !isPaginating && (
)} ); });