2023-09-01 11:12:30 +00:00
|
|
|
import { useEffect } from "react";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-09-04 11:57:29 +00:00
|
|
|
import Image from "next/image";
|
2023-09-01 11:12:30 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
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";
|
2023-09-01 11:12:30 +00:00
|
|
|
// mobx store
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useMobxStore } from "@/lib/mobx/store-provider";
|
|
|
|
import { RootStore } from "@/store/root";
|
2023-09-04 11:57:29 +00:00
|
|
|
// assets
|
|
|
|
import SomethingWentWrongImage from "public/something-went-wrong.svg";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
export const ProjectDetailsView = observer(() => {
|
|
|
|
const router = useRouter();
|
2023-12-01 07:55:48 +00:00
|
|
|
const { workspace_slug, project_slug, states, labels, priorities, peekId } = router.query;
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
issue: issueStore,
|
|
|
|
project: projectStore,
|
|
|
|
issueDetails: issueDetailStore,
|
|
|
|
user: userStore,
|
|
|
|
}: RootStore = useMobxStore();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!userStore.currentUser) {
|
|
|
|
userStore.fetchCurrentUser();
|
|
|
|
}
|
|
|
|
}, [userStore]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (workspace_slug && project_slug) {
|
|
|
|
const params = {
|
|
|
|
state: states || null,
|
|
|
|
labels: labels || null,
|
|
|
|
priority: priorities || null,
|
|
|
|
};
|
|
|
|
issueStore.fetchPublicIssues(workspace_slug?.toString(), project_slug.toString(), params);
|
|
|
|
}
|
|
|
|
}, [workspace_slug, project_slug, issueStore, states, labels, priorities]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (peekId && workspace_slug && project_slug) {
|
|
|
|
issueDetailStore.setPeekId(peekId.toString());
|
|
|
|
}
|
|
|
|
}, [peekId, issueDetailStore, project_slug, workspace_slug]);
|
|
|
|
|
|
|
|
return (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="relative h-full w-full overflow-hidden">
|
2023-09-01 11:12:30 +00:00
|
|
|
{workspace_slug && <IssuePeekOverview />}
|
|
|
|
|
|
|
|
{issueStore?.loader && !issueStore.issues ? (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="py-10 text-center text-sm text-custom-text-100">Loading...</div>
|
2023-09-01 11:12:30 +00:00
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
{issueStore?.error ? (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="grid h-full w-full place-items-center p-6">
|
2023-09-04 11:57:29 +00:00
|
|
|
<div className="text-center">
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="mx-auto grid h-52 w-52 place-items-center rounded-full bg-custom-background-80">
|
|
|
|
<div className="grid h-32 w-32 place-items-center">
|
2023-09-04 11:57:29 +00:00
|
|
|
<Image src={SomethingWentWrongImage} alt="Oops! Something went wrong" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-12-01 07:55:48 +00:00
|
|
|
<h1 className="mt-12 text-3xl font-semibold">Oops! Something went wrong.</h1>
|
2023-09-04 11:57:29 +00:00
|
|
|
<p className="mt-4 text-custom-text-300">The public board does not exist. Please check the URL.</p>
|
|
|
|
</div>
|
2023-09-01 11:12:30 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
projectStore?.activeBoard && (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative flex h-full w-full flex-col overflow-hidden">
|
2023-12-05 11:56:57 +00:00
|
|
|
{/* applied filters */}
|
|
|
|
<IssueAppliedFilters />
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
{projectStore?.activeBoard === "list" && (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="relative h-full w-full overflow-y-auto">
|
2023-09-01 11:12:30 +00:00
|
|
|
<IssueListView />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{projectStore?.activeBoard === "kanban" && (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="relative mx-auto h-full w-full p-5">
|
2023-09-01 11:12:30 +00:00
|
|
|
<IssueKanbanView />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{projectStore?.activeBoard === "calendar" && <IssueCalendarView />}
|
|
|
|
{projectStore?.activeBoard === "spreadsheet" && <IssueSpreadsheetView />}
|
|
|
|
{projectStore?.activeBoard === "gantt" && <IssueGanttView />}
|
2023-12-05 11:56:57 +00:00
|
|
|
</div>
|
2023-09-01 11:12:30 +00:00
|
|
|
)
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|