Skip to content

Commit

Permalink
fix: merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed May 13, 2024
2 parents c3c9683 + cda84af commit bec61f5
Show file tree
Hide file tree
Showing 34 changed files with 973 additions and 771 deletions.
13 changes: 4 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],
"ignorePatterns": [
"dist",
".eslintrc.json"
],
"ignorePatterns": ["dist", ".eslintrc.json"],
"parser": "@typescript-eslint/parser",
"plugins": [
"react",
"react-refresh"
],
"plugins": ["react", "react-refresh"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"react-refresh/only-export-components": [
"warn",

Expand All @@ -30,4 +25,4 @@
"no-unused-vars": "warn",
"react/jsx-pascal-case": "warn"
}
}
}
Binary file added public/sign/doneCheck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/sign/doneCircle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/sign/emailerror.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 10 additions & 15 deletions src/api/auth/auth.post.api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import { ICommon } from '../types/common';
import { basicResponse } from '@/models/response';
import { postRequest } from '../request';
import {
ISignIn,
Expand All @@ -10,28 +9,24 @@ import {
IPhoneNumber,
IPhoneAuth
} from '../types/auth';

import { ICommon } from '../types/common';

/* 회원가입 */

export const signup = async ({
memberEmail,
memberPassword,
memberName,
memberGender,
memberJob,
memberPhone,
memberBirthDate,
memberSmsAgree
}: ISignUp) => {
const response = await postRequest<null, ISignUp>('members', {
const response = await postRequest<ICommon<null>, ISignUp>('members', {
memberEmail,
memberPassword,
memberName,
memberGender,
memberJob,
memberPhone,
memberBirthDate,
memberSmsAgree
});
return response;
Expand All @@ -51,43 +46,43 @@ export const signin = async ({ memberEmail, memberPassword }: ISignIn) => {
/* 이메일 인증 요청 */

export const emailauthrequest = async ({ emailAddress }: IEmail) => {
const response = await postRequest<null, IEmail>(`auth/email`, {
const response = await postRequest<ICommon<null>, IEmail>(`auth/email`, {
emailAddress
});

return response as basicResponse | null;
return response;
};

/* 이메일 코드 검증 */

export const emailauthverify = async ({ emailAddress, code }: IEmailAuth) => {
const response = await postRequest<null, IEmailAuth>(`auth/email/verify`, {
const response = await postRequest<ICommon<null>, IEmailAuth>(`auth/email/verify`, {
emailAddress,
code
});

return response as basicResponse | null;
return response;
};

/* 휴대전화 번호 인증 요청*/

export const phoneauthrequest = async ({ phoneNumber }: IPhoneNumber) => {
const response = await postRequest<null, IPhoneNumber>('/auth/phone', {
const response = await postRequest<ICommon<null>, IPhoneNumber>(`auth/phone`, {
phoneNumber
});

return response as basicResponse | null;
return response;
};

/* 휴대전화 번호 코드 검증*/

export const phoneauthverify = async ({ phoneNumber, code }: IPhoneAuth) => {
const response = await postRequest<null, IPhoneAuth>('/auth/phone/verify', {
const response = await postRequest<ICommon<null>, IPhoneAuth>(`auth/phone/verify`, {
phoneNumber,
code
});

return response as basicResponse | null;
return response;
};

/* 로그아웃*/
Expand Down
3 changes: 0 additions & 3 deletions src/api/types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ export interface ISignIn {

export interface ISignUp extends ISignIn {
memberName: string;
memberGender: string;
memberJob: string;
memberPhone: string;
memberBirthDate: string;
memberSmsAgree: boolean;
}

Expand All @@ -19,7 +17,6 @@ export interface IUpdateProfile {
memberName: string;
memberJob: string;
memberPhone: string;
memberBirthDate: string;
}

export interface IPhoneNumber {
Expand Down
6 changes: 3 additions & 3 deletions src/api/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface ICommon<T> {
status: number;
code: string;
status: string;
errorCode: string;
message: string;
value: T;
data: T;
}
95 changes: 60 additions & 35 deletions src/components/findpassword/EmailCertification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { motion } from 'framer-motion';
import { useMutation } from 'react-query';
import { invertSecond } from '@/utils/invertSecond';
import { emailauthrequest, emailauthverify } from '@/api/auth/auth.post.api';
import { signError } from '@/constant/signError';

interface EmailCertificationProps {
setStep: Dispatch<React.SetStateAction<number>>;
Expand All @@ -17,10 +18,10 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {
const [isRequest, setIsRequest] = useState(false);
const [validNumber, setValidNumber] = useState<string>('');
const [validTime, setValidTime] = useState<number>(300);
const [isError, setIsError] = useState(false);
const [emailError, setEmailError] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);
const startRef = useRef<HTMLInputElement>(null);
//추가
const [errorMessage, setErrorMessage] = useState('');

const { mutateAsync: emailRequest } = useMutation((email: string) => {
return emailauthrequest({ emailAddress: email });
Expand Down Expand Up @@ -65,14 +66,13 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {

useEffect(() => {
let timeoutId: NodeJS.Timeout;
if (isError || emailError) {
if (errorMessage != '') {
timeoutId = setTimeout(() => {
setIsError(false);
setEmailError(false);
setErrorMessage('');
}, 4000);
}
return () => clearTimeout(timeoutId);
}, [isError, emailError]);
}, [errorMessage]);

useEffect(() => {
let intervalId: NodeJS.Timeout;
Expand All @@ -88,37 +88,51 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {

const handleClick = async () => {
if (btnStatus == 'SECOND') {
const { status } = (await emailRequest(userEmail)) as { status: string };
if (status == 'SUCCESS') {
setIsRequest(true);
setBtnStatus('THIRD');
}
if (status == 'FAIL') {
setUserEmail('');
setEmailError(true);
return;
try {
const { status } = await emailRequest(userEmail);
if (status == 'SUCCESS') {
setIsRequest(true);
setBtnStatus('THIRD');
}
} catch (error: any) {
const errorResponse = error.response.data;
const errorCode = errorResponse.errorCode;
const select = signError.find((item) => item.errorCode === errorCode);
if (select) {
setErrorMessage(select.message);
setUserEmail('');
setBtnStatus('FIRST');
startRef.current?.focus();
return;
}
}
}
if (btnStatus == 'THIRD') {
if (validNumber.length != 6) {
setValidNumber('');
setIsError(true);
setErrorMessage('6자리 코드를 입력해주세요.');
inputRef.current?.focus();
return;
}
const { status } = (await emailVerify({
emailAddress: userEmail,
code: Number(validNumber)
})) as { status: string };
try {
const { status } = (await emailVerify({
emailAddress: userEmail,
code: Number(validNumber)
})) as { status: string };

if (status == 'SUCCESS') {
setStep((prev) => prev + 1);
}
if (status == 'FAIL') {
setValidNumber('');
setIsError(true);
inputRef.current?.focus();
return;
if (status == 'SUCCESS') {
setStep((prev) => prev + 1);
}
} catch (error: any) {
const errorResponse = error.response.data;
const errorCode = errorResponse.errorCode;
const select = signError.find((item) => item.errorCode === errorCode);
if (select) {
setErrorMessage(select.message);
setValidNumber('');
inputRef.current?.focus();
return;
}
}
}
};
Expand Down Expand Up @@ -176,6 +190,7 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {
value={userEmail}
onChange={handleEmailChange}
ref={startRef}
autoComplete="off"
/>
</div>
<button
Expand All @@ -190,10 +205,10 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {
</button>
</div>
</div>
{emailError ? (
{errorMessage != '' && isRequest === false ? (
<div className="flex ml-4">
<div className="text-red-700 text-xs font-normal font-pretendard leading-tight">
*등록되지 않은 이메일입니다.
{errorMessage}
</div>
</div>
) : (
Expand All @@ -202,12 +217,22 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {
</motion.div>

{isRequest && (
<>
<motion.div
initial={{ opacity: 0, translateX: -90 }}
transition={{
duration: 0.4,
ease: 'easeInOut',
delay: 0.6
}}
animate={{
opacity: 1,
translateX: 0
}}>
<div className="mt-[48px] border-b border-neutral-300 ml-4">
{isError ? (
{errorMessage != '' ? (
<div className="flex flex-row-reverse">
<div className="text-red-700 text-xs font-normal font-pretendard leading-tight">
*올바르지 않은 코드입니다.
{errorMessage}
</div>
</div>
) : (
Expand Down Expand Up @@ -241,10 +266,10 @@ const EmailCertification = ({ setStep }: EmailCertificationProps) => {
이메일로 발송된 코드를 입력해주세요.
</div>
</div>
</>
</motion.div>
)}
</div>
);
};

export default EmailCertification;
export default EmailCertification;
2 changes: 1 addition & 1 deletion src/components/findpassword/NewPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const NewPasswordForm = ({
</div>
</div>
</div>
<div className="w-full flex justify-center items-center mx-auto mb-2">
<div className="w-full flex justify-center items-center mx-auto mb-4">
<button
disabled={!validBtn}
className={`mt-[250px] w-[361px] h-12 px-3.5 rounded-lg justify-center items-center inline-flex text-[15px] font-semibold font-pretendard leading-snug
Expand Down
1 change: 1 addition & 0 deletions src/components/shared/MainContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactNode } from 'react';

const MainContainer = ({ children }: { children: ReactNode }) => {
//
return <div className=" max-w-[393px] mx-auto">{children}</div>;
};

Expand Down
1 change: 1 addition & 0 deletions src/components/shared/sign/SignInButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';

const SignInButton = () => {
const router = useRouter();
//
return (
<button
className="w-[361px] h-12 px-3.5 rounded-lg border border-black justify-center items-center inline-flex text-black text-[15px] font-semibold font-pretendard leading-snug"
Expand Down
1 change: 1 addition & 0 deletions src/components/shared/sign/SignUpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';

const SignUpButton = () => {
const router = useRouter();
//
return (
<button
className="w-[361px] h-12 px-3.5 bg-space-black rounded-lg justify-center items-center inline-flex text-white text-[15px] font-semibold font-pretendard leading-snug"
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/sign/ToBack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IoIosArrowRoundBack } from 'react-icons/io';

const ToBack = () => {
return (
<div className="w-[80px] mt-[84px]">
<div className="w-[80px] mt-[60px]">
<Link href={'/sign'}>
<IoIosArrowRoundBack size={80} />
</Link>
Expand Down
Loading

0 comments on commit bec61f5

Please sign in to comment.