Skip to content

Commit

Permalink
Upt. 오류 수정 및 메타 데이터 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jee-eun-k committed Jul 17, 2023
1 parent 2abed05 commit 34317c1
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 93 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="ddok-ddak"
/>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
Expand Down
8 changes: 3 additions & 5 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ export const checkDuplicatedNickname = async (nickname: string) => {

/**
* user sign up
* @param nickname
* @param request: UserData
* @returns response
*/
export const addUser = async (userData: UserData) => {
export const addUser = async (request: UserData) => {
const response = await callAPI({
url: '/api/v1/auth/signup',
method: 'POST',
params: {
userData
}
body: request,
});

return response as CommonResponse;
Expand Down
15 changes: 4 additions & 11 deletions src/hooks/signUpSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ export function useSignUpStepForm(steps: ReactElement[]) {
* handle next button
*/
function handleNextButton() {
setCurrentStepIndex(i => {
if (i < steps.length - 1) {
return i + 1;
} else {
return i;
}
});

const currIdx = currentStepIndex;
setCurrentStepIndex(() => (currIdx < steps.length - 1) ? (currIdx + 1) : currIdx);
}

/**
* handle prev button
*/
function handlePrevButton() {
setCurrentStepIndex(i => {
return (i <= 0) ? i : i - 1;
});
const currIdx = currentStepIndex;
setCurrentStepIndex(() => (currIdx <= 0) ? currIdx : currIdx - 1);
}

return {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/auth/InputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type InputItemType = {
duplicateCheckerHandler?: () => {},
verifyCodeRequestButton?: ReactJSXElement,
verifyCodeRequestHandler?: () => void,
onChangeHandler?: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => Promise<true | undefined> | void | boolean,
onChangeHandler?: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => Promise<true | undefined | void> | void,
type?: string,
value?: string
}
Expand All @@ -43,6 +43,7 @@ const InputForm = ({itemArray, disableDuplicateChkBtn, helper, isHelperError, va
onChange={item.onChangeHandler}
type={item.type}
value={value}
autoComplete='off'
/>
<FormHelperText
sx={{color: 'green'}}
Expand Down
32 changes: 16 additions & 16 deletions src/pages/auth/SetEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ const SetEmail = (props: any) => {
{
name: '이메일',
placeholder: '이메일 주소를 입력해주세요.',
duplicateCheckerButton:
(<InputAdornment
position="end"
onClick={duplicateCheckerHandler}
>
<Button
sx={{
color: '#FF8999',
fontSize: '13px',
fontWeight: '400'
}}
disabled={disableDuplicateChkBtn}
>
{'중복확인'}
</Button>
</InputAdornment>),
duplicateCheckerButton:(
<InputAdornment position="end">
<Button
onClick={duplicateCheckerHandler}
disabled={disableDuplicateChkBtn}
sx={{
color: '#FF8999',
fontSize: '13px',
fontWeight: '400'
}}
>
{'중복확인'}
</Button>
</InputAdornment>
),
onChangeHandler,
type: 'email'
},
];

useEffect(() => {
setDisableDuplicateChkBtn(true);
setSignUpStepInstruction('이메일을 입력해주세요.');
setSignUpNextButtonProps({
...signUpNextButtonProps,
Expand Down
25 changes: 12 additions & 13 deletions src/pages/auth/SetNickname.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@ const SetNickname = (props: any) => {
placeholder: '영어, 숫자, _, -를 사용한 2 ~ 15자리 이내',
onChangeHandler: async (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
const value = event.target.value;
setNickname(value);

setNickname(() => value);
const reg = /^[a-zA-Z0-9_-]{2,15}$/g;
let isNotAvail = true;
if (!reg.test(value)) {
setHelper('영어, 숫자, _, - 를 사용한 2 ~ 15자리 이내로 입력해주세요.');
setIsHelperError(true);
setIsNextButtonDisabled(true);
return true;
setIsHelperError(isNotAvail);
setIsNextButtonDisabled(isNotAvail);
} else {
await checkDuplicatedNickname(value).then((response) => {
let isAvail = false;
if (response.status === 'SUCCESS') {
isNotAvail = false;
setHelper('사용 가능한 닉네임입니다.');
setIsNextButtonDisabled(isAvail);
setSignUpData({...signUpData, nickname: value});
} else {
isAvail = true;
setHelper('이미 사용하고 있는 닉네임입니다.');
}
setIsHelperError(isAvail);
setIsNextButtonDisabled(isNotAvail);
setIsHelperError(isNotAvail);
setSignUpNextButtonProps({
...signUpNextButtonProps,
isDisabled: isAvail,
isDisabled: isNotAvail,
});
});
}
Expand All @@ -59,7 +58,8 @@ const SetNickname = (props: any) => {
text: '회원가입 완료',
isDisabled: true,
clickHandler: async () => {
await addUser(signUpData).then((response) => {
const userData = signUpData;
await addUser(userData).then((response) => {
if (response.status === 'SUCCESS') {
alert('회원 가입 성공')
} else {
Expand All @@ -68,9 +68,8 @@ const SetNickname = (props: any) => {
});
},
});
}, []);
}, [nickname]);


return (
<FormWrapper>
<InputForm
Expand Down
29 changes: 15 additions & 14 deletions src/pages/auth/SetPW.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const SetPW = (props: any) => {
...signUpNextButtonProps,
isDisabled: isMatch,
});

};

// password items
Expand Down Expand Up @@ -91,19 +90,21 @@ const SetPW = (props: any) => {

return (
<FormWrapper>
<InputForm
key="password1"
itemArray={itemArray1}
helper={helper1}
isHelperError={isHelperError1}
value={password}
/>
<InputForm
key="password2"
itemArray={itemArray2}
helper={helper2}
isHelperError={isHelperError2}
/>
<form>
<InputForm
key="password1"
itemArray={itemArray1}
helper={helper1}
isHelperError={isHelperError1}
value={password}
/>
<InputForm
key="password2"
itemArray={itemArray2}
helper={helper2}
isHelperError={isHelperError2}
/>
</form>
</FormWrapper>
);
};
Expand Down
62 changes: 31 additions & 31 deletions src/pages/auth/VerifyCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,41 @@ const VerifyCode = (props: any) => {
</InputAdornment>),
verifyCodeRequestButton:
(<Button
onClick={() => {
const requestCount = requestCodeCount;
if (requestCount < 5) {
setRequestCodeCount(requestCount + 1);
// TODO: check verification code
} else {
setModalInfo({
open: true,
title: '인증 요청 제한 횟수(5회)를 초과했습니다. 다른 이메일로 시도하시겠습니까? ',
msg: '그렇지 않은 경우 해당 이메일로는 24시간 후에 시도할 수 있습니다.',
btn1Text: '아니오',
btn1ClickHandler: () => {
setModalInfo({ ...modalInfo, open: false });
},
btn2Text: '네',
btn2ClickHandler: () => {
setModalInfo({ ...modalInfo, open: false });
setCurrentStepIndex(currentStepIndex - 1);
}
})
}
}}
sx={{
height: '29px',
width: '110px',
margin: '16px 0 8px 10px',
justifyContent: 'center',
radius: '5px',
backgroundColor: '#E8E8E8',
}}
onClick={() => {
const requestCount = requestCodeCount;
if (requestCount < 5) {
setRequestCodeCount(requestCount + 1);
// TODO: check verification code
} else {
setModalInfo({
open: true,
title: '인증 요청 제한 횟수(5회)를 초과했습니다. 다른 이메일로 시도하시겠습니까? ',
msg: '그렇지 않은 경우 해당 이메일로는 24시간 후에 시도할 수 있습니다.',
btn1Text: '아니오',
btn1ClickHandler: () => {
setModalInfo({ ...modalInfo, open: false });
},
btn2Text: '네',
btn2ClickHandler: () => {
setModalInfo({ ...modalInfo, open: false });
setCurrentStepIndex(currentStepIndex - 1);
}
})
}
}}
sx={{
height: '29px',
width: '120px',
margin: '16px 0 8px 10px',
justifyContent: 'center',
radius: '5px',
backgroundColor: '#E8E8E8',
}}
>
<Typography
sx={{
fontSize: '11px',
color: '#949494'
color: '#949494',
}}
>
인증코드 재요청
Expand Down
1 change: 0 additions & 1 deletion src/store/signUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { atom } from 'recoil';
export const SignUpStepState = atom({
key: 'signUpState',
default: 0,
dangerouslyAllowMutability: false
});

// sign up user data
Expand Down

0 comments on commit 34317c1

Please sign in to comment.