Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#164] 로그인 페이지 코드 리팩토링 (dev로 반영) #173

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/api/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ const onErrorResponse = async (error: AxiosResponseError<string>) => {
}
}
console.log(error.response.data.code, error.response);
return Promise.reject(error);
}
console.log('response error : ', error);
return Promise.reject(error);
};

// 요청 인터셉터 추가
Expand Down
2 changes: 2 additions & 0 deletions src/components/Auth/AuthButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const SubmitButton = styled.button<AuthButtonStyleProps>`
return '#C1C1C1';
} else if (props.$variant === 'pink') {
return 'linear-gradient(91deg, #FF3478 1.39%, #FF83AD 98.63%)';
} else if (props.$variant === 'skyblue') {
return 'linear-gradient(89.18deg, #3182F6 0%, #6AB2FF 111.65%)';
} else {
return '#1A2849';
}
Expand Down
17 changes: 16 additions & 1 deletion src/components/Login/LoginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ const LoginForm = ({ handleModalOpen }: LoginFormProps) => {
const navigate = useNavigate();
const { state } = useLocation();

const methods = useForm({ mode: 'onBlur' });
const methods = useForm({
mode: 'onBlur'
});
const {
setValue,
formState: { errors },
handleSubmit
} = methods;
const isError = !!errors?.login_id || !!errors?.login_password ? true : false;

const setDefaultValues = async () => {
setValue('login_id', '[email protected]');
setValue('login_password', 'test1234!');
};

const movetoSignUp = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
navigate('/signup');
Expand Down Expand Up @@ -110,6 +118,13 @@ const LoginForm = ({ handleModalOpen }: LoginFormProps) => {
text="회원가입"
buttonFunc={movetoSignUp}
/>
<AuthButton
buttonType="button"
size="large"
variant="skyblue"
text="게스트 계정으로 둘러보기"
buttonFunc={setDefaultValues}
/>
</Buttons>
</form>
</FormProvider>
Expand Down
1 change: 0 additions & 1 deletion src/utils/lib/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { SetCookies, GetCookies } from '@/types/auth';
export const setCookies: SetCookies = (name, value, expiresIn) => {
try {
document.cookie = `${name}=${value};max-age=${expiresIn};path=/;secure`;
console.log(`${name}: 쿠키설정 성공`);
} catch (error) {
console.log(error);
alert(`${name}: 쿠키설정에 실패했습니다.`);
Expand Down