+
-
- 8~20자 이내
+
+ 8자 이상 20자 이하
-
- 영문 대소문자, 숫자 포함
+
+ 영문, 숫자, 특수문자(@$!%*#?&) 포함
-
diff --git a/app/register/_components/ScreenRegister.tsx b/app/register/_components/ScreenRegister.tsx
index 7acaac2..c7da289 100644
--- a/app/register/_components/ScreenRegister.tsx
+++ b/app/register/_components/ScreenRegister.tsx
@@ -15,7 +15,7 @@ export const ScreenRegister = () => {
const [password, setPassword] = useState("");
const { mutate: sendEmail, isPending: isSendingEmail } = useSendEmail();
- const { mutate: verifyEmail, isPending: isVerifyingEmail } = useVerifyEmail();
+ const { verify, isPending: isVerifyingEmail } = useVerifyEmail();
const { mutate: signUp, isPending: isSigningUp } = useSignUp();
const handleEmailSubmit = (e: React.SyntheticEvent
) => {
@@ -25,17 +25,11 @@ export const ScreenRegister = () => {
});
};
- const handleVerify = (code: string, onError: () => void) => {
- verifyEmail(
+ const handleVerify = (code: string, onError: (msg?: string) => void) => {
+ verify(
{ email, code },
{
- onSuccess: (data) => {
- if (data.status === 200) {
- setStep(3);
- } else {
- onError();
- }
- },
+ onSuccess: () => setStep(3),
onError,
},
);
diff --git a/app/register/_components/VerificationStep.tsx b/app/register/_components/VerificationStep.tsx
index 89cda7a..5790e57 100644
--- a/app/register/_components/VerificationStep.tsx
+++ b/app/register/_components/VerificationStep.tsx
@@ -6,7 +6,7 @@ type VerificationStepProps = {
email: string;
verificationCode: string;
onVerificationCodeChange: (code: string) => void;
- onVerify: (code: string, onError: () => void) => void;
+ onVerify: (code: string, onError: (msg?: string) => void) => void;
onResend: () => void;
isVerifying?: boolean;
};
@@ -20,7 +20,7 @@ export const VerificationStep = ({
isVerifying = false,
}: VerificationStepProps) => {
const [timeLeft, setTimeLeft] = useState(300); // 5분 = 300초
- const [isWrong, setIsWrong] = useState(false);
+ const [errorMessage, setErrorMessage] = useState("");
useEffect(() => {
if (timeLeft <= 0) return;
@@ -40,19 +40,21 @@ export const VerificationStep = ({
const handleVerificationCodeChange = (value: string) => {
onVerificationCodeChange(value);
- if (isWrong && value) {
- setIsWrong(false);
+ if (errorMessage && value) {
+ setErrorMessage("");
}
};
const handleSubmit = (e: React.SyntheticEvent) => {
e.preventDefault();
- onVerify(verificationCode, () => setIsWrong(true));
+ onVerify(verificationCode, (msg?: string) =>
+ setErrorMessage(msg || "인증번호를 다시 확인해 주세요"),
+ );
};
const handleResend = () => {
setTimeLeft(300); // 타이머 리셋
- setIsWrong(false); // 에러 상태 초기화
+ setErrorMessage(""); // 에러 상태 초기화
onResend();
};
@@ -96,7 +98,7 @@ export const VerificationStep = ({
required
value={verificationCode}
onChange={(e) => handleVerificationCodeChange(e.target.value)}
- error={isWrong}
+ error={!!errorMessage}
maxLength={6}
inputMode="numeric"
className="flex-1"
@@ -110,9 +112,9 @@ export const VerificationStep = ({
재전송
- {isWrong && (
+ {errorMessage && (