import React from "react"; import { useRouter } from "next/router"; import Image from "next/image"; import useSWR from "swr"; // icons import { CalendarDaysIcon, ChartBarIcon, ChatBubbleBottomCenterTextIcon, RectangleGroupIcon, Squares2X2Icon, UserIcon, } from "@heroicons/react/24/outline"; // services import issuesService from "services/issues.service"; // components import { CommentCard } from "components/issues/comment"; // ui import { Loader } from "components/ui"; // icons import { BlockedIcon, BlockerIcon, CyclesIcon, TagIcon, UserGroupIcon } from "components/icons"; // helpers import { renderShortNumericDateFormat, timeAgo } from "helpers/date-time.helper"; import { addSpaceIfCamelCase } from "helpers/string.helper"; // types import { IIssueComment } from "types"; import { PROJECT_ISSUES_ACTIVITY } from "constants/fetch-keys"; const activityDetails: { [key: string]: { message?: string; icon: JSX.Element; }; } = { assignee: { message: "removed the assignee", icon: , }, assignees: { message: "added a new assignee", icon: , }, blocks: { message: "marked this issue being blocked by", icon: , }, blocking: { message: "marked this issue is blocking", icon: , }, cycles: { message: "set the cycle to", icon: , }, labels: { icon: , }, modules: { message: "set the module to", icon: , }, state: { message: "set the state to", icon: , }, priority: { message: "set the priority to", icon: , }, name: { message: "set the name to", icon: , }, description: { message: "updated the description.", icon: , }, target_date: { message: "set the due date to", icon: , }, parent: { message: "set the parent to", icon: , }, }; type Props = {}; export const IssueActivitySection: React.FC = () => { const router = useRouter(); const { workspaceSlug, projectId, issueId } = router.query; const { data: issueActivities, mutate: mutateIssueActivities } = useSWR( workspaceSlug && projectId && issueId ? PROJECT_ISSUES_ACTIVITY(issueId as string) : null, workspaceSlug && projectId && issueId ? () => issuesService.getIssueActivities( workspaceSlug as string, projectId as string, issueId as string ) : null ); const handleCommentUpdate = async (comment: IIssueComment) => { if (!workspaceSlug || !projectId || !issueId) return; await issuesService .patchIssueComment( workspaceSlug as string, projectId as string, issueId as string, comment.id, comment ) .then((res) => { mutateIssueActivities(); }); }; const handleCommentDelete = async (commentId: string) => { if (!workspaceSlug || !projectId || !issueId) return; await issuesService .deleteIssueComment( workspaceSlug as string, projectId as string, issueId as string, commentId ) .then((response) => { mutateIssueActivities(); console.log(response); }); }; return ( <> {issueActivities ? (
{issueActivities.map((activity, index) => { if ("field" in activity && activity.field !== "updated_by") { return (
{issueActivities.length > 1 && index !== issueActivities.length - 1 ? (
); } else if ("comment_json" in activity) return ( ); })}
) : (
)} ); };