2023-11-23 09:17:04 +00:00
|
|
|
import { FC } from "react";
|
2023-10-20 11:37:46 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-10-17 10:53:54 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-11-27 08:45:33 +00:00
|
|
|
// hooks
|
2023-10-20 11:37:46 +00:00
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-10-17 10:53:54 +00:00
|
|
|
// components
|
2023-10-20 11:37:46 +00:00
|
|
|
import { ProjectIssueQuickActions } from "components/issues";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
2023-11-23 09:17:04 +00:00
|
|
|
import { EIssueActions } from "../../types";
|
2023-11-27 08:45:33 +00:00
|
|
|
// constants
|
2023-11-23 09:17:04 +00:00
|
|
|
import { BaseListRoot } from "../base-list-root";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { IProjectStore } from "store/project";
|
|
|
|
import { EProjectStore } from "store/command-palette.store";
|
2023-10-17 10:53:54 +00:00
|
|
|
|
|
|
|
export const ProfileIssuesListLayout: FC = observer(() => {
|
2023-10-20 11:37:46 +00:00
|
|
|
const router = useRouter();
|
2023-11-27 08:45:33 +00:00
|
|
|
const { workspaceSlug, userId } = router.query as { workspaceSlug: string; userId: string };
|
|
|
|
|
|
|
|
// store
|
|
|
|
const { workspaceProfileIssuesFilter: profileIssueFiltersStore, workspaceProfileIssues: profileIssuesStore } =
|
|
|
|
useMobxStore();
|
2023-10-17 10:53:54 +00:00
|
|
|
|
2023-11-23 09:17:04 +00:00
|
|
|
const issueActions = {
|
2023-11-27 08:45:33 +00:00
|
|
|
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !userId) return;
|
2023-10-20 11:37:46 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
await profileIssuesStore.updateIssue(workspaceSlug, userId, issue.id, issue);
|
2023-11-23 09:17:04 +00:00
|
|
|
},
|
2023-11-27 08:45:33 +00:00
|
|
|
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !userId) return;
|
|
|
|
|
2023-11-29 14:28:27 +00:00
|
|
|
await profileIssuesStore.removeIssue(workspaceSlug, issue.project, issue.id, userId);
|
2023-10-20 11:37:46 +00:00
|
|
|
},
|
2023-11-23 09:17:04 +00:00
|
|
|
};
|
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
const getProjects = (projectStore: IProjectStore) => projectStore.workspaceProjects;
|
2023-10-17 10:53:54 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
return (
|
|
|
|
<BaseListRoot
|
|
|
|
issueFilterStore={profileIssueFiltersStore}
|
|
|
|
issueStore={profileIssuesStore}
|
|
|
|
QuickActions={ProjectIssueQuickActions}
|
|
|
|
issueActions={issueActions}
|
|
|
|
getProjects={getProjects}
|
|
|
|
currentStore={EProjectStore.PROFILE}
|
|
|
|
/>
|
|
|
|
);
|
2023-10-17 10:53:54 +00:00
|
|
|
});
|