Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gahyuun committed Jan 29, 2024
2 parents 6a524db + ac9acdf commit e5db2dd
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/pages/sign-in/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import styled from 'styled-components';
import { Footer } from '@components/layout/footer';
import { Main } from '@components/sign-up';
import { ValidateSchema } from '@/utils/sign-in/ValidateSchema';
import { getCookie, setCookie } from '@hooks/sign-in/useSignIn';
import { getCookie, removeCookie, setCookie } from '@hooks/sign-in/useSignIn';
import { useCustomNavigate } from '@hooks/sign-up/useSignUp';
import { usePostLogin } from '@queries/sign-in';
import { useFormik } from 'formik';
import { Layout, Input, Button, message } from 'antd';
import { TextBox } from '@components/text-box';
import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
import { AxiosError } from 'axios';
import { HTTP_STATUS_CODE, RESPONSE_CODE } from '@/constants/api';
import { HTTP_STATUS_CODE } from '@/constants/api';
import { colors } from '@/constants/colors';
import { SignInData } from '@api/sign-in/type';
import { ACCOMMODATION_API } from '@api/accommodation';
Expand All @@ -21,6 +21,9 @@ export const SignIn = () => {
const { mutate } = usePostLogin({
onSuccess: async (response) => {
try {
if (getCookie('accommodationId')) {
removeCookie('accommodationId');
}
setCookie('accessToken', response.data.accessToken);
setCookie('refreshToken', response.data.refreshToken);
const { data } = await ACCOMMODATION_API.getAccommodationList();
Expand All @@ -40,26 +43,11 @@ export const SignIn = () => {
console.log(error);
}
},
onError(error) {
if (
error.response?.data.code === RESPONSE_CODE.REQUEST_BODY_ERROR ||
error.response?.data.code === RESPONSE_CODE.INCORRECT_EMAIL ||
error.response?.data.code === RESPONSE_CODE.INCORRECT_PASSWORD
) {
message.error({
content: (
<TextBox typography="body3" fontWeight={'400'}>
이메일과 비밀번호를 확인해 주세요.
</TextBox>
),
duration: 2,
});
return;
}
onError() {
message.error({
content: (
<TextBox typography="body3" fontWeight={'400'}>
요청을 처리하지 못했습니다. 관리자에게 문의해주세요.
이메일과 비밀번호를 확인해 주세요.
</TextBox>
),
duration: 2,
Expand Down

0 comments on commit e5db2dd

Please sign in to comment.