import React, { useCallback } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // react-beautiful-dnd import { DragDropContext, DropResult } from "react-beautiful-dnd"; import StrictModeDroppable from "components/dnd/StrictModeDroppable"; // services import stateService from "services/state.service"; // hooks import useUser from "hooks/use-user"; import { useProjectMyMembership } from "contexts/project-member.context"; // components import { AllLists, AllBoards, CalendarView, SpreadsheetView, GanttChartView, } from "components/core"; // ui import { EmptyState, Spinner } from "components/ui"; // icons import { TrashIcon } from "@heroicons/react/24/outline"; // images import emptyIssue from "public/empty-state/issue.svg"; import emptyIssueArchive from "public/empty-state/issue-archive.svg"; // helpers import { getStatesList } from "helpers/state.helper"; // types import { IIssue, IIssueViewProps } from "types"; // fetch-keys import { STATES_LIST } from "constants/fetch-keys"; type Props = { addIssueToDate: (date: string) => void; addIssueToGroup: (groupTitle: string) => void; disableUserActions: boolean; dragDisabled?: boolean; emptyState: { title: string; description?: string; primaryButton?: { icon: any; text: string; onClick: () => void; }; secondaryButton?: React.ReactNode; }; handleIssueAction: (issue: IIssue, action: "copy" | "delete" | "edit") => void; handleOnDragEnd: (result: DropResult) => Promise; openIssuesListModal: (() => void) | null; removeIssue: ((bridgeId: string, issueId: string) => void) | null; trashBox: boolean; setTrashBox: React.Dispatch>; viewProps: IIssueViewProps; }; export const AllViews: React.FC = ({ addIssueToDate, addIssueToGroup, disableUserActions, dragDisabled = false, emptyState, handleIssueAction, handleOnDragEnd, openIssuesListModal, removeIssue, trashBox, setTrashBox, viewProps, }) => { const router = useRouter(); const { workspaceSlug, projectId, cycleId, moduleId } = router.query; const { user } = useUser(); const { memberRole } = useProjectMyMembership(); const { groupedIssues, isEmpty, issueView } = viewProps; const { data: stateGroups } = useSWR( workspaceSlug && projectId ? STATES_LIST(projectId as string) : null, workspaceSlug ? () => stateService.getStates(workspaceSlug as string, projectId as string) : null ); const states = getStatesList(stateGroups); const handleTrashBox = useCallback( (isDragging: boolean) => { if (isDragging && !trashBox) setTrashBox(true); }, [trashBox, setTrashBox] ); return ( {(provided, snapshot) => (
Drop here to delete the issue.
)}
{groupedIssues ? ( !isEmpty || issueView === "kanban" || issueView === "calendar" || issueView === "gantt_chart" ? ( <> {issueView === "list" ? ( ) : issueView === "kanban" ? ( ) : issueView === "calendar" ? ( ) : issueView === "spreadsheet" ? ( ) : ( issueView === "gantt_chart" && )} ) : router.pathname.includes("archived-issues") ? ( { router.push(`/${workspaceSlug}/projects/${projectId}/settings/automations`); }, }} /> ) : ( ) ) : (
)}
); };