Skip to content

Commit

Permalink
[Fix]- 충돌 에러 픽스
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaem03 committed Nov 15, 2024
2 parents ccd7d4f + f2b5ceb commit 8e378f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/components/testQuestion/TestQuestion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export const TestQuestion = ({
handleAnswerSelect,
handleNextQuestion,
TEST_QUESTION,
isAnswerinCorrect, //정답이 맞는지-접속자
isAnswerCorrect, //정답이 맞는지-접속자
isAnswerSelected, //선택되었는지 - 소유자
}) => {
const handleSelect = (index) => {
if (selectedAnswer[currentQuestion] === null) {
handleAnswerSelect(index);
}
};
console.log("isAnswerinCorrect:", isAnswerinCorrect);
console.log("isAnswerinCorrect:", isAnswerCorrect);

return (
<S.Container>
Expand All @@ -30,8 +30,8 @@ export const TestQuestion = ({
key={index}
onClick={() => handleSelect(index)}
$isSelected={selectedAnswer[currentQuestion] === index}
$isAnswerinCorrect={
isAnswerinCorrect && selectedAnswer[currentQuestion] === index
$isAnswerCorrect={
isAnswerCorrect && selectedAnswer[currentQuestion] === index
}
>
{answer}
Expand Down
12 changes: 6 additions & 6 deletions src/components/testQuestion/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ export const AnswerBox = styled.div`
border-radius: 15px;
${({ theme }) => theme.fonts.pretendardB4}
box-shadow: ${({ $isSelected, $isAnswerinCorrect }) =>
box-shadow: ${({ $isSelected, $isAnswerCorrect }) =>
$isSelected
? $isAnswerinCorrect // 정답인지 확인
? $isAnswerCorrect // 정답인지 확인
? "0px 0px 10px 0px rgba(55, 130, 237, 0.50)" //파
: "0px 0px 10px 0px rgba(255, 0, 0, 0.50)" //빨
: "none"};
border: 1px solid
${({ theme, $isSelected, $isAnswerinCorrect }) =>
${({ theme, $isSelected, $isAnswerCorrect }) =>
$isSelected
? $isAnswerinCorrect
? $isAnswerCorrect
? theme.colors.blue300
: theme.colors.red200
: theme.colors.blue300};
background: ${({ theme, $isSelected, $isAnswerinCorrect }) =>
background: ${({ theme, $isSelected, $isAnswerCorrect }) =>
$isSelected
? $isAnswerinCorrect
? $isAnswerCorrect
? theme.colors.blue100
: theme.colors.red100
: theme.colors.gray100};
Expand Down
16 changes: 4 additions & 12 deletions src/pages/nuguTest/ChallengerTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,10 @@ export const ChallengerTest = () => {
const ResulthighlightIndex = result?.findIndex(
(user) => user.id === challengerId
);
console.log("ResulthighlightIndex", ResulthighlightIndex);
console.log(
"selectedAnswer[currentQuestion]",
selectedAnswer[currentQuestion]
);
console.log("rank[currentQuestion]", rank[currentQuestion]);

//정답 비교
const isAnswerinCorrect =
selectedAnswer[currentQuestion] === null
? null
: parseInt(rank[currentQuestion], 10) ===
parseInt(selectedAnswer[currentQuestion], 10)
const isAnswerCorrect =
Number(rank[currentQuestion]) == selectedAnswer[currentQuestion]
? true
: false;

Expand Down Expand Up @@ -96,7 +88,7 @@ export const ChallengerTest = () => {
handleAnswerSelect={handleAnswerSelect}
handleNextQuestion={handleNextQuestion}
TEST_QUESTION={TEST_QUESTION}
isAnswerinCorrect={isAnswerinCorrect}
isAnswerCorrect={isAnswerCorrect}
isAnswerSelected={isAnswerSelected}
/>
)}
Expand Down

0 comments on commit 8e378f7

Please sign in to comment.