Skip to content

Commit

Permalink
HotFix: 회원가입 핫 픽스
Browse files Browse the repository at this point in the history
  • Loading branch information
kangsinbeom committed Jun 28, 2024
1 parent 0e4f43e commit 1c0b60e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/apis/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ instance.interceptors.response.use(
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true;
try {
const { setMember } = memberStore.getState();
console.log('hi');
const response = await getNewToken();
const { accessToken } = response.data;
console.log(accessToken);
const { setMember } = memberStore.getState();
setMember(accessToken);
originalRequest.headers['Authorization'] = `Bearer ${accessToken}`;
return instance(originalRequest);
Expand Down
22 changes: 13 additions & 9 deletions src/pages/signup/components/signupCheck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Timer } from '..';
import { useEffect, useState } from 'react';
import { Button, CircleLoader, InputField } from '@/components';
import usePostEmailVerify from '../../hooks/usePostEmailVerify';
import { useForm } from 'react-hook-form';
import { RegisterOptions, useForm } from 'react-hook-form';
import usePostCheckEmailOrNickname, {
SignupCheckData,
} from '../../hooks/usePostCheckEmailOrNickname';
Expand All @@ -13,10 +13,17 @@ export interface SignupCheckProps {
label: string;
value: 'email' | 'nickname';
buttonLabel: string;
registerOptions: RegisterOptions;
successMessage: string;
}

const SignupCheck = ({ label, value, buttonLabel, successMessage }: SignupCheckProps) => {
const SignupCheck = ({
label,
value,
buttonLabel,
successMessage,
registerOptions,
}: SignupCheckProps) => {
const {
register,
formState: { errors },
Expand All @@ -34,13 +41,10 @@ const SignupCheck = ({ label, value, buttonLabel, successMessage }: SignupCheckP
<S.Container>
<S.InputBox>
<InputField
register={register(value, {
required: '이메일을 입력해주세요',
pattern: {
value: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
message: '이메일 형식을 지켜주세요',
},
})}
register={register(
value,
registerOptions as RegisterOptions<SignupCheckData, 'email' | 'nickname'>,
)}
error={errors[value]}
label={label}
value={value}
Expand Down
9 changes: 7 additions & 2 deletions src/pages/signup/components/signupForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SignupFormLayout, SignupTextarea } from '..';
import { Button, InputField } from '@/components';
import { ExtendedSignupForm } from '@/types/member';
import { useFormContext } from 'react-hook-form';
import { RegisterOptions, useFormContext } from 'react-hook-form';
import { essentiolFormData, optionalFormData } from '@/consts/signup';
import { checkModalStore } from '@/stores/modal';
import { Navigate } from 'react-router-dom';
Expand Down Expand Up @@ -50,7 +50,12 @@ const SignupForm = () => {
open({
title: props.title,
content: (
<SignupCheck label={label} value={value} {...checkOption} />
<SignupCheck
label={label}
value={value}
registerOptions={registerOptions as RegisterOptions}
{...checkOption}
/>
),
})
}
Expand Down

0 comments on commit 1c0b60e

Please sign in to comment.