Skip to content

Commit

Permalink
added error checking in reaction display component
Browse files Browse the repository at this point in the history
  • Loading branch information
ARADDCC002 committed Dec 16, 2024
1 parent 65d259b commit 64d10bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frontend/src/reviews/ReactionDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button, Tooltip } from '@mui/material'
import { useGetMultipleUserInformation } from 'actions/user'
import { ReactNode, useMemo } from 'react'
import Loading from 'src/common/Loading'
import MessageAlert from 'src/MessageAlert'
import { ReactionKindKeys } from 'types/types'
import { plural } from 'utils/stringUtils'

Expand All @@ -13,7 +14,7 @@ type ReactionDisplayProps = {
}

export default function ReactionDisplay({ kind, icon, users, onReactionClick }: ReactionDisplayProps) {
const { userInformation, isUserInformationLoading } = useGetMultipleUserInformation(users)
const { userInformation, isUserInformationLoading, isUserInformationError } = useGetMultipleUserInformation(users)
const title = useMemo(() => {
return userInformation && userInformation.length > 3
? `${userInformation
Expand All @@ -22,6 +23,11 @@ export default function ReactionDisplay({ kind, icon, users, onReactionClick }:
.join(', ')}, and ${userInformation.length - 3} others`
: `${userInformation.map((user) => user.name).join(', ')}`
}, [userInformation])

if (isUserInformationError) {
return <MessageAlert message={isUserInformationError.info.message} severity='error' />
}

if (isUserInformationLoading) {
return <Loading />
}
Expand Down

0 comments on commit 64d10bb

Please sign in to comment.