forked from github/plane
5b0066140f
* chore: format all files in the project * fix: removing @types/react from dependencies * fix: adding prettier and eslint config * chore: format files * fix: upgrading turbo version * chore: ignoring warnings and adding todos * fix: updated the type of bubble menu item in the document editor * chore: format files --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { FC } from "react";
|
|
// components
|
|
import { IssueReactionPreview, IssueReactionSelector } from "components/issues";
|
|
// types
|
|
import { IUser } from "types";
|
|
|
|
interface IIssueReaction {
|
|
issueReactions: any;
|
|
user: IUser | null;
|
|
issueReactionCreate: (reaction: string) => void;
|
|
issueReactionRemove: (reaction: string) => void;
|
|
position?: "top" | "bottom";
|
|
}
|
|
|
|
export const IssuePeekOverviewReactions: FC<IIssueReaction> = (props) => {
|
|
const { issueReactions, user, issueReactionCreate, issueReactionRemove, position = "bottom" } = props;
|
|
|
|
const handleReaction = (reaction: string) => {
|
|
const isReactionAvailable =
|
|
issueReactions?.[reaction].find((_reaction: any) => _reaction.actor === user?.id) ?? false;
|
|
|
|
if (isReactionAvailable) issueReactionRemove(reaction);
|
|
else issueReactionCreate(reaction);
|
|
};
|
|
|
|
return (
|
|
<div className="relative flex flex-wrap items-center gap-2">
|
|
<IssueReactionSelector onSelect={handleReaction} position={position} />
|
|
<IssueReactionPreview issueReactions={issueReactions} user={user} handleReaction={handleReaction} />
|
|
</div>
|
|
);
|
|
};
|