-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat] 회원가입 페이지 구현 완료 #105
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,85 +4,217 @@ import { Dropdown } from "@/components/common/Dropdown/Dropdown"; | |
import { CheckBox } from "@/components/common/CheckBox/CheckBox"; | ||
import { PrimaryButton } from "@/components/common/Buttons/PrimaryButton/PrimaryButton"; | ||
import classes from "./registerForm.module.css"; | ||
// refresh token 안됨 !! 왜지 ?? | ||
//import { getServerSideToken } from "@/components/common/Auth/getServerSideToken"; | ||
Comment on lines
+7
to
+8
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. 혹시 이 문제는 해결된 건가요? 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. 아 넹 해결되엇습니다 |
||
import { useAuth } from "@/components/common/Auth/AuthProvider"; | ||
import { CommonAxios } from "@/utils/CommonAxios/CommonAxios"; | ||
|
||
const MEMBER_TYPES = ["학생", "교수/교직원", "기업관계자", "외부인"]; | ||
|
||
const SIGNUP_SOURCES = ["학과 게시판", "s-top 홍보자료", "학과 카톡방", "지인 소개", "기타"]; | ||
export function RegisterForm() { | ||
const [formData, setFormData] = useState({ | ||
name: "", | ||
phoneNumber: "", | ||
userType: "", | ||
email: "", | ||
signUpSource: "", | ||
studentInfo: { department: "", studentNumber: "" }, | ||
division: null, | ||
position: null, | ||
}); | ||
|
||
const [selectedMemberType, setSelectedMemberType] = useState<string | null>(null); | ||
const [selectedDepartment, setSelectedDepartment] = useState<string | null>(null); | ||
//const [selectedSignupSource, setSelectedSignupSource] = useState<String | null>(null); | ||
|
||
const [acceptedTerms, setAcceptedTerms] = useState(false); | ||
const [acceptedPrivacy, setAcceptedPrivacy] = useState(false); | ||
|
||
const { token } = useAuth(); | ||
|
||
const handleTermsChange = () => { | ||
setAcceptedTerms(!acceptedTerms); | ||
}; | ||
|
||
const handlePrivacyChange = () => { | ||
setAcceptedPrivacy(!acceptedPrivacy); | ||
}; | ||
|
||
const handleChange = (field: string, value: any) => { | ||
setFormData((prevState) => ({ | ||
...prevState, | ||
[field]: value, | ||
})); | ||
}; | ||
|
||
const handleMemberTypeChange = (type: string) => { | ||
setSelectedMemberType(type); | ||
setSelectedDepartment(null); // Reset department when member type changes | ||
setFormData((prevState) => ({ | ||
...prevState, | ||
userType: | ||
type === "학생" | ||
? "STUDENT" | ||
: type === "교수/교직원" | ||
? "FACULTY" | ||
: type === "기업관계자" | ||
? "COMPANY_REP" | ||
: "EXTERNAL", | ||
})); | ||
setSelectedDepartment(null); | ||
}; | ||
|
||
const handleDepartmentChange = (department: string) => { | ||
setSelectedDepartment(department); | ||
setFormData((prevState) => ({ | ||
...prevState, | ||
studentInfo: { ...prevState.studentInfo, department }, | ||
})); | ||
}; | ||
|
||
const handleSubmit = async (e: React.FormEvent) => { | ||
e.preventDefault(); | ||
|
||
if (!acceptedTerms || !acceptedPrivacy) { | ||
alert("서비스 이용약관과 개인정보 처리 방침에 동의해주세요"); | ||
return; | ||
} | ||
|
||
try { | ||
//const { accessToken, refreshToken } = await getServerSideToken() | ||
|
||
const config = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
withCredentials: true, | ||
}; | ||
|
||
const response = await CommonAxios.post( | ||
"http://localhost:8000/auth/register", | ||
formData, | ||
config | ||
); | ||
|
||
console.log("Registration Successful: ", response.data); | ||
} catch (error) { | ||
console.error("Error registering: ", error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={classes.registerBox}> | ||
<img src="/images/S-TopLogo.png" alt="Logo" className={classes.logo} /> | ||
|
||
<h1>회원 정보 입력</h1> | ||
|
||
<TextInput className={classes.text} label="이름" placeholder="이름을 입력하세요" required /> | ||
<TextInput | ||
className={classes.text} | ||
label="휴대전화" | ||
placeholder="휴대전화 번호를 입력하세요" | ||
required | ||
/> | ||
|
||
<Dropdown | ||
options={MEMBER_TYPES} | ||
placeholder="회원 유형을 선택하세요" | ||
selectedOption={selectedMemberType} | ||
onOptionClick={handleMemberTypeChange} | ||
/> | ||
|
||
{selectedMemberType === "학생" && ( | ||
<> | ||
<form onSubmit={handleSubmit} className={classes.form}> | ||
<img src="/images/S-TopLogo.png" alt="Logo" className={classes.logo} /> | ||
|
||
<h1>회원 정보 입력</h1> | ||
|
||
<TextInput | ||
className={classes.text} | ||
label="이름" | ||
placeholder="이름을 입력하세요" | ||
required | ||
onChange={(e) => handleChange("name", e.target.value)} | ||
/> | ||
<TextInput | ||
className={classes.text} | ||
label="휴대전화" | ||
placeholder="휴대전화 번호를 입력하세요" | ||
required | ||
onChange={(e) => handleChange("phoneNumber", e.target.value)} | ||
/> | ||
<TextInput | ||
className={classes.text} | ||
label="이메일" | ||
placeholder="이메일 주소를 입력하세요" | ||
required | ||
onChange={(e) => handleChange("email", e.target.value)} | ||
/> | ||
<br /> | ||
<Dropdown | ||
options={MEMBER_TYPES} | ||
placeholder="회원 유형을 선택하세요" | ||
selectedOption={selectedMemberType} | ||
onOptionClick={handleMemberTypeChange} | ||
/> | ||
|
||
{selectedMemberType === "학생" && ( | ||
<> | ||
<Dropdown | ||
options={[ | ||
"컴퓨터공학과", | ||
"소프트웨어학과", | ||
"글로벌 융합학부", | ||
"지능형 소프트웨어학과", | ||
"기타", | ||
]} | ||
placeholder="학과를 선택하세요" | ||
selectedOption={selectedDepartment} | ||
onOptionClick={handleDepartmentChange} | ||
/> | ||
<br /> | ||
<TextInput | ||
className={classes.text} | ||
label="학번" | ||
placeholder="학번을 입력하세요" | ||
onChange={(e) => | ||
setFormData((prevState) => ({ | ||
...prevState, | ||
studentInfo: { ...prevState.studentInfo, studentNumber: e.target.value }, | ||
})) | ||
} | ||
/> | ||
|
||
<Dropdown | ||
options={SIGNUP_SOURCES} | ||
placeholder="가입 경로를 선택하세요" | ||
selectedOption={formData.signUpSource} | ||
onOptionClick={(value) => handleChange("signUpSource", value)} | ||
/> | ||
</> | ||
)} | ||
|
||
{(selectedMemberType === "교수/교직원" || selectedMemberType === "기업관계자") && ( | ||
<> | ||
<TextInput | ||
className={classes.text} | ||
label="소속" | ||
placeholder="소속을 입력하세요" | ||
onChange={(e) => handleChange("division", e.target.value)} | ||
/> | ||
<TextInput | ||
className={classes.text} | ||
label="직책" | ||
placeholder="직책을 입력하세요" | ||
onChange={(e) => handleChange("position", e.target.value)} | ||
/> | ||
<br /> | ||
<Dropdown | ||
options={SIGNUP_SOURCES} | ||
placeholder="가입 경로를 선택하세요" | ||
selectedOption={formData.signUpSource} | ||
onOptionClick={(value) => handleChange("signUpSource", value)} | ||
/> | ||
</> | ||
)} | ||
|
||
{selectedMemberType === "외부인" && ( | ||
<Dropdown | ||
options={[ | ||
"컴퓨터공학과", | ||
"소프트웨어학과", | ||
"글로벌 융합학부", | ||
"지능형 소프트웨어학과", | ||
"기타", | ||
]} | ||
placeholder="학과를 선택하세요" | ||
selectedOption={selectedDepartment} | ||
onOptionClick={handleDepartmentChange} | ||
options={SIGNUP_SOURCES} | ||
placeholder="가입 경로를 선택하세요" | ||
selectedOption={formData.signUpSource} | ||
onOptionClick={(value) => handleChange("signUpSource", value)} | ||
/> | ||
<TextInput className={classes.text} label="학번" placeholder="학번을 입력하세요" /> | ||
<TextInput | ||
className={classes.text} | ||
label="가입경로" | ||
placeholder="가입경로를 입력하세요" | ||
/> | ||
</> | ||
)} | ||
|
||
{(selectedMemberType === "교수/교직원" || selectedMemberType === "기업관계자") && ( | ||
<> | ||
<TextInput className={classes.text} label="소속" placeholder="소속을 입력하세요" /> | ||
<TextInput className={classes.text} label="직책" placeholder="직책을 입력하세요" /> | ||
<TextInput | ||
className={classes.text} | ||
label="가입경로" | ||
placeholder="가입경로를 입력하세요" | ||
/> | ||
</> | ||
)} | ||
|
||
{selectedMemberType === "외부인" && ( | ||
<TextInput className={classes.text} label="가입경로" placeholder="가입경로를 입력하세요" /> | ||
)} | ||
)} | ||
|
||
<CheckBox label="서비스이용약관 (필수)" /> | ||
<CheckBox label="개인정보처리방침 (필수)" /> | ||
<PrimaryButton>회원가입</PrimaryButton> | ||
<br /> | ||
<div onClick={handleTermsChange}> | ||
<CheckBox label="서비스이용약관 (필수)" /> | ||
</div> | ||
<div onClick={handlePrivacyChange}> | ||
<CheckBox label="개인정보처리방침 (필수)" /> | ||
</div> | ||
<br /> | ||
<br /> | ||
<PrimaryButton type="submit">회원가입</PrimaryButton> | ||
</form> | ||
</div> | ||
); | ||
} |
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.
여기서 main과 complict 일어날 수도 있을 것 같아서 기능에 지장이 없다면 버전은 유지해주시면 좋겠습니다!
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.
파일삭제하겟습니다