// hooks import useIssueReaction from "hooks/use-issue-reaction"; // components import { ReactionSelector } from "components/core"; // string helpers import { renderEmoji } from "helpers/emoji.helper"; import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // types type Props = { workspaceSlug: string; projectId: string; issueId: string; }; export const IssueReaction: React.FC = observer((props) => { const { workspaceSlug, projectId, issueId } = props; const { user: { currentUser }, } = useMobxStore(); const { reactions, groupedReactions, handleReactionCreate, handleReactionDelete } = useIssueReaction( workspaceSlug, projectId, issueId ); const handleReactionClick = (reaction: string) => { if (!workspaceSlug || !projectId || !issueId) return; const isSelected = reactions?.some((r) => r.actor === currentUser?.id && r.reaction === reaction); if (isSelected) { handleReactionDelete(reaction); } else { handleReactionCreate(reaction); } }; return (
reaction.actor === currentUser?.id).map((r) => r.reaction) || []} onSelect={handleReactionClick} /> {Object.keys(groupedReactions || {}).map( (reaction) => groupedReactions?.[reaction]?.length && groupedReactions[reaction].length > 0 && ( ) )}
); });