2023-10-18 07:02:02 +00:00
|
|
|
import React, { useCallback } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
|
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
// components
|
|
|
|
import { SpreadsheetView } from "components/issues";
|
|
|
|
// types
|
|
|
|
import { IIssue, IIssueDisplayFilterOptions } from "types";
|
|
|
|
// constants
|
|
|
|
import { IIssueUnGroupedStructure } from "store/issue";
|
|
|
|
|
|
|
|
export const CycleSpreadsheetLayout: React.FC = observer(() => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
|
|
|
const {
|
|
|
|
issueFilter: issueFilterStore,
|
|
|
|
cycleIssue: cycleIssueStore,
|
|
|
|
issueDetail: issueDetailStore,
|
|
|
|
project: projectStore,
|
2023-11-08 15:01:46 +00:00
|
|
|
projectState: projectStateStore,
|
2023-10-18 07:02:02 +00:00
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
const issues = cycleIssueStore.getIssues;
|
|
|
|
|
|
|
|
const handleDisplayFiltersUpdate = useCallback(
|
|
|
|
(updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => {
|
|
|
|
if (!workspaceSlug || !projectId) return;
|
|
|
|
|
|
|
|
issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), {
|
|
|
|
display_filters: {
|
|
|
|
...updatedDisplayFilter,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
[issueFilterStore, projectId, workspaceSlug]
|
|
|
|
);
|
|
|
|
|
|
|
|
const handleUpdateIssue = useCallback(
|
|
|
|
(issue: IIssue, data: Partial<IIssue>) => {
|
2023-10-20 11:37:46 +00:00
|
|
|
if (!workspaceSlug || !projectId) return;
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
const payload = {
|
|
|
|
...issue,
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
|
|
|
|
cycleIssueStore.updateIssueStructure(null, null, payload);
|
2023-10-20 11:37:46 +00:00
|
|
|
issueDetailStore.updateIssue(workspaceSlug.toString(), projectId.toString(), issue.id, data);
|
2023-10-18 07:02:02 +00:00
|
|
|
},
|
2023-10-20 11:37:46 +00:00
|
|
|
[issueDetailStore, cycleIssueStore, projectId, workspaceSlug]
|
2023-10-18 07:02:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SpreadsheetView
|
|
|
|
displayProperties={issueFilterStore.userDisplayProperties}
|
|
|
|
displayFilters={issueFilterStore.userDisplayFilters}
|
|
|
|
handleDisplayFilterUpdate={handleDisplayFiltersUpdate}
|
|
|
|
issues={issues as IIssueUnGroupedStructure}
|
|
|
|
members={projectId ? projectStore.members?.[projectId.toString()]?.map((m) => m.member) : undefined}
|
|
|
|
labels={projectId ? projectStore.labels?.[projectId.toString()] ?? undefined : undefined}
|
2023-11-08 15:01:46 +00:00
|
|
|
states={projectId ? projectStateStore.states?.[projectId.toString()] : undefined}
|
2023-10-18 07:02:02 +00:00
|
|
|
handleIssueAction={() => {}}
|
|
|
|
handleUpdateIssue={handleUpdateIssue}
|
|
|
|
disableUserActions={false}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|