2024-01-24 15:03:54 +00:00
|
|
|
import React from "react";
|
2024-02-15 14:01:38 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-01-24 15:03:54 +00:00
|
|
|
// hooks
|
2024-03-06 13:09:14 +00:00
|
|
|
import { INBOX_STATUS } from "constants/inbox";
|
2024-01-24 15:03:54 +00:00
|
|
|
import { useInboxIssues } from "hooks/store";
|
|
|
|
// constants
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
inboxId: string;
|
|
|
|
issueId: string;
|
|
|
|
iconSize?: number;
|
|
|
|
showDescription?: boolean;
|
|
|
|
};
|
|
|
|
|
2024-02-15 14:01:38 +00:00
|
|
|
export const InboxIssueStatus: React.FC<Props> = observer((props) => {
|
2024-01-24 15:03:54 +00:00
|
|
|
const { workspaceSlug, projectId, inboxId, issueId, iconSize = 18, showDescription = false } = props;
|
|
|
|
// hooks
|
|
|
|
const {
|
|
|
|
issues: { getInboxIssueByIssueId },
|
|
|
|
} = useInboxIssues();
|
|
|
|
|
|
|
|
const inboxIssueDetail = getInboxIssueByIssueId(inboxId, issueId);
|
|
|
|
if (!inboxIssueDetail) return <></>;
|
|
|
|
|
|
|
|
const inboxIssueStatusDetail = INBOX_STATUS.find((s) => s.status === inboxIssueDetail.status);
|
|
|
|
if (!inboxIssueStatusDetail) return <></>;
|
|
|
|
|
|
|
|
const isSnoozedDatePassed =
|
|
|
|
inboxIssueDetail.status === 0 && new Date(inboxIssueDetail.snoozed_till ?? "") < new Date();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={`flex items-center ${inboxIssueStatusDetail.textColor(isSnoozedDatePassed)} ${
|
|
|
|
showDescription
|
|
|
|
? `p-3 gap-2 text-sm rounded-md border ${inboxIssueStatusDetail.bgColor(
|
|
|
|
isSnoozedDatePassed
|
|
|
|
)} ${inboxIssueStatusDetail.borderColor(isSnoozedDatePassed)} `
|
|
|
|
: "w-full justify-end gap-1 text-xs"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
<inboxIssueStatusDetail.icon size={iconSize} strokeWidth={2} />
|
|
|
|
{showDescription ? (
|
|
|
|
inboxIssueStatusDetail.description(
|
|
|
|
workspaceSlug,
|
|
|
|
projectId,
|
|
|
|
inboxIssueDetail.duplicate_to ?? "",
|
|
|
|
new Date(inboxIssueDetail.snoozed_till ?? "")
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<span>{inboxIssueStatusDetail.title}</span>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2024-02-15 14:01:38 +00:00
|
|
|
});
|