-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionReport.js
More file actions
90 lines (78 loc) · 2.25 KB
/
SolutionReport.js
File metadata and controls
90 lines (78 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { useState } from "react";
import GitHubLogin from "./GitHubLogin";
import {
TabWrapper,
BlockText,
Button,
StepByStepInputItem,
InlineText,
TextInput,
DataList,
Option,
TextArea,
} from "./Style/StyledComponent";
export default function SolutionReport() {
const [submitted, setSubmitted] = useState(false);
const [questionName, setQuestionName] = useState("");
const [detailContent, setDetailContent] = useState("");
const isDetailContentUnvisible = questionName === "";
const isSubmitBtnDisabled = detailContent === "";
function handleOtherSolutionBtnClick() {
setSubmitted(false);
setQuestionName("");
setDetailContent("");
}
function handleQuestionNameInput(e) {
setQuestionName(e.target.value);
}
function handleDetailContentInput(e) {
setDetailContent(e.target.value);
}
function handleSubmitBtnClick() {
setSubmitted(true);
}
return submitted ? (
<TabWrapper>
<BlockText>제보해주셔서 감사합니다.</BlockText>
<Button onClick={handleOtherSolutionBtnClick}>다른 정답 제보</Button>
</TabWrapper>
) : (
<TabWrapper>
<StepByStepInputItem>
<InlineText>문제 이름: </InlineText>
<TextInput
list="questionName"
name="question"
onInput={handleQuestionNameInput}
defaultValue={questionName}
/>
<DataList id="questionName">
<Option value="1번문제" />
<Option value="2번문제" />
<Option value="3번문제" />
</DataList>
</StepByStepInputItem>
{isDetailContentUnvisible ? null : (
<>
<StepByStepInputItem>
<GitHubLogin />
</StepByStepInputItem>
<StepByStepInputItem>
<InlineText>내용: </InlineText>
<TextArea
rows="20"
cols="100"
onInput={handleDetailContentInput}
defaultValue={detailContent}
></TextArea>
</StepByStepInputItem>
<StepByStepInputItem>
<Button id="submitBtn" disabled={isSubmitBtnDisabled} onClick={handleSubmitBtnClick}>
제출
</Button>
</StepByStepInputItem>
</>
)}
</TabWrapper>
);
}