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 { CycleIssueQuickActions } from "../../quick-action-dropdowns";
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
export const CycleSpreadsheetLayout: React.FC = observer(() => {
|
|
|
|
const router = useRouter();
|
2023-11-27 08:45:33 +00:00
|
|
|
const { workspaceSlug, cycleId } = router.query as { workspaceSlug: string; cycleId: string };
|
2023-10-18 07:02:02 +00:00
|
|
|
|
2023-11-23 09:17:04 +00:00
|
|
|
const { cycleIssues: cycleIssueStore, cycleIssuesFilter: cycleIssueFilterStore } = useMobxStore();
|
2023-10-18 07:02:02 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
const issueActions = {
|
|
|
|
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !cycleId) return;
|
|
|
|
|
|
|
|
cycleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, cycleId);
|
|
|
|
},
|
|
|
|
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !cycleId) return;
|
|
|
|
cycleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, cycleId);
|
|
|
|
},
|
|
|
|
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !cycleId || !issue.bridge_id) return;
|
|
|
|
cycleIssueStore.removeIssueFromCycle(workspaceSlug, issue.project, cycleId, issue.id, issue.bridge_id);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-10-18 07:02:02 +00:00
|
|
|
return (
|
2023-11-27 08:45:33 +00:00
|
|
|
<BaseSpreadsheetRoot
|
|
|
|
issueStore={cycleIssueStore}
|
|
|
|
issueFiltersStore={cycleIssueFilterStore}
|
|
|
|
viewId={cycleId}
|
|
|
|
issueActions={issueActions}
|
|
|
|
QuickActions={CycleIssueQuickActions}
|
|
|
|
/>
|
2023-10-18 07:02:02 +00:00
|
|
|
);
|
|
|
|
});
|