import React from "react"; import Link from "next/link"; import { useRouter } from "next/router"; // icons import { TrashIcon, PencilIcon } from "@heroicons/react/24/outline"; import { PhotoFilterOutlined } from "@mui/icons-material"; //components import { CustomMenu } from "components/ui"; import { IWorkspaceView } from "types/workspace-views"; // helpers import { truncateText } from "helpers/string.helper"; type Props = { view: IWorkspaceView; handleEditView: () => void; handleDeleteView: () => void; }; export const SingleWorkspaceViewItem: React.FC = ({ view, handleEditView, handleDeleteView, }) => { const router = useRouter(); const { workspaceSlug } = router.query; const viewRedirectionUrl = `/${workspaceSlug}/workspace-views/issues?globalViewId=${view.id}`; return (

{truncateText(view.name, 75)}

{view?.description && (

{view.description}

)}

{view.query_data.filters && Object.keys(view.query_data.filters).length > 0 ? `${Object.keys(view.query_data.filters) .map((key: string) => view.query_data.filters[key as keyof typeof view.query_data.filters] !== null ? isNaN( ( view.query_data.filters[ key as keyof typeof view.query_data.filters ] as any ).length ) ? 0 : ( view.query_data.filters[ key as keyof typeof view.query_data.filters ] as any ).length : 0 ) .reduce((curr, prev) => curr + prev, 0)} filters` : "0 filters"}

{ e.preventDefault(); e.stopPropagation(); handleEditView(); }} > Edit View { e.preventDefault(); e.stopPropagation(); handleDeleteView(); }} > Delete View
); };