2024-01-24 15:03:54 +00:00
|
|
|
import { FC, useEffect } from "react";
|
|
|
|
import { observer } from "mobx-react";
|
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// icons
|
|
|
|
import { CalendarDays } from "lucide-react";
|
|
|
|
// hooks
|
2024-03-12 15:09:36 +00:00
|
|
|
import { usePlatformOS } from "hooks/use-platform-os";
|
2024-01-24 15:03:54 +00:00
|
|
|
// ui
|
|
|
|
import { Tooltip, PriorityIcon } from "@plane/ui";
|
|
|
|
// helpers
|
2024-03-06 13:09:14 +00:00
|
|
|
import { InboxIssueStatus } from "components/inbox/inbox-issue-status";
|
2024-01-24 15:03:54 +00:00
|
|
|
import { renderFormattedDate } from "helpers/date-time.helper";
|
|
|
|
// components
|
2024-03-06 13:09:14 +00:00
|
|
|
import { useInboxIssues, useIssueDetail, useProject } from "hooks/store";
|
2024-01-24 15:03:54 +00:00
|
|
|
|
|
|
|
type TInboxIssueListItem = {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
inboxId: string;
|
|
|
|
issueId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const InboxIssueListItem: FC<TInboxIssueListItem> = observer((props) => {
|
|
|
|
const { workspaceSlug, projectId, inboxId, issueId } = props;
|
|
|
|
// router
|
|
|
|
const router = useRouter();
|
|
|
|
const { inboxIssueId } = router.query;
|
|
|
|
// hooks
|
|
|
|
const { getProjectById } = useProject();
|
|
|
|
const {
|
|
|
|
issues: { getInboxIssueByIssueId },
|
|
|
|
} = useInboxIssues();
|
|
|
|
const {
|
|
|
|
issue: { getIssueById },
|
|
|
|
} = useIssueDetail();
|
2024-03-12 15:09:36 +00:00
|
|
|
const { isMobile } = usePlatformOS();
|
2024-01-24 15:03:54 +00:00
|
|
|
const inboxIssueDetail = getInboxIssueByIssueId(inboxId, issueId);
|
|
|
|
const issue = getIssueById(issueId);
|
|
|
|
|
|
|
|
if (!issue || !inboxIssueDetail) return <></>;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (issueId === inboxIssueId) {
|
|
|
|
setTimeout(() => {
|
|
|
|
const issueItemCard = document.getElementById(`inbox-issue-list-item-${issueId}`);
|
|
|
|
if (issueItemCard)
|
|
|
|
issueItemCard.scrollIntoView({
|
|
|
|
behavior: "smooth",
|
|
|
|
block: "center",
|
|
|
|
});
|
|
|
|
}, 200);
|
|
|
|
}
|
|
|
|
}, [issueId, inboxIssueId]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Link
|
|
|
|
id={`inbox-issue-list-item-${issue.id}`}
|
|
|
|
key={`${inboxId}_${issueId}`}
|
|
|
|
href={`/${workspaceSlug}/projects/${projectId}/inbox/${inboxId}?inboxIssueId=${issueId}`}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={`relative min-h-[5rem]select-none space-y-3 border-b border-custom-border-200 px-4 py-2 hover:bg-custom-primary/5 cursor-pointer ${
|
|
|
|
inboxIssueId === issueId ? "bg-custom-primary/5" : " "
|
|
|
|
} ${inboxIssueDetail.status !== -2 ? "opacity-60" : ""}`}
|
|
|
|
>
|
|
|
|
<div className="flex items-center justify-between gap-x-2">
|
2024-01-25 13:50:02 +00:00
|
|
|
<div className="relative flex items-center gap-x-2 overflow-hidden">
|
2024-01-24 15:03:54 +00:00
|
|
|
<p className="flex-shrink-0 text-xs text-custom-text-200">
|
|
|
|
{getProjectById(issue.project_id)?.identifier}-{issue.sequence_id}
|
|
|
|
</p>
|
|
|
|
<h5 className="truncate text-sm">{issue.name}</h5>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<InboxIssueStatus
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
inboxId={inboxId}
|
|
|
|
issueId={issueId}
|
|
|
|
iconSize={14}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
2024-03-12 15:09:36 +00:00
|
|
|
<Tooltip tooltipHeading="Priority" tooltipContent={`${issue.priority ?? "None"}`} isMobile={isMobile}>
|
2024-01-24 15:03:54 +00:00
|
|
|
<PriorityIcon priority={issue.priority ?? null} className="h-3.5 w-3.5" />
|
|
|
|
</Tooltip>
|
2024-03-12 15:09:36 +00:00
|
|
|
<Tooltip tooltipHeading="Created on" tooltipContent={`${renderFormattedDate(issue.created_at ?? "")}`} isMobile={isMobile}>
|
2024-01-24 15:03:54 +00:00
|
|
|
<div className="flex items-center gap-1 rounded border border-custom-border-200 px-2 py-[0.19rem] text-xs text-custom-text-200 shadow-sm">
|
|
|
|
<CalendarDays size={12} strokeWidth={1.5} />
|
|
|
|
<span>{renderFormattedDate(issue.created_at ?? "")}</span>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|