Skip to content

Commit

Permalink
Merge pull request #284 from INFP-Study/feature/signInPeristalsis
Browse files Browse the repository at this point in the history
๋กœ๊ทธ์ธ, ๋กœ๊ทธ์•„์›ƒ ๊ตฌํ˜„ ๋ฐ ๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€ ํ† ํฐ ์ €์žฅ๋ฐฉ์‹ ์ ์šฉ #282
  • Loading branch information
thyoondev authored Jan 22, 2022
2 parents fc01db5 + b6ed396 commit a81a82e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
36 changes: 27 additions & 9 deletions frontend/src/components/common/layout/header.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { Affix, Layout } from 'antd';
import { SIGN_IN, TITLE } from '../../../constants';
import React, { useEffect, useState } from 'react';
import { Affix, Button, Layout, notification } from 'antd';
import { SIGN_IN, SIGN_OUT, SIGN_OUT_SUCCESS, TITLE } from '../../../constants';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { MAIN_URL, SIGN_IN_URL } from '../../../constants/urls';
import { MdAccountCircle } from 'react-icons/md';
import { theme } from '../../../style/theme';
import { useSelector } from 'react-redux';

const { Header } = Layout;

Expand Down Expand Up @@ -41,16 +42,33 @@ const UserInfo = styled(Link)`
`;

function SiteHeader() {
const signOut = () => {
notification.success({
message: 'CIAT',
description: SIGN_OUT_SUCCESS,
});
localStorage.removeItem('token');
};

return (
<Affix offsetTop={0}>
<Header style={HeaderStyle}>
<Logo to={MAIN_URL}>{TITLE}</Logo>
<UserInfo to={SIGN_IN_URL}>
<MdAccountCircle
style={{ fontSize: theme.fontSizeIcon, margin: '0px 10px' }}
/>
{SIGN_IN}
</UserInfo>
{localStorage.getItem('token') === null ? (
<UserInfo to={SIGN_IN_URL}>
<MdAccountCircle
style={{ fontSize: theme.fontSizeIcon, margin: '0px 10px' }}
/>
{SIGN_IN}
</UserInfo>
) : (
<UserInfo to={MAIN_URL} onClick={signOut}>
<MdAccountCircle
style={{ fontSize: theme.fontSizeIcon, margin: '0px 10px' }}
/>
{SIGN_OUT}
</UserInfo>
)}
</Header>
</Affix>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const EMPTY_NICKNAME = '๋‹‰๋„ค์ž„์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.';
export const EMPTY_PASSWORD = '๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.';
export const EMPTY_PASSWORD_CONFIRM = '๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.';
export const SIGN_UP_SUCCESS = 'ํšŒ์›๊ฐ€์ž…์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.';
export const SIGN_OUT_SUCCESS = '์ •์ƒ์ ์œผ๋กœ ๋กœ๊ทธ์•„์›ƒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.';
export const REQUIRED_CHECK = 'ํ•„์ˆ˜ํ•ญ๋ชฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.';
export const EMAIL_CHECK = '์ด๋ฉ”์ผ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.';
export const NICKNAME_CHECK =
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/containers/auth/sign-in-container.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { message } from 'antd';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
import SignIn from '../../components/auth/sign-in';
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/saga/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function* signInSaga(action) {
type: authStore.signInSuccess,
payload: success.config.headers.Authorization,
});

localStorage.setItem('token', success.config.headers.Authorization);
window.location.href = '/';
} catch (error) {
message.error(SIGN_IN_ERROR, 5);
Expand All @@ -46,7 +46,7 @@ function* signUpSaga(action) {
}, 1500);
} catch (e) {
// ์ด๋ฉ”์ผ ์ค‘๋ณต ํ™•์ธ ๋กœ์ง ์ถ”๊ฐ€์˜ˆ์ •
alert('์ด๋ฏธ ๋“ฑ๋ก๋œ ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.');
alert('์•Œ์ˆ˜์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.');
if (axios.isAxiosError(e)) {
console.log(e.response);
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/utils/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const authAPI = {
};

export const SIGN_UP_API =
'https://ciat-bakend.choicloudlab.com/api/v1/user/signup';
'https://ciat-dev.choicloudlab.com/api/v1/user/signup';

export const SIGN_IN_API =
'https://ciat-bakend.choicloudlab.com/api/v1/user/signin';
'https://ciat-dev.choicloudlab.com/api/v1/user/signin';

export const IS_SUCCESS =
'https://ciat-bakend.choicloudlab.com/api/v1/user/success';
'https://ciat-dev.choicloudlab.com/api/v1/user/success';

0 comments on commit a81a82e

Please sign in to comment.