"use client"; import { FC, useEffect } from "react"; import { observer } from "mobx-react-lite"; import Image from "next/image"; import { useParams } from "next/navigation"; import useSWR from "swr"; // components import { IssueCalendarView } from "@/components/issues/board-views/calendar"; import { IssueGanttView } from "@/components/issues/board-views/gantt"; import { IssueKanbanView } from "@/components/issues/board-views/kanban"; import { IssueListView } from "@/components/issues/board-views/list"; import { IssueSpreadsheetView } from "@/components/issues/board-views/spreadsheet"; import { IssueAppliedFilters } from "@/components/issues/filters/applied-filters/root"; import { IssuePeekOverview } from "@/components/issues/peek-overview"; // mobx store import { useIssue, useUser, useProject, useIssueDetails } from "@/hooks/store"; // assets import SomethingWentWrongImage from "public/something-went-wrong.svg"; type ProjectDetailsViewProps = { workspaceSlug: string; projectId: string; peekId: string; }; export const ProjectDetailsView: FC = observer((props) => { const { workspaceSlug, projectId, peekId } = props; // router const params = useParams(); // store hooks const { fetchPublicIssues } = useIssue(); const { activeLayout } = useProject(); // fetching public issues useSWR( workspaceSlug && projectId ? "PROJECT_PUBLIC_ISSUES" : null, workspaceSlug && projectId ? () => fetchPublicIssues(workspaceSlug, projectId, params) : null ); // store hooks const issueStore = useIssue(); const issueDetailStore = useIssueDetails(); const { data: currentUser, fetchCurrentUser } = useUser(); useEffect(() => { if (!currentUser) { fetchCurrentUser(); } }, [currentUser, fetchCurrentUser]); useEffect(() => { if (peekId && workspaceSlug && projectId) { issueDetailStore.setPeekId(peekId.toString()); } }, [peekId, issueDetailStore, projectId, workspaceSlug]); return (
{workspaceSlug && } {issueStore?.loader && !issueStore.issues ? (
Loading...
) : ( <> {issueStore?.error ? (
Oops! Something went wrong

Oops! Something went wrong.

The public board does not exist. Please check the URL.

) : ( activeLayout && (
{/* applied filters */} {activeLayout === "list" && (
)} {activeLayout === "kanban" && (
)} {activeLayout === "calendar" && } {activeLayout === "spreadsheet" && } {activeLayout === "gantt" && }
) )} )}
); });