/
Header.js
65 lines (61 loc) · 1.76 KB
/
Header.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from "react";
import { Grid, Text, Button } from "../elements";
import { getCookie, deleteCookie } from "../shared/Cookie";
import { useSelector, useDispatch } from "react-redux";
import { actionCreators as userActions } from "../redux/modules/user";
import { history } from "../redux/configureStore";
import { apiKey } from "../shared/firebase";
const Header = (props) => {
const dispatch = useDispatch();
const is_login = useSelector((state) => state.user.is_login);
const session_key = `firebase:authUser:${apiKey}:[DEFAULT]`;
const is_session = sessionStorage.getItem(session_key) ? true : false;
if (is_login && is_session) {
return (
<Grid is_flex padding="4px 16px">
<Grid>
<Text margin="0px" size="24px" bold>
헬로
</Text>
</Grid>
<Grid is_flex>
<Button text="내 정보"></Button>
<Button _onClick={() => history.push("/noti")} text="알림"></Button>
<Button
text="로그아웃"
_onClick={() => {
dispatch(userActions.logoutFB());
}}
></Button>
</Grid>
</Grid>
);
}
return (
<React.Fragment>
<Grid is_flex padding="4px 16px">
<Grid>
<Text margin="0px" size="24px" bold>
헬로
</Text>
</Grid>
<Grid is_flex>
<Button
text="로그인"
_onClick={() => {
history.push("/login");
}}
></Button>
<Button
text="회원가입"
_onClick={() => {
history.push("/signup");
}}
></Button>
</Grid>
</Grid>
</React.Fragment>
);
};
Header.defaultProps = {};
export default Header;