Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment에 choice 추가해서 선택지 반영 #222

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading