import React from "react"; // next import { useRouter } from "next/router"; import Image from "next/image"; // swr import { KeyedMutator } from "swr"; // common import { addSpaceIfCamelCase, renderShortNumericDateFormat, timeAgo } from "constants/common"; // ui import { Loader } from "ui"; // icons import { CalendarDaysIcon, ChartBarIcon, ChatBubbleBottomCenterTextIcon, Squares2X2Icon, UserIcon, } from "@heroicons/react/24/outline"; import { BlockedIcon, BlockerIcon, TagIcon, UserGroupIcon } from "ui/icons"; import { IIssueActivity, IIssueComment } from "types"; // components import CommentCard from "components/project/issues/issue-detail/comment/issue-comment-card"; // services import issuesServices from "lib/services/issues.service"; 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: , }, labels: { 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: , }, }; const defaultValues: Partial = { comment_html: "", comment_json: "", }; const IssueActivitySection: React.FC<{ issueActivities: IIssueActivity[]; mutate: KeyedMutator; }> = ({ issueActivities, mutate }) => { const router = useRouter(); let { workspaceSlug, projectId, issueId } = router.query; const onCommentUpdate = async (comment: IIssueComment) => { if (!workspaceSlug || !projectId || !issueId) return; await issuesServices .patchIssueComment( workspaceSlug as string, projectId as string, issueId as string, comment.id, comment ) .then((response) => { mutate(); }); }; const onCommentDelete = async (commentId: string) => { if (!workspaceSlug || !projectId || !issueId) return; await issuesServices .deleteIssueComment( workspaceSlug as string, projectId as string, issueId as string, commentId ) .then((response) => { mutate(); 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 ( ); } })}
) : (
)} ); }; export default IssueActivitySection;