import { useRouter } from "next/router"; import useSWR from "swr"; // services import issuesService from "services/issues.service"; // icons import { Icon, Tooltip } from "components/ui"; import { CopyPlus } from "lucide-react"; import { Squares2X2Icon } from "@heroicons/react/24/outline"; import { BlockedIcon, BlockerIcon, RelatedIcon } from "components/icons"; // helpers import { renderShortDateWithYearFormat } from "helpers/date-time.helper"; import { capitalizeFirstLetter } from "helpers/string.helper"; // types import { IIssueActivity } from "types"; // fetch-keys import { WORKSPACE_LABELS } from "constants/fetch-keys"; const IssueLink = ({ activity }: { activity: IIssueActivity }) => { const router = useRouter(); const { workspaceSlug } = router.query; return ( {activity.issue_detail ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` : "Issue"} ); }; const UserLink = ({ activity }: { activity: IIssueActivity }) => { const router = useRouter(); const { workspaceSlug } = router.query; return ( {activity.new_value && activity.new_value !== "" ? activity.new_value : activity.old_value} ); }; const LabelPill = ({ labelId }: { labelId: string }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { data: labels } = useSWR( workspaceSlug ? WORKSPACE_LABELS(workspaceSlug.toString()) : null, workspaceSlug ? () => issuesService.getWorkspaceLabels(workspaceSlug.toString()) : null ); return ( l.id === labelId)?.color ?? "#000000", }} aria-hidden="true" /> ); }; const activityDetails: { [key: string]: { message: ( activity: IIssueActivity, showIssue: boolean, workspaceSlug: string ) => React.ReactNode; icon: React.ReactNode; }; } = { assignees: { message: (activity, showIssue) => { if (activity.old_value === "") return ( <> added a new assignee {showIssue && ( <> {" "} to )} . ); else return ( <> removed the assignee {showIssue && ( <> {" "} from )} . ); }, icon: