Skip to content

Commit 0ba7f42

Browse files
authored
Merge pull request #132 from codeit-sprint-part3-6team/#122_페이지_회원가입
#122 페이지 회원가입
2 parents 854a28b + adf8f04 commit 0ba7f42

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

src/components/common/modal/general/GeneralModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ export default function GeneralModal({
6262
{cancelTitle}
6363
</CDSButton>
6464
<span style={{ margin: '0 5px' }} />
65-
<CDSButton btnType="modal_colored" onClick={handleAdaptClick}>
65+
<CDSButton
66+
btnType="modal_colored"
67+
onClick={handleAdaptClick}
68+
disabled={inputValue === ''}
69+
>
6670
{adaptTitle}
6771
</CDSButton>
6872
</div>

src/components/common/navbar/Navbar.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function Navbar() {
3434

3535
const isMyDashboard = pathname !== '/mydashboard';
3636
const isMyPage = pathname !== '/mypage';
37-
const isEdit = pathname !== '/edit';
37+
const isEdit = pathname !== '/dashboard/[id]/edit';
3838

3939
useEffect(() => {
4040
setClientUser(user);
@@ -78,12 +78,14 @@ function Navbar() {
7878
};
7979

8080
const handleDropdownClick = (value: string) => {
81-
if (value === 'mypage') {
82-
router.push('/mypage');
83-
} else if (value === 'logout') {
81+
if (value === 'logout') {
8482
localStorage.removeItem('accessToken');
8583
sessionStorage.removeItem('accessToken');
8684
router.push('/');
85+
} else if (value === 'mypage') {
86+
router.push('/mypage');
87+
} else if (value === 'mydashboard') {
88+
router.push('/mydashboard');
8789
}
8890
};
8991

@@ -162,8 +164,9 @@ function Navbar() {
162164
<Dropdown
163165
onMenuClick={handleDropdownClick}
164166
menus={[
165-
{ label: '마이페이지', value: 'mypage' },
166167
{ label: '로그아웃', value: 'logout' },
168+
{ label: '내 정보', value: 'mypage' },
169+
{ label: '내 대시보드', value: 'mydashboard' },
167170
]}
168171
>
169172
{clientUser && (

src/components/product/auth/SigninForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';
55
import { setUserInfo } from '@/redux/settingSlice';
66
import { AppDispatch } from '@/redux/store';
77
import { postSignin } from '@/lib/signin/postSignin';
8-
import { ERROR_MESSAGE, PLACEHOLDER } from '@/constants/messages';
8+
import { ERROR_MESSAGE, LABEL, PLACEHOLDER } from '@/constants/messages';
99
import { emailValidation, passwordValidation } from '@/utils/authValidation';
1010
import AuthInput from '@/components/common/input/auth-input/AuthInput';
1111
import CDSButton from '@/components/common/button/CDSButton';
@@ -126,7 +126,7 @@ function SigninForm() {
126126
name="login"
127127
id="login"
128128
htmlFor="login"
129-
text="로그인 상태 유지"
129+
text={LABEL.KEEP_LOGIN}
130130
onChange={() => setIsChecked(!isChecked)}
131131
/>
132132

src/components/product/auth/SignupForm.tsx

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styles from './SigninForm.module.css';
2-
import { ChangeEvent, FocusEvent, FormEvent, useEffect, useState } from 'react';
2+
import { ChangeEvent, FocusEvent, FormEvent, useState } from 'react';
33
import { useRouter } from 'next/router';
44
import { useDispatch } from 'react-redux';
55
import { setUserInfo } from '@/redux/settingSlice';
@@ -32,36 +32,18 @@ function SignupForm() {
3232
const [passwordValid, setPasswordValid] = useState(false);
3333
const [nicknameValid, setNicknameValid] = useState(false);
3434
const [passwordCheckValid, setPasswordCheckValid] = useState(false);
35-
const [disabled, setDisabled] = useState(true);
3635
const [isModalVisible, setIsModalVisible] = useState(false);
3736
const [responseMessage, setResponseMessage] = useState('');
3837
const router = useRouter();
3938
const dispatch = useDispatch<AppDispatch>();
4039

41-
useEffect(() => {
42-
const isEmailValid = emailValidation(values.email);
43-
const isPasswordValid = passwordValidation(values.password);
44-
const isNicknameValid = nicknameValidation(values.nickname);
45-
const isPasswordCheckValid = passwordCheckValidation(
46-
values.password,
47-
values.passwordCheck,
48-
);
49-
setDisabled(
50-
!(
51-
isEmailValid &&
52-
isPasswordValid &&
53-
!isNicknameValid &&
54-
!isPasswordCheckValid &&
55-
values.checkbox
56-
),
57-
);
58-
}, [values]);
59-
60-
useEffect(() => {
61-
if (sessionStorage.getItem('accessToken')) {
62-
router.push('/mydashboard');
63-
}
64-
}, []);
40+
const isEmailValid = emailValidation(values.email);
41+
const isPasswordValid = passwordValidation(values.password);
42+
const isNicknameValid = nicknameValidation(values.nickname);
43+
const isPasswordCheckValid = passwordCheckValidation(
44+
values.password,
45+
values.passwordCheck,
46+
);
6547

6648
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
6749
const { name, type, value, checked } = e.target;
@@ -102,19 +84,14 @@ function SignupForm() {
10284
user: response.user,
10385
}),
10486
);
105-
87+
alert(`${values.nickname}님 가입이 완료되었습니다.`);
10688
router.push('/mydashboard');
10789
} catch (error) {
10890
setResponseMessage(error.message);
10991
setIsModalVisible(true);
11092
}
11193
};
11294

113-
const handleCancelClick = () => {
114-
setIsModalVisible(false);
115-
setResponseMessage(null);
116-
};
117-
11895
return (
11996
<>
12097
<form onSubmit={onSubmit}>
@@ -187,7 +164,19 @@ function SignupForm() {
187164
/>
188165

189166
<div className={styles['login-button']}>
190-
<CDSButton btnType="auth" type="submit" disabled={disabled}>
167+
<CDSButton
168+
btnType="auth"
169+
type="submit"
170+
disabled={
171+
!(
172+
isEmailValid &&
173+
isPasswordValid &&
174+
!isNicknameValid &&
175+
!isPasswordCheckValid &&
176+
values.checkbox
177+
)
178+
}
179+
>
191180
가입하기
192181
</CDSButton>
193182
</div>
@@ -196,7 +185,10 @@ function SignupForm() {
196185
{isModalVisible && (
197186
<AuthModal
198187
message={responseMessage}
199-
handleCancelClick={handleCancelClick}
188+
handleCancelClick={() => {
189+
setIsModalVisible(false);
190+
setResponseMessage(null);
191+
}}
200192
/>
201193
)}
202194
</>

src/constants/messages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ export const PLACEHOLDER = {
1313
PASSWORD_CONFIRM_PLACEHOLDER: '비밀번호를 한번 더 입력해 주세요',
1414
TERMS_PLACEHOLDER: '이용약관에 동의해 주세요',
1515
};
16+
17+
export const LABEL = {
18+
KEEP_LOGIN: '로그인 상태 유지',
19+
};

0 commit comments

Comments
 (0)