2023-08-11 11:48:33 +00:00
|
|
|
"use client";
|
|
|
|
|
2024-05-14 08:56:54 +00:00
|
|
|
import { FC } from "react";
|
2023-08-11 11:48:33 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2024-05-14 08:56:54 +00:00
|
|
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IssueBlockDueDate } from "@/components/issues/board-views/block-due-date";
|
|
|
|
import { IssueBlockPriority } from "@/components/issues/board-views/block-priority";
|
|
|
|
import { IssueBlockState } from "@/components/issues/board-views/block-state";
|
2024-05-14 08:56:54 +00:00
|
|
|
// hooks
|
|
|
|
import { useIssueDetails, useProject } from "@/hooks/store";
|
2023-08-11 11:48:33 +00:00
|
|
|
// interfaces
|
2024-05-14 08:56:54 +00:00
|
|
|
import { IIssue } from "@/types/issue";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
2024-05-14 08:56:54 +00:00
|
|
|
type IssueKanBanBlockProps = {
|
|
|
|
issue: IIssue;
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
params: any;
|
|
|
|
};
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2024-05-14 08:56:54 +00:00
|
|
|
export const IssueKanBanBlock: FC<IssueKanBanBlockProps> = observer((props) => {
|
|
|
|
const { workspaceSlug, projectId, params, issue } = props;
|
2024-05-16 07:37:47 +00:00
|
|
|
const { board, priority, states, labels } = params;
|
2024-05-14 08:56:54 +00:00
|
|
|
// store
|
|
|
|
const { project } = useProject();
|
|
|
|
const { setPeekId } = useIssueDetails();
|
2023-09-01 11:12:30 +00:00
|
|
|
// router
|
|
|
|
const router = useRouter();
|
2024-05-14 08:56:54 +00:00
|
|
|
const searchParams = useSearchParams();
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
const handleBlockClick = () => {
|
2024-05-14 08:56:54 +00:00
|
|
|
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;
|
2024-05-16 07:37:47 +00:00
|
|
|
if (priority && priority.length > 0) params.priority = priority;
|
2023-12-06 10:57:33 +00:00
|
|
|
if (labels && labels.length > 0) params.labels = labels;
|
2024-05-14 08:56:54 +00:00
|
|
|
router.push(`/${workspaceSlug}/${projectId}?${searchParams}`);
|
2023-09-01 11:12:30 +00:00
|
|
|
};
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
return (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex flex-col gap-1.5 space-y-2 rounded border-[0.5px] border-custom-border-200 bg-custom-background-100 px-3 py-2 text-sm shadow-custom-shadow-2xs">
|
2023-08-11 11:48:33 +00:00
|
|
|
{/* id */}
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="break-words text-xs text-custom-text-300">
|
2024-05-14 08:56:54 +00:00
|
|
|
{project?.identifier}-{issue?.sequence_id}
|
2023-08-11 11:48:33 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* name */}
|
2023-11-23 09:39:46 +00:00
|
|
|
<h6
|
|
|
|
onClick={handleBlockClick}
|
|
|
|
role="button"
|
2023-12-10 10:18:10 +00:00
|
|
|
className="line-clamp-2 cursor-pointer break-words text-sm font-medium"
|
2023-11-23 09:39:46 +00:00
|
|
|
>
|
2023-09-01 11:12:30 +00:00
|
|
|
{issue.name}
|
|
|
|
</h6>
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="hide-horizontal-scrollbar relative flex w-full flex-grow items-end gap-2 overflow-x-scroll">
|
2023-09-01 11:12:30 +00:00
|
|
|
{/* priority */}
|
2023-08-11 11:48:33 +00:00
|
|
|
{issue?.priority && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockPriority priority={issue?.priority} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{/* state */}
|
|
|
|
{issue?.state_detail && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockState state={issue?.state_detail} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{/* due date */}
|
|
|
|
{issue?.target_date && (
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<IssueBlockDueDate due_date={issue?.target_date} group={issue?.state_detail?.group} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-09-01 11:12:30 +00:00
|
|
|
});
|