import React, { useState } from "react"; // next import { useRouter } from "next/router"; // components import { SpreadsheetColumns, SpreadsheetIssues } from "components/core"; import { CustomMenu, Icon, Spinner } from "components/ui"; // hooks import useIssuesProperties from "hooks/use-issue-properties"; import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; // types import { ICurrentUserResponse, IIssue, Properties, UserAuth } from "types"; // constants import { SPREADSHEET_COLUMN } from "constants/spreadsheet"; // icon import { PlusIcon } from "@heroicons/react/24/outline"; type Props = { type: "issue" | "cycle" | "module"; handleEditIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void; openIssuesListModal?: (() => void) | null; isCompleted?: boolean; user: ICurrentUserResponse | undefined; userAuth: UserAuth; }; export const SpreadsheetView: React.FC = ({ type, handleEditIssue, handleDeleteIssue, openIssuesListModal, isCompleted = false, user, userAuth, }) => { const [expandedIssues, setExpandedIssues] = useState([]); const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { spreadsheetIssues } = useSpreadsheetIssuesView(); const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string); const columnData = SPREADSHEET_COLUMN.map((column) => ({ ...column, isActive: properties ? column.propertyName === "labels" ? properties[column.propertyName as keyof Properties] : column.propertyName === "title" ? true : properties[column.propertyName as keyof Properties] : false, })); const gridTemplateColumns = columnData .filter((column) => column.isActive) .map((column) => column.colSize) .join(" "); return (
{spreadsheetIssues ? (
{spreadsheetIssues.map((issue: IIssue, index) => ( ))}
{type === "issue" ? ( ) : ( !isCompleted && ( Add Issue } position="left" menuItemsClassName="left-5 !w-36" noBorder > { const e = new KeyboardEvent("keydown", { key: "c" }); document.dispatchEvent(e); }} > Create new {openIssuesListModal && ( Add an existing issue )} ) )}
) : ( )}
); };