2023-11-03 14:50:05 +00:00
|
|
|
import { FC } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// hooks
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
// components
|
|
|
|
import { List } from "../default";
|
|
|
|
import { ArchivedIssueQuickActions } from "components/issues";
|
|
|
|
// helpers
|
|
|
|
import { orderArrayBy } from "helpers/array.helper";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
|
|
|
// constants
|
|
|
|
import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
|
|
|
|
|
|
|
|
export const ArchivedIssueListLayout: FC = observer(() => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
|
|
|
const {
|
|
|
|
project: projectStore,
|
2023-11-18 20:16:11 +00:00
|
|
|
projectLabel: { projectLabels },
|
2023-11-09 12:26:55 +00:00
|
|
|
projectMember: { projectMembers },
|
2023-11-08 15:01:46 +00:00
|
|
|
projectState: projectStateStore,
|
2023-11-20 10:28:40 +00:00
|
|
|
projectEstimates: { projectEstimates },
|
2023-11-03 14:50:05 +00:00
|
|
|
archivedIssues: archivedIssueStore,
|
|
|
|
archivedIssueFilters: archivedIssueFiltersStore,
|
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
// derived values
|
|
|
|
const issues = archivedIssueStore.getIssues;
|
2023-11-06 15:13:10 +00:00
|
|
|
const displayProperties = archivedIssueFiltersStore?.userDisplayProperties || null;
|
2023-11-03 14:50:05 +00:00
|
|
|
const group_by: string | null = archivedIssueFiltersStore?.userDisplayFilters?.group_by || null;
|
2023-11-20 07:18:30 +00:00
|
|
|
const showEmptyGroup = archivedIssueFiltersStore?.userDisplayFilters?.show_empty_groups || false;
|
2023-11-03 14:50:05 +00:00
|
|
|
|
|
|
|
const handleIssues = (group_by: string | null, issue: IIssue, action: "delete" | "update") => {
|
|
|
|
if (!workspaceSlug || !projectId) return;
|
|
|
|
|
|
|
|
if (action === "delete") {
|
2023-11-20 07:18:30 +00:00
|
|
|
archivedIssueStore.deleteArchivedIssue(group_by === "null" ? null : group_by, null, issue);
|
|
|
|
archivedIssueStore.fetchIssues(workspaceSlug.toString(), projectId.toString());
|
2023-11-03 14:50:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
|
|
|
|
|
2023-11-08 15:01:46 +00:00
|
|
|
const states = projectStateStore?.projectStates || null;
|
2023-11-03 14:50:05 +00:00
|
|
|
const priorities = ISSUE_PRIORITIES || null;
|
|
|
|
const stateGroups = ISSUE_STATE_GROUPS || null;
|
|
|
|
const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
|
|
|
|
const estimates =
|
2023-11-20 10:28:40 +00:00
|
|
|
projectDetails?.estimate !== null ? projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null : null;
|
2023-11-03 14:50:05 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="relative w-full h-full bg-custom-background-90">
|
|
|
|
<List
|
|
|
|
issues={issues}
|
|
|
|
group_by={group_by}
|
|
|
|
isReadonly
|
|
|
|
handleIssues={handleIssues}
|
|
|
|
quickActions={(group_by, issue) => (
|
|
|
|
<ArchivedIssueQuickActions issue={issue} handleDelete={async () => handleIssues(group_by, issue, "delete")} />
|
|
|
|
)}
|
2023-11-06 15:13:10 +00:00
|
|
|
displayProperties={displayProperties}
|
2023-11-03 14:50:05 +00:00
|
|
|
states={states}
|
|
|
|
stateGroups={stateGroups}
|
|
|
|
priorities={priorities}
|
2023-11-18 20:16:11 +00:00
|
|
|
labels={projectLabels}
|
2023-11-09 12:26:55 +00:00
|
|
|
members={projectMembers?.map((m) => m.member) ?? null}
|
2023-11-03 14:50:05 +00:00
|
|
|
projects={projects}
|
|
|
|
estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
|
2023-11-20 07:18:30 +00:00
|
|
|
showEmptyGroup={showEmptyGroup}
|
2023-11-03 14:50:05 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|