diff --git a/src/components/common/CheckBox/CheckBox.tsx b/src/components/common/CheckBox/CheckBox.tsx index 07fa4811..ffe7065b 100644 --- a/src/components/common/CheckBox/CheckBox.tsx +++ b/src/components/common/CheckBox/CheckBox.tsx @@ -5,19 +5,22 @@ import styles from "./CheckBox.module.css"; interface CheckBoxProps { label: string; + checked?: boolean; + onChange?: (checked: boolean) => void; } -export const CheckBox: React.FC = ({ label }) => { - const [checked, setChecked] = useState(false); +export const CheckBox: React.FC = ({ label, checked = false, onChange }) => { + const [isChecked, setChecked] = useState(checked); const handleClick = () => { - setChecked(!checked); + setChecked(!isChecked); + onChange?.(!isChecked); }; return (
(null); const [selectedDepartment, setSelectedDepartment] = useState(null); + //const [selectedSignupSource, setSelectedSignupSource] = useState(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 (
- Logo - -

회원 정보 입력

- - - - - - - {selectedMemberType === "학생" && ( - <> +
+ Logo + +

회원 정보 입력

+ + handleChange("name", e.target.value)} + /> + handleChange("phoneNumber", e.target.value)} + /> + handleChange("email", e.target.value)} + /> +
+ + + {selectedMemberType === "학생" && ( + <> + +
+ + setFormData((prevState) => ({ + ...prevState, + studentInfo: { ...prevState.studentInfo, studentNumber: e.target.value }, + })) + } + /> + + handleChange("signUpSource", value)} + /> + + )} + + {(selectedMemberType === "교수/교직원" || selectedMemberType === "기업관계자") && ( + <> + handleChange("division", e.target.value)} + /> + handleChange("position", e.target.value)} + /> +
+ handleChange("signUpSource", value)} + /> + + )} + + {selectedMemberType === "외부인" && ( handleChange("signUpSource", value)} /> - - - - )} - - {(selectedMemberType === "교수/교직원" || selectedMemberType === "기업관계자") && ( - <> - - - - - )} - - {selectedMemberType === "외부인" && ( - - )} + )} - - - 회원가입 +
+
+ +
+
+ +
+
+
+ 회원가입 +
); } diff --git a/src/components/common/SearchInput/SearchInput.tsx b/src/components/common/SearchInput/SearchInput.tsx index 6183d1ea..e28862dc 100644 --- a/src/components/common/SearchInput/SearchInput.tsx +++ b/src/components/common/SearchInput/SearchInput.tsx @@ -6,11 +6,13 @@ export function SearchInput({ placeholder, iconSize = 16, onChange, + value, ...props }: InputProps & { placeholder?: string; iconSize?: number; onChange?: (event: React.ChangeEvent) => void; + value?: string; }) { return ( <> @@ -22,6 +24,7 @@ export function SearchInput({ placeholder={placeholder} leftSection={} onChange={onChange} + value={value} {...props} />