diff --git a/api/src/graphql/partReactions.sdl.js b/api/src/graphql/partReactions.sdl.js index 4eaaa26..b27334e 100644 --- a/api/src/graphql/partReactions.sdl.js +++ b/api/src/graphql/partReactions.sdl.js @@ -13,6 +13,7 @@ export const schema = gql` type Query { partReactions: [PartReaction!]! partReaction(id: String!): PartReaction + partReactionsByPartId(partId: String!): [PartReaction!]! } input TogglePartReactionInput { diff --git a/api/src/services/partReactions/partReactions.js b/api/src/services/partReactions/partReactions.js index 9116014..6adac0f 100644 --- a/api/src/services/partReactions/partReactions.js +++ b/api/src/services/partReactions/partReactions.js @@ -15,6 +15,12 @@ export const partReaction = ({ id }) => { }) } +export const partReactionsByPartId = ({ partId }) => { + return db.partReaction.findMany({ + where: { partId: partId }, + }) +} + export const togglePartReaction = async ({ input }) => { // if write fails emote_userId_partId @@unique constraint, then delete it instead requireAuth() diff --git a/web/src/components/EmojiReaction/EmojiReaction.js b/web/src/components/EmojiReaction/EmojiReaction.js index ce254b9..dbc931a 100644 --- a/web/src/components/EmojiReaction/EmojiReaction.js +++ b/web/src/components/EmojiReaction/EmojiReaction.js @@ -20,6 +20,7 @@ const EmojiReaction = ({ emotes, userEmotes, onEmote = () => {}, + onShowPartReactions, className, }) => { const { currentUser } = useAuth() @@ -107,17 +108,20 @@ const EmojiReaction = ({ horizontal: 'left', }} > -
- {emojiMenu.map((emoji, i) => ( - - ))} +
+
+ {emojiMenu.map((emoji, i) => ( + + ))} +
+
diff --git a/web/src/components/PartProfile/PartProfile.js b/web/src/components/PartProfile/PartProfile.js index 7ff2d8e..222a47b 100644 --- a/web/src/components/PartProfile/PartProfile.js +++ b/web/src/components/PartProfile/PartProfile.js @@ -2,12 +2,14 @@ import { useState, useEffect, useRef } from 'react' import { useAuth } from '@redwoodjs/auth' import { Link, navigate, routes } from '@redwoodjs/router' import Editor from 'rich-markdown-editor' +import Dialog from '@material-ui/core/Dialog' import ImageUploader from 'src/components/ImageUploader' import ConfirmDialog from 'src/components/ConfirmDialog' import Breadcrumb from 'src/components/Breadcrumb' import EmojiReaction from 'src/components/EmojiReaction' import Button from 'src/components/Button' +import PartReactionsCell from '../PartReactionsCell' import { countEmotes } from 'src/helpers/emote' import { getActiveClasses } from 'get-active-classes' @@ -21,6 +23,7 @@ const PartProfile = ({ }) => { const [comment, setComment] = useState('') const [isConfirmDialogOpen, setIsConfirmDialogOpen] = useState(false) + const [isReactionsModalOpen, setIsReactionsModalOpen] = useState(false) const [isInvalid, setIsInvalid] = useState(false) const { currentUser } = useAuth() const editorRef = useRef(null) @@ -94,6 +97,7 @@ const PartProfile = ({ emotes={emotes} userEmotes={userEmotes} onEmote={onReaction} + onShowPartReactions={() => setIsReactionsModalOpen(true)} />