Skip to content

Commit

Permalink
Add community classes to replies (#9513)
Browse files Browse the repository at this point in the history
* add community classes to replies

* use start date
  • Loading branch information
smallbrownbike authored Oct 1, 2024
1 parent 5def800 commit 4698799
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/components/Squeak/components/Replies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,35 @@ type ExpandedProps = {
replies: StrapiData<ReplyData[]>
}

const getComunityClasses = (reply, isResolution) => {
const profile = reply?.attributes?.profile?.data
const isTeamMember = !!profile?.attributes?.startDate
const isAI = profile?.id === Number(process.env.GATSBY_AI_PROFILE_ID)
return `${isAI ? 'community-profile-ai' : isTeamMember ? 'community-profile-mod' : 'community-profile-member'}${
isResolution ? ' community-reply-resolution' : ''
}`
}

const Expanded = ({ replies }: ExpandedProps) => {
const {
question: {
profile: {
data: { id: questionProfileID },
},
resolvedBy,
},
} = useContext(CurrentQuestionContext)

return (
<>
{replies.data.map((reply) => {
const badgeText = getBadge(questionProfileID, reply?.attributes?.profile?.data?.id)

return (
<li
key={reply.id}
className={`pr-[5px] pl-[30px] !mb-0 border-l border-solid border-light dark:border-dark squeak-left-border relative before:border-l-0`}
className={`pr-[5px] pl-[30px] !mb-0 border-l border-solid border-light dark:border-dark squeak-left-border relative before:border-l-0 ${getComunityClasses(
reply,
resolvedBy?.data?.id === reply.id
)}`}
>
<Reply reply={reply} badgeText={badgeText} />
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Squeak/hooks/useQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const query = (id: string | number, isModerator: boolean) =>
sort: ['createdAt:asc'],
populate: {
profile: {
fields: ['id', 'firstName', 'lastName', 'gravatarURL', 'pronouns', 'color'],
fields: ['id', 'firstName', 'lastName', 'gravatarURL', 'pronouns', 'color', 'startDate'],
populate: {
avatar: {
fields: ['id', 'url'],
Expand Down

0 comments on commit 4698799

Please sign in to comment.