Skip to content

Commit 94d7d27

Browse files
mksoomksoo
authored andcommitted
form 입력 받은거 state에 넣는거까지
1 parent 01514ce commit 94d7d27

File tree

3 files changed

+122
-23
lines changed

3 files changed

+122
-23
lines changed

src/components/common/InputField.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface InputFieldProps {
1010
fullWidth?: boolean;
1111
placeholder?: string;
1212
multiline?: boolean;
13+
onChange: (e: any) => void;
1314
}
1415

1516
const InputField: React.FC<InputFieldProps> = ({
@@ -20,6 +21,7 @@ const InputField: React.FC<InputFieldProps> = ({
2021
fullWidth = true,
2122
placeholder = '',
2223
multiline = false,
24+
onChange,
2325
}) => {
2426
return (
2527
<Box
@@ -37,6 +39,7 @@ const InputField: React.FC<InputFieldProps> = ({
3739
defaultValue={defaultValue}
3840
placeholder={placeholder}
3941
multiline={multiline}
42+
onChange={onChange}
4043
/>
4144
</Box>
4245
);

src/components/common/MultipleChoiceField.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface MultipleChoiceFieldProps {
2525
fullWidth?: boolean;
2626
isMultipleOption?: boolean;
2727
isOtherOption?: boolean;
28+
onChange?: (e: any) => void;
2829
}
2930

3031
const MultipleChoiceField: FC<MultipleChoiceFieldProps> = ({
@@ -35,6 +36,7 @@ const MultipleChoiceField: FC<MultipleChoiceFieldProps> = ({
3536
fullWidth = true,
3637
isMultipleOption = false,
3738
isOtherOption = false,
39+
onChange,
3840
}) => {
3941
const [selectedOptions, setSelectedOptions] = useState<string[]>(
4042
defaultValue ? [defaultValue] : []
@@ -79,7 +81,7 @@ const MultipleChoiceField: FC<MultipleChoiceFieldProps> = ({
7981
control={
8082
<Checkbox
8183
checked={selectedOptions.includes(option.value)}
82-
onChange={handleChange}
84+
onChange={onChange}
8385
value={option.value}
8486
/>
8587
}
@@ -107,14 +109,14 @@ const MultipleChoiceField: FC<MultipleChoiceFieldProps> = ({
107109
<FormControlLabel
108110
key={option.value}
109111
value={option.value}
110-
control={<Radio onChange={handleRadioChange} />}
112+
control={<Radio onChange={onChange} />}
111113
label={option.label}
112114
/>
113115
))}
114116
{isOtherOption && (
115117
<FormControlLabel
116118
value="other"
117-
control={<Radio onChange={handleRadioChange} />}
119+
control={<Radio onChange={onChange} />}
118120
label="기타"
119121
/>
120122
)}

src/modules/Builder/ApplyBuilder.tsx

Lines changed: 114 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,125 @@ import InputField from "../../components/common/InputField";
33
import MultipleChoiceField from "../../components/common/MultipleChoiceField";
44
import PrivacyPolicy from "./component/PrivacyPolicy";
55
import BuilderRules from "./component/BuilderRules";
6+
import { useState } from "react";
67

78
const ApplyBuilder = () => {
9+
const [formData, setFormData] = useState({
10+
email: "",
11+
name: "",
12+
phone: "",
13+
introduceMe: "",
14+
wasBuilder: false,
15+
discordId: "",
16+
notionId: "",
17+
portfolio: "",
18+
role: "",
19+
buildName: "",
20+
buildDescription: "",
21+
buildReason: "",
22+
buildGain: "",
23+
buildResearchMember: "",
24+
expectation: "",
25+
question: "",
26+
availability: "",
27+
isBuilder: true,
28+
ruleAgree: true,
29+
privacyAgree: true,
30+
});
31+
32+
const handleChange = (id: string, value: any) => {
33+
setFormData((prevData) => ({
34+
...prevData,
35+
[id]: value,
36+
}));
37+
};
38+
39+
const handleSubmit = () => {
40+
console.log(formData);
41+
};
42+
843
return (
944
<>
1045
<h1>빌더 지원서</h1>
11-
<InputField id="email" label="이메일" placeholder="이메일" />
12-
<InputField id="name" label="이름" placeholder="이름" />
46+
<InputField
47+
id="email"
48+
label="이메일"
49+
placeholder="이메일"
50+
onChange={(e) => handleChange("email", e.target.value)}
51+
/>
52+
<InputField
53+
id="name"
54+
label="이름"
55+
placeholder="이름"
56+
onChange={(e) => handleChange("name", e.target.value)}
57+
/>
1358
<InputField
1459
id="phone"
1560
label="연락처(000-0000-0000)"
1661
placeholder="연락처"
62+
onChange={(e) => handleChange("phone", e.target.value)}
1763
/>
1864
<InputField
1965
id="introduce-me"
2066
label="3줄 자기소개"
2167
placeholder="3줄 자기소개"
2268
multiline={true}
2369
rows={3}
70+
onChange={(e) => handleChange("introduceMe", e.target.value)}
2471
/>
2572
<MultipleChoiceField
2673
id="was-builder"
2774
label="이전에 빌더로 활동하신 적 있으신가요?"
2875
options={[
29-
{ value: "", label: "yes" },
30-
{ value: "아니오", label: "no" },
76+
{ value: "y", label: "" },
77+
{ value: "n", label: "아니오" },
3178
]}
79+
onChange={(e) => {
80+
handleChange("wasBuilder", (e.target.value === "y" ? true : false));
81+
}}
3282
/>
3383
<InputField
3484
id="discordId"
3585
label="디스코드 ID"
3686
placeholder="디스코드 ID"
87+
onChange={(e) => handleChange("discordId", e.target.value)}
3788
/>
3889
<InputField
3990
id="notionId"
4091
label="노션 ID(이메일 형태; 이메일 주소가 아니면 초대가 어렵습니다."
4192
placeholder="노션 ID"
93+
onChange={(e) => handleChange("notionId", e.target.value)}
4294
/>
4395
<InputField
4496
id="portfolio"
4597
label="자신을 표현할 수 있는 링크를 하나 공유해주세요!"
4698
placeholder="e.g. linkedIn, github, blog, CV 등"
99+
onChange={(e) => handleChange("portfolio", e.target.value)}
47100
/>
48101
<MultipleChoiceField
49102
id="role"
50103
label="지원하고자 하는 역할은 무엇인가요?"
51104
options={[
52-
{ value: "아카데미 빌더", label: "academy" },
53-
{ value: "펠로우십 빌더", label: "fellowship" },
54-
{ value: "커뮤니티 빌더", label: "comminity" },
55-
{ value: "데브 빌더", label: "dev" },
105+
{ value: "academy", label: "acad아카데미 빌더emy" },
106+
{ value: "fellowship", label: "펠로우십 빌더" },
107+
{ value: "community", label: "커뮤니티 빌더" },
108+
{ value: "dev", label: "데브 빌더" },
56109
{
57-
value: "리서치팀으로 전환(1기수 수료 후, 2기수 이상 활동 희망시",
58-
label: "research",
110+
value: "research",
111+
label: "리서치팀으로 전환(1기수 수료 후, 2기수 이상 활동 희망시",
59112
},
60113
]}
114+
onChange={(e) => {
115+
handleChange("role", e.target.value);
116+
}}
61117
/>
62118
<InputField
63119
id="build-name"
64120
label='지원하신 역할로 진행하실 스터디/프로젝트명을 알려주세요. (리서치팀인 경우 팀명과 프로젝트 명을 각각 적어주셍. "팀명/프로젝트명" 형태)'
65121
placeholder=""
122+
onChange={(e) => {
123+
handleChange("buildName", e.target.value);
124+
}}
66125
/>
67126
<InputField
68127
id="build-description"
@@ -73,20 +132,29 @@ const ApplyBuilder = () => {
73132
placeholder=""
74133
multiline={true}
75134
rows={3}
135+
onChange={(e) => {
136+
handleChange("buildDescription", e.target.value);
137+
}}
76138
/>
77139
<InputField
78140
id="build-reason"
79141
label="위의 지원하신 역할과 관련된 경험이 있으시다면, 얘기해주세요! 없으시다면, 지원하신 역할을 하고자하는 이유를 적어주세요."
80142
placeholder=""
81143
multiline={true}
82144
rows={3}
145+
onChange={(e) => {
146+
handleChange("buildReason", e.target.value);
147+
}}
83148
/>
84149
<InputField
85150
id="build-gain"
86151
label="빌더 활동을 통해 얻고 싶은 것이 무엇인가요?"
87152
placeholder=""
88153
multiline={true}
89154
rows={3}
155+
onChange={(e) => {
156+
handleChange("buildGain", e.target.value);
157+
}}
90158
/>
91159
<InputField
92160
id="build-research-member"
@@ -95,23 +163,32 @@ const ApplyBuilder = () => {
95163
placeholder=""
96164
multiline={true}
97165
rows={3}
166+
onChange={(e) => {
167+
handleChange("buildResearchMember", e.target.value);
168+
}}
98169
/>
99170
<InputField
100171
id="expectation"
101172
label="여러분들이 가짜연구소 커뮤니티에 가장 기대하는 것은 무엇인가요?"
102173
placeholder=""
103174
multiline={true}
104175
rows={3}
176+
onChange={(e) => {
177+
handleChange("expectation", e.target.value);
178+
}}
105179
/>
106180
<InputField
107181
id="question"
108182
label="가짜연구소에 궁금한 점이 있으신가요?"
109183
placeholder=""
110184
multiline={true}
111185
rows={3}
186+
onChange={(e) => {
187+
handleChange("question", e.target.value);
188+
}}
112189
/>
113190
<MultipleChoiceField
114-
id=""
191+
id="availability"
115192
label="가짜연구소의 대부분의 모임 및 활동들은 주 1회 이루어집니다. 2024년 상반기에 주 1회 모임을 이끄시거나 참여하시는 것이 가능하신지 생각해봐주세요!"
116193
options={[
117194
{
@@ -129,14 +206,20 @@ const ApplyBuilder = () => {
129206
},
130207
]}
131208
isOtherOption={true}
209+
onChange={(e) => {
210+
handleChange("availability", e.target.value);
211+
}}
132212
/>
133213
<MultipleChoiceField
134214
id="is-builder"
135215
label='본 신청은 스터디나 일반 참가자가 아닌 "운영진"을 신청하는 것임을 확인하셨나요?'
136216
options={[
137-
{ value: "예", label: "yes" },
138-
{ value: "아니오", label: "no" },
139-
]}
217+
{ value: "y", label: "예" },
218+
{ value: "n", label: "아니오" },
219+
]}
220+
onChange={(e) => {
221+
handleChange("wasBuilder", (e.target.value === "y" ? true : false));
222+
}}
140223
/>
141224
<Box
142225
sx={{
@@ -156,17 +239,23 @@ const ApplyBuilder = () => {
156239
id="rule-agree"
157240
label="위의 규칙에 동의하십니까?"
158241
options={[
159-
{ value: "", label: "yes" },
160-
{ value: "아니오", label: "no" },
242+
{ value: "y", label: "" },
243+
{ value: "n", label: "아니오" },
161244
]}
245+
onChange={(e) => {
246+
handleChange("wasBuilder", (e.target.value === "y" ? true : false));
247+
}}
162248
/>
163249
<MultipleChoiceField
164250
id="privacy-agree"
165251
label="아래 개인정보 처리방침에 동의하십니까?"
166252
options={[
167-
{ value: "예", label: "yes" },
168-
{ value: "아니오", label: "no" },
169-
]}
253+
{ value: "y", label: "예" },
254+
{ value: "n", label: "아니오" },
255+
]}
256+
onChange={(e) => {
257+
handleChange("wasBuilder", (e.target.value === "y" ? true : false));
258+
}}
170259
/>
171260

172261
<Box
@@ -183,7 +272,12 @@ const ApplyBuilder = () => {
183272
>
184273
<PrivacyPolicy />
185274
</Box>
186-
<Button fullWidth={true} variant="contained" color="primary">
275+
<Button
276+
fullWidth={true}
277+
variant="contained"
278+
color="primary"
279+
onClick={handleSubmit}
280+
>
187281
제출하기
188282
</Button>
189283
</>

0 commit comments

Comments
 (0)