From b45ecadd2060ec4258df96e07a03b8016db6e14f Mon Sep 17 00:00:00 2001 From: muerwre Date: Fri, 9 Aug 2019 14:46:05 +0700 Subject: [PATCH] fixed error handling --- src/components/main/Header/index.tsx | 70 +++++++++++--------- src/components/main/Header/style.scss | 7 +- src/containers/dialogs/LoginDialog/index.tsx | 2 +- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/components/main/Header/index.tsx b/src/components/main/Header/index.tsx index 0d4302dc..0793f05d 100644 --- a/src/components/main/Header/index.tsx +++ b/src/components/main/Header/index.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React, { FC, useCallback } from 'react'; import { connect } from 'react-redux'; import { push as historyPush } from 'connected-react-router'; import { Link } from 'react-router-dom'; @@ -6,49 +6,57 @@ import { Logo } from '~/components/main/Logo'; import * as style from './style.scss'; import { Filler } from '~/components/containers/Filler'; -import { selectUser, selectAuthLogin } from '~/redux/auth/selectors'; +import { selectUser } from '~/redux/auth/selectors'; import { Group } from '~/components/containers/Group'; +import * as MODAL_ACTIONS from '~/redux/modal/actions'; +import { DIALOGS } from '~/redux/modal/constants'; const mapStateToProps = selectUser; const mapDispatchToProps = { - push: historyPush + push: historyPush, + showDialog: MODAL_ACTIONS.modalShowDialog, }; type IProps = ReturnType & typeof mapDispatchToProps & {}; -const HeaderUnconnected: React.FunctionComponent = ({ username, is_user }) => ( -
-
- +const HeaderUnconnected: FC = ({ username, is_user, showDialog }) => { + const onLogin = useCallback(() => { + showDialog(DIALOGS.LOGIN); + }, [showDialog]); - + return ( +
+
+ -
- flow - image - editor - horizontal + + +
+ flow + image + editor + horizontal +
+ + + + {is_user && ( + +
{username}
+
+ + )} + + {!is_user && ( + +
ВДОХ
+
+ )}
- - - - {is_user && ( - -
{username}
-
- - )} - - {!is_user && ( - -
ВДОХНУТЬ
-
- - )}
-
-); + ); +}; const Header = connect( mapStateToProps, diff --git a/src/components/main/Header/style.scss b/src/components/main/Header/style.scss index 1da3abd7..bfd4d901 100644 --- a/src/components/main/Header/style.scss +++ b/src/components/main/Header/style.scss @@ -6,7 +6,6 @@ height: 96px; } - .spacer { flex: 1; } @@ -49,9 +48,10 @@ &:last-child { padding-right: 0; - &::after { display: none; } + &::after { + display: none; + } } - } } @@ -68,6 +68,7 @@ text-transform: uppercase; flex: 0 !important; opacity: 0.3; + cursor: pointer; } .user_avatar { diff --git a/src/containers/dialogs/LoginDialog/index.tsx b/src/containers/dialogs/LoginDialog/index.tsx index 0313a35b..ddff1322 100644 --- a/src/containers/dialogs/LoginDialog/index.tsx +++ b/src/containers/dialogs/LoginDialog/index.tsx @@ -35,7 +35,7 @@ const LoginDialogUnconnected: FC = ({ useEffect(() => { if (error) userSetLoginError(null); - }, [username, password, error, userSetLoginError]); + }, [username, password]); const buttons = (