import { useState } from "react"; import { Draggable } from "@hello-pangea/dnd"; import { observer } from "mobx-react-lite"; // components import { CalendarQuickAddIssueForm, CalendarIssueBlockRoot } from "components/issues"; // helpers import { renderFormattedPayloadDate } from "helpers/date-time.helper"; // types import { TIssue, TIssueMap } from "@plane/types"; import useSize from "hooks/use-window-size"; type Props = { date: Date; issues: TIssueMap | undefined; issueIdList: string[] | null; quickActions: (issue: TIssue, customActionButton?: React.ReactElement) => React.ReactNode; isDragDisabled?: boolean; enableQuickIssueCreate?: boolean; disableIssueCreation?: boolean; quickAddCallback?: ( workspaceSlug: string, projectId: string, data: TIssue, viewId?: string ) => Promise; addIssuesToView?: (issueIds: string[]) => Promise; viewId?: string; readOnly?: boolean; }; export const CalendarIssueBlocks: React.FC = observer((props) => { const { date, issues, issueIdList, quickActions, isDragDisabled = false, enableQuickIssueCreate, disableIssueCreation, quickAddCallback, addIssuesToView, viewId, readOnly, } = props; // states const [showAllIssues, setShowAllIssues] = useState(false); // hooks const [windowWidth] = useSize(); const formattedDatePayload = renderFormattedPayloadDate(date); const totalIssues = issueIdList?.length ?? 0; if (!formattedDatePayload) return null; return ( <> {issueIdList?.slice(0, showAllIssues || windowWidth <= 768 ? issueIdList.length : 4).map((issueId, index) => windowWidth > 768 ? ( {(provided, snapshot) => (
)}
) : ( ) )} {enableQuickIssueCreate && !disableIssueCreation && !readOnly && (
setShowAllIssues(true)} />
)} {totalIssues > 4 && (
)} ); });