2024-02-13 15:28:44 +00:00
|
|
|
import React, { Fragment } from "react";
|
2023-11-03 14:50:05 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-11-03 14:50:05 +00:00
|
|
|
import useSWR from "swr";
|
|
|
|
// mobx store
|
|
|
|
// components
|
2024-01-24 13:20:54 +00:00
|
|
|
import {
|
|
|
|
ArchivedIssueListLayout,
|
|
|
|
ArchivedIssueAppliedFiltersRoot,
|
2024-01-24 13:42:54 +00:00
|
|
|
ProjectArchivedEmptyState,
|
2024-01-24 13:20:54 +00:00
|
|
|
IssuePeekOverview,
|
2024-03-19 14:38:35 +00:00
|
|
|
} from "@/components/issues";
|
|
|
|
import { ListLayoutLoader } from "@/components/ui";
|
|
|
|
import { EIssuesStoreType } from "@/constants/issue";
|
2024-01-10 14:39:45 +00:00
|
|
|
// ui
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useIssues } from "@/hooks/store";
|
2023-11-03 14:50:05 +00:00
|
|
|
|
|
|
|
export const ArchivedIssueLayoutRoot: React.FC = observer(() => {
|
2024-01-10 14:39:45 +00:00
|
|
|
// router
|
2023-11-03 14:50:05 +00:00
|
|
|
const router = useRouter();
|
2024-01-10 14:39:45 +00:00
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
// hooks
|
|
|
|
const { issues, issuesFilter } = useIssues(EIssuesStoreType.ARCHIVED);
|
2023-11-03 14:50:05 +00:00
|
|
|
|
2024-01-10 14:39:45 +00:00
|
|
|
useSWR(
|
|
|
|
workspaceSlug && projectId ? `ARCHIVED_ISSUES_${workspaceSlug.toString()}_${projectId.toString()}` : null,
|
|
|
|
async () => {
|
|
|
|
if (workspaceSlug && projectId) {
|
|
|
|
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
|
|
|
|
await issues?.fetchIssues(
|
|
|
|
workspaceSlug.toString(),
|
|
|
|
projectId.toString(),
|
|
|
|
issues?.groupedIssueIds ? "mutation" : "init-loader"
|
|
|
|
);
|
|
|
|
}
|
2024-02-28 09:48:11 +00:00
|
|
|
},
|
|
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
2024-01-10 14:39:45 +00:00
|
|
|
);
|
2023-11-03 14:50:05 +00:00
|
|
|
|
2024-02-13 13:42:10 +00:00
|
|
|
if (issues?.loader === "init-loader" || !issues?.groupedIssueIds) {
|
|
|
|
return <ListLayoutLoader />;
|
|
|
|
}
|
|
|
|
|
2024-01-10 14:39:45 +00:00
|
|
|
if (!workspaceSlug || !projectId) return <></>;
|
2023-11-03 14:50:05 +00:00
|
|
|
return (
|
2024-03-20 15:32:58 +00:00
|
|
|
<>
|
2023-11-03 14:50:05 +00:00
|
|
|
<ArchivedIssueAppliedFiltersRoot />
|
2024-02-13 15:28:44 +00:00
|
|
|
{issues?.groupedIssueIds?.length === 0 ? (
|
|
|
|
<div className="relative h-full w-full overflow-y-auto">
|
|
|
|
<ProjectArchivedEmptyState />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<Fragment>
|
|
|
|
<div className="relative h-full w-full overflow-auto">
|
|
|
|
<ArchivedIssueListLayout />
|
|
|
|
</div>
|
2024-02-18 09:58:37 +00:00
|
|
|
<IssuePeekOverview is_archived />
|
2024-02-13 15:28:44 +00:00
|
|
|
</Fragment>
|
|
|
|
)}
|
2024-03-20 15:32:58 +00:00
|
|
|
</>
|
2023-11-03 14:50:05 +00:00
|
|
|
);
|
|
|
|
});
|