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";
|
|
|
|
// components
|
2023-11-23 09:17:04 +00:00
|
|
|
import { BaseSpreadsheetRoot } from "../base-spreadsheet-root";
|
|
|
|
import { useRouter } from "next/router";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { EIssueActions } from "../../types";
|
|
|
|
import { IIssue } from "types";
|
|
|
|
import { ModuleIssueQuickActions } from "../../quick-action-dropdowns";
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
export const ModuleSpreadsheetLayout: React.FC = observer(() => {
|
|
|
|
const router = useRouter();
|
2023-11-27 08:45:33 +00:00
|
|
|
const { workspaceSlug, moduleId } = router.query as { workspaceSlug: string; moduleId: string };
|
2023-10-18 07:02:02 +00:00
|
|
|
|
2023-11-23 09:17:04 +00:00
|
|
|
const { moduleIssues: moduleIssueStore, moduleIssuesFilter: moduleIssueFilterStore } = useMobxStore();
|
2023-11-27 08:45:33 +00:00
|
|
|
|
|
|
|
const issueActions = {
|
|
|
|
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !moduleId) return;
|
|
|
|
|
|
|
|
moduleIssueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue, moduleId);
|
|
|
|
},
|
|
|
|
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !moduleId) return;
|
|
|
|
moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
|
|
|
},
|
|
|
|
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !moduleId || !issue.bridge_id) return;
|
|
|
|
moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-10-18 07:02:02 +00:00
|
|
|
return (
|
2023-11-27 08:45:33 +00:00
|
|
|
<BaseSpreadsheetRoot
|
|
|
|
issueStore={moduleIssueStore}
|
|
|
|
issueFiltersStore={moduleIssueFilterStore}
|
|
|
|
viewId={moduleId}
|
|
|
|
issueActions={issueActions}
|
|
|
|
QuickActions={ModuleIssueQuickActions}
|
|
|
|
/>
|
2023-10-18 07:02:02 +00:00
|
|
|
);
|
|
|
|
});
|