import { useRouter } from "next/router"; import useSWR from "swr"; // hook import useMyIssuesFilters from "hooks/my-issues/use-my-issues-filter"; import useUser from "hooks/use-user"; // services import workspaceService from "services/workspace.service"; // layouts import { WorkspaceAuthorizationLayout } from "layouts/auth-layout"; // contexts import { IssueViewContextProvider } from "contexts/issue-view.context"; // components import { SpreadsheetView } from "components/core"; import { WorkspaceViewsNavigation } from "components/workspace/views/workpace-view-navigation"; import { WorkspaceIssuesViewOptions } from "components/issues/workspace-views/workspace-issue-view-option"; // ui import { EmptyState, PrimaryButton } from "components/ui"; // icons import { PlusIcon } from "@heroicons/react/24/outline"; // images import emptyView from "public/empty-state/view.svg"; // fetch-keys import { WORKSPACE_VIEW_DETAILS, WORKSPACE_VIEW_ISSUES } from "constants/fetch-keys"; import { CheckCircle } from "lucide-react"; const WorkspaceView: React.FC = () => { const router = useRouter(); const { workspaceSlug, workspaceViewId } = router.query; const { user } = useUser(); const { data: viewDetails, error } = useSWR( workspaceSlug && workspaceViewId ? WORKSPACE_VIEW_DETAILS(workspaceViewId.toString()) : null, workspaceSlug && workspaceViewId ? () => workspaceService.getViewDetails(workspaceSlug.toString(), workspaceViewId.toString()) : null ); const { displayFilters } = useMyIssuesFilters(workspaceSlug?.toString()); const params: any = { assignees: viewDetails?.query_data?.assignees ? viewDetails?.query_data?.assignees.join(",") : undefined, state: viewDetails?.query_data?.state ? viewDetails?.query_data?.state.join(",") : undefined, priority: viewDetails?.query_data?.priority ? viewDetails.query_data?.priority.join(",") : undefined, labels: viewDetails?.query_data?.labels ? viewDetails?.query_data?.labels.join(",") : undefined, created_by: viewDetails?.query_data?.created_by ? viewDetails?.query_data?.created_by.join(",") : undefined, start_date: viewDetails?.query_data?.start_date ? viewDetails?.query_data?.start_date.join(",") : undefined, target_date: viewDetails?.query_data?.target_date ? viewDetails?.query_data?.target_date.join(",") : undefined, sub_issue: displayFilters?.sub_issue, type: displayFilters?.type ? displayFilters?.type : undefined, }; const { data: viewIssues, mutate: mutateIssues } = useSWR( workspaceSlug && viewDetails ? WORKSPACE_VIEW_ISSUES(workspaceSlug.toString(), params) : null, workspaceSlug && viewDetails ? () => workspaceService.getViewIssues(workspaceSlug.toString(), params) : null ); return ( {viewDetails ? `${viewDetails.name} Issues` : "Workspace Issues"} } right={
{ const e = new KeyboardEvent("keydown", { key: "c" }); document.dispatchEvent(e); }} > Add Issue
} >
{error ? ( router.push(`/${workspaceSlug}/workspace-views`), }} /> ) : (
{}} disableUserActions={false} user={user} userAuth={{ isGuest: false, isMember: false, isOwner: false, isViewer: false, }} />
)}
); }; export default WorkspaceView;