2023-11-23 09:17:04 +00:00
|
|
|
import React from "react";
|
2023-10-18 07:02:02 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
|
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-11-23 09:17:04 +00:00
|
|
|
import { BaseSpreadsheetRoot } from "../base-spreadsheet-root";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { EIssueActions } from "../../types";
|
|
|
|
import { IIssue } from "types";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { ProjectIssueQuickActions } from "../../quick-action-dropdowns";
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
export const ProjectSpreadsheetLayout: React.FC = observer(() => {
|
2023-11-27 08:45:33 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query as { workspaceSlug: string };
|
|
|
|
|
2023-11-23 09:17:04 +00:00
|
|
|
const { projectIssues: projectIssuesStore, projectIssuesFilter: projectIssueFiltersStore } = useMobxStore();
|
2023-11-27 08:45:33 +00:00
|
|
|
|
|
|
|
const issueActions = {
|
|
|
|
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug) return;
|
|
|
|
|
|
|
|
await projectIssuesStore.updateIssue(workspaceSlug, issue.project, issue.id, issue);
|
|
|
|
},
|
|
|
|
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug) return;
|
|
|
|
|
|
|
|
await projectIssuesStore.removeIssue(workspaceSlug, issue.project, issue.id);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BaseSpreadsheetRoot
|
|
|
|
issueStore={projectIssuesStore}
|
|
|
|
issueFiltersStore={projectIssueFiltersStore}
|
|
|
|
issueActions={issueActions}
|
|
|
|
QuickActions={ProjectIssueQuickActions}
|
|
|
|
/>
|
|
|
|
);
|
2023-10-18 07:02:02 +00:00
|
|
|
});
|