-
Notifications
You must be signed in to change notification settings - Fork 0
[#1] 오류제보, 정답제보 탭 순차적 렌더링 구현 #10
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { useState } from "react"; | ||
|
||
export default function ErrorReport() { | ||
const [submitted, setSubmitted] = useState(false); | ||
const [errorCategory, setErrorCategory] = useState(-1); | ||
const [questionName, setQuestionName] = useState(""); | ||
const [detailInput, setDetailInput] = useState(""); | ||
|
||
return submitted ? ( | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. div 대신 용어를 담은 StyledComponent를 사용하면 해당 페이지의 구조를 더 파악하기 쉬울 것 같아요! |
||
<p>제보해주셔서 감사합니다.</p> | ||
<button | ||
onClick={() => { | ||
setSubmitted(false); | ||
setErrorCategory(-1); | ||
setQuestionName(""); | ||
setDetailInput(""); | ||
}} | ||
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이런 로직이 onClick 다이렉트로 적어 놓는 것이 아니라 |
||
> | ||
다른 오류 제보 | ||
</button> | ||
</div> | ||
) : ( | ||
<div> | ||
<div> | ||
<span>오류 유형: </span> | ||
<input | ||
type="radio" | ||
id="errorCategory0" | ||
name="errorCategory" | ||
onClick={() => setErrorCategory(0)} | ||
/> | ||
<label htmlFor="errorCategory0">정답 통과가 안돼요</label> | ||
<input | ||
type="radio" | ||
id="errorCategory1" | ||
name="errorCategory" | ||
onClick={() => setErrorCategory(1)} | ||
/> | ||
<label htmlFor="errorCategory1">코드 복사가 안돼요</label> | ||
<input | ||
type="radio" | ||
id="errorCategory2" | ||
name="errorCategory" | ||
onClick={() => setErrorCategory(2)} | ||
/> | ||
<label htmlFor="errorCategory2">기타</label> | ||
</div> | ||
|
||
{errorCategory === -1 || errorCategory === 1 ? null : ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 순차적 렌더링을 위해 분기가 많이 생길 수 밖에 없는데요! 이러한 부분도 handleClick을 분리 했던 것 처럼 로직을 return 외부로 분리 시키면 좋을 것 같아요. 예를 들면 |
||
<div> | ||
<span>문제 이름:</span> | ||
<input | ||
list="questionName" | ||
name="question" | ||
onInput={(e) => setQuestionName(e.target.value)} | ||
defaultValue={questionName} | ||
/> | ||
<datalist id="questionName"> | ||
<option value="1번문제" /> | ||
<option value="2번문제" /> | ||
<option value="3번문제" /> | ||
</datalist> | ||
</div> | ||
)} | ||
|
||
{errorCategory === -1 || (errorCategory === 0 && questionName === "") ? null : ( | ||
<> | ||
<div> | ||
<span>내용: </span> | ||
<textarea | ||
rows="20" | ||
cols="100" | ||
onInput={(e) => setDetailInput(e.target.value)} | ||
defaultValue={detailInput} | ||
></textarea> | ||
</div> | ||
<div> | ||
<button | ||
id="submitBtn" | ||
disabled={errorCategory === 2 && detailInput === ""} | ||
onClick={() => setSubmitted(true)} | ||
> | ||
제출 | ||
</button> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useState } from "react"; | ||
|
||
export default function SolutionReport() { | ||
const [submitted, setSubmitted] = useState(false); | ||
const [questionName, setQuestionName] = useState(""); | ||
const [detailInput, setDetailInput] = useState(""); | ||
|
||
return submitted ? ( | ||
<div> | ||
<p>제보해주셔서 감사합니다.</p> | ||
<button | ||
onClick={() => { | ||
setSubmitted(false); | ||
setQuestionName(""); | ||
setDetailInput(""); | ||
}} | ||
> | ||
다른 정답 제보 | ||
</button> | ||
</div> | ||
) : ( | ||
<div> | ||
<div> | ||
<span>문제 이름:</span> | ||
<input | ||
list="questionName" | ||
name="question" | ||
onInput={(e) => setQuestionName(e.target.value)} | ||
defaultValue={questionName} | ||
/> | ||
<datalist id="questionName"> | ||
<option value="1번문제" /> | ||
<option value="2번문제" /> | ||
<option value="3번문제" /> | ||
</datalist> | ||
</div> | ||
|
||
{questionName === "" ? null : ( | ||
<> | ||
<div className="gitHubLogin"> | ||
<span>기여자 등록: </span> | ||
<button id="gitHubLoginBtn">GitHub 로그인</button> | ||
</div> | ||
<div> | ||
<span>내용: </span> | ||
<textarea | ||
rows="20" | ||
cols="100" | ||
onInput={(e) => setDetailInput(e.target.value)} | ||
defaultValue={detailInput} | ||
></textarea> | ||
</div> | ||
<div> | ||
<button id="submitBtn" disabled={detailInput === ""} onClick={() => setSubmitted(true)}> | ||
제출 | ||
</button> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { atom } from "recoil"; | ||
|
||
export const tabNoState = atom({ | ||
key: "tabNoState", | ||
default: 0, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
숫자가 아닌 실제 옵션 명으로 state가 정의 되어있으면 좋을 것 같아요. 숫자로 어떤 선택지인지 파악하기가 어렵습니다!