2023-09-01 11:12:30 +00:00
|
|
|
import { FC } from "react";
|
2023-08-11 11:48:33 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-08-11 11:48:33 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IssueBlockDueDate } from "@/components/issues/board-views/block-due-date";
|
|
|
|
import { IssueBlockLabels } from "@/components/issues/board-views/block-labels";
|
|
|
|
import { IssueBlockPriority } from "@/components/issues/board-views/block-priority";
|
|
|
|
import { IssueBlockState } from "@/components/issues/board-views/block-state";
|
2023-08-11 11:48:33 +00:00
|
|
|
// mobx hook
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useMobxStore } from "@/lib/mobx/store-provider";
|
2023-08-11 11:48:33 +00:00
|
|
|
// interfaces
|
2024-03-19 14:38:35 +00:00
|
|
|
import { RootStore } from "@/store/root";
|
2023-09-01 11:12:30 +00:00
|
|
|
import { IIssue } from "types/issue";
|
|
|
|
// store
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
export const IssueListBlock: FC<{ issue: IIssue }> = observer((props) => {
|
|
|
|
const { issue } = props;
|
|
|
|
// store
|
|
|
|
const { project: projectStore, issueDetails: issueDetailStore }: RootStore = useMobxStore();
|
|
|
|
// router
|
|
|
|
const router = useRouter();
|
2023-12-06 10:57:33 +00:00
|
|
|
const { workspace_slug, project_slug, board, priorities, states, labels } = router.query as {
|
|
|
|
workspace_slug: string;
|
|
|
|
project_slug: string;
|
|
|
|
board: string;
|
|
|
|
priorities: string;
|
|
|
|
states: string;
|
|
|
|
labels: string;
|
|
|
|
};
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
const handleBlockClick = () => {
|
|
|
|
issueDetailStore.setPeekId(issue.id);
|
2023-12-06 10:57:33 +00:00
|
|
|
const params: any = { board: board, peekId: issue.id };
|
|
|
|
if (states && states.length > 0) params.states = states;
|
|
|
|
if (priorities && priorities.length > 0) params.priorities = priorities;
|
|
|
|
if (labels && labels.length > 0) params.labels = labels;
|
2023-09-03 20:20:49 +00:00
|
|
|
router.push(
|
2023-09-01 11:12:30 +00:00
|
|
|
{
|
2023-12-06 10:57:33 +00:00
|
|
|
pathname: `/${workspace_slug}/${project_slug}`,
|
|
|
|
query: { ...params },
|
2023-09-01 11:12:30 +00:00
|
|
|
},
|
2023-09-03 20:20:49 +00:00
|
|
|
undefined,
|
2023-09-01 11:12:30 +00:00
|
|
|
{ shallow: true }
|
|
|
|
);
|
|
|
|
// router.push(`/${workspace_slug?.toString()}/${project_slug}?board=${board?.toString()}&peekId=${issue.id}`);
|
|
|
|
};
|
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
return (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative flex items-center gap-10 bg-custom-background-100 p-3">
|
|
|
|
<div className="relative flex w-full flex-grow items-center gap-3 overflow-hidden">
|
2023-08-11 11:48:33 +00:00
|
|
|
{/* id */}
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex-shrink-0 text-xs font-medium text-custom-text-300">
|
2023-09-01 11:12:30 +00:00
|
|
|
{projectStore?.project?.identifier}-{issue?.sequence_id}
|
2023-08-11 11:48:33 +00:00
|
|
|
</div>
|
|
|
|
{/* name */}
|
2023-12-10 10:18:10 +00:00
|
|
|
<div onClick={handleBlockClick} className="flex-grow cursor-pointer truncate text-sm font-medium">
|
2023-09-01 11:12:30 +00:00
|
|
|
{issue.name}
|
|
|
|
</div>
|
2023-08-11 11:48:33 +00:00
|
|
|
</div>
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
<div className="inline-flex flex-shrink-0 items-center gap-2 text-xs">
|
|
|
|
{/* priority */}
|
|
|
|
{issue?.priority && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockPriority priority={issue?.priority} />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
{/* state */}
|
|
|
|
{issue?.state_detail && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockState state={issue?.state_detail} />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
{/* labels */}
|
|
|
|
{issue?.label_details && issue?.label_details.length > 0 && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockLabels labels={issue?.label_details} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{/* due date */}
|
|
|
|
{issue?.target_date && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockDueDate due_date={issue?.target_date} group={issue?.state_detail?.group} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-08-11 11:48:33 +00:00
|
|
|
</div>
|
|
|
|
);
|
2023-09-01 11:12:30 +00:00
|
|
|
});
|