Skip to content

Commit

Permalink
comment에 choice 추가해서 선택지 반영 (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinho1011 authored Feb 19, 2024
1 parent 093fdbf commit b1350d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/Home/Comment/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ProfileImg from '@components/commons/ProfileImg/ProfileImg';
import Text from '@components/commons/Text/Text';
import useModal from '@hooks/useModal/useModal';
import { CommentResponse } from '@interfaces/api/comment';
import { Choice } from '@interfaces/api/topic';

import { useAuthStore } from '@store/auth';

Expand All @@ -18,9 +19,10 @@ import Thumbs from './Thumbs';

interface CommentProps {
comment: CommentResponse;
choices: Choice[];
}

const Comment = React.memo(({ comment }: CommentProps) => {
const Comment = React.memo(({ comment, choices }: CommentProps) => {
const { Modal, toggleModal } = useModal('action');
const reactMutation = useReactComment(comment.topicId, comment.commentId);
const memberId = useAuthStore((store) => store.memberId);
Expand Down Expand Up @@ -79,8 +81,12 @@ const Comment = React.memo(({ comment }: CommentProps) => {
{'·'} {distanceText}
</Text>
</Row>
<Text size={14} color={colors.A} weight={600}>
{comment.writersVotedOption}
<Text
size={14}
color={comment.writersVotedOption === 'CHOICE_A' ? colors.A_60 : colors.B_60}
weight={600}
>
{choices[comment.writersVotedOption === 'CHOICE_A' ? 0 : 1].content.text}
</Text>
</Col>
</Row>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Home/TopicComments/TopicComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const TopicComments = memo(({ topic }: TopicCommentsProps) => {
</Row>
</TopicCommentsHeader>
<CommentsContainer>
{comments?.map((comment) => <Comment key={comment.commentId} comment={comment} />)}
{comments?.map((comment) => (
<Comment key={comment.commentId} comment={comment} choices={topic.choices} />
))}
</CommentsContainer>
<CommentInputContainer>
<CommentInput
Expand Down

0 comments on commit b1350d9

Please sign in to comment.