Merge branch 'FE/ExistingID' into 'frontend'
[Front-End] feat: 회원가입 existingId, existingEmail 처리 추가 See merge request s11-webmobile1-sub2/S11P12A701!79
This commit is contained in:
commit
ed92096688
@ -16,6 +16,7 @@ export default function LectureLayout() {
|
||||
const { lectureDelete } = useLectureDelete();
|
||||
const { data } = useLectureInfo(lectureId);
|
||||
const lecture = data?.data;
|
||||
console.log(lecture);
|
||||
const userType = useBoundStore((state) => state.userType);
|
||||
const handleDelete = async () => {
|
||||
await lectureDelete(lectureId);
|
||||
@ -36,8 +37,7 @@ export default function LectureLayout() {
|
||||
title={lecture.title}
|
||||
tutor={lecture.teacherName}
|
||||
img={lecture.image}
|
||||
// TODO: isLive를 받아올 수단 추가
|
||||
isLive={true}
|
||||
isLive={lecture.online}
|
||||
/>
|
||||
<MaxWidthLayout hasSideBar>
|
||||
<aside>
|
||||
|
@ -31,7 +31,7 @@ export function useAuth() {
|
||||
});
|
||||
};
|
||||
|
||||
const userRegister = (role, userId, name, email, password, onError = () => {}) => {
|
||||
const userRegister = (role, userId, name, email, password) => {
|
||||
const userData = {
|
||||
role,
|
||||
userId,
|
||||
@ -39,9 +39,7 @@ export function useAuth() {
|
||||
email,
|
||||
password,
|
||||
};
|
||||
return instance.post(`${API_URL}/user/join`, userData).catch((e) => {
|
||||
onError(e);
|
||||
});
|
||||
return instance.post(`${API_URL}/user/join`, userData);
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
@ -15,13 +15,16 @@ export default function UserRegisterPage() {
|
||||
|
||||
const [userType, setUserType] = useState('STUDENT');
|
||||
const [passwordMatch, setPasswordMatch] = useState(true);
|
||||
const [existingId, setExistingId] = useState(false);
|
||||
const [existingEmail, setExistingEmail] = useState(false);
|
||||
|
||||
const { userRegister } = useAuth();
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
const isPWMatch = passwordRef.current.value === passwordConfirmRef.current.value;
|
||||
|
||||
setExistingId(false);
|
||||
setExistingEmail(false);
|
||||
setPasswordMatch(isPWMatch);
|
||||
if (!isPWMatch) {
|
||||
return;
|
||||
@ -32,10 +35,18 @@ export default function UserRegisterPage() {
|
||||
nameRef.current.value,
|
||||
emailRef.current.value,
|
||||
passwordRef.current.value
|
||||
).then((response) => {
|
||||
console.log(response);
|
||||
navigate('../login');
|
||||
});
|
||||
)
|
||||
.then(() => {
|
||||
navigate('../login');
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.response.data === '아이디가 중복 됐습니다.') {
|
||||
setExistingId(true);
|
||||
}
|
||||
if (err.response.data === '이메일이 중복 됐습니다.') {
|
||||
setExistingEmail(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const linkProps = {
|
||||
@ -73,7 +84,12 @@ export default function UserRegisterPage() {
|
||||
type="text"
|
||||
id="ID"
|
||||
ref={idRef}
|
||||
/>
|
||||
hasError={existingId}
|
||||
>
|
||||
{existingId && (
|
||||
<div className={`${styles.textBodyStrong} ${styles.dangerColor}`}>이미 존재하는 아이디입니다</div>
|
||||
)}
|
||||
</InputBox>
|
||||
<InputBox
|
||||
title="이름"
|
||||
type="text"
|
||||
@ -85,7 +101,12 @@ export default function UserRegisterPage() {
|
||||
type="email"
|
||||
id="email"
|
||||
ref={emailRef}
|
||||
/>
|
||||
hasError={existingEmail}
|
||||
>
|
||||
{existingEmail && (
|
||||
<div className={`${styles.textBodyStrong} ${styles.dangerColor}`}>이미 등록된 이메일입니다</div>
|
||||
)}
|
||||
</InputBox>
|
||||
<InputBox
|
||||
title="비밀번호"
|
||||
type="password"
|
||||
|
Loading…
Reference in New Issue
Block a user