mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed error handling
This commit is contained in:
parent
988a069d57
commit
b45ecadd20
3 changed files with 44 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
||||||
import * as React from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { push as historyPush } from 'connected-react-router';
|
import { push as historyPush } from 'connected-react-router';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
@ -6,18 +6,26 @@ import { Logo } from '~/components/main/Logo';
|
||||||
|
|
||||||
import * as style from './style.scss';
|
import * as style from './style.scss';
|
||||||
import { Filler } from '~/components/containers/Filler';
|
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 { Group } from '~/components/containers/Group';
|
||||||
|
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
||||||
|
import { DIALOGS } from '~/redux/modal/constants';
|
||||||
|
|
||||||
const mapStateToProps = selectUser;
|
const mapStateToProps = selectUser;
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
push: historyPush
|
push: historyPush,
|
||||||
|
showDialog: MODAL_ACTIONS.modalShowDialog,
|
||||||
};
|
};
|
||||||
|
|
||||||
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
||||||
|
|
||||||
const HeaderUnconnected: React.FunctionComponent<IProps> = ({ username, is_user }) => (
|
const HeaderUnconnected: FC<IProps> = ({ username, is_user, showDialog }) => {
|
||||||
|
const onLogin = useCallback(() => {
|
||||||
|
showDialog(DIALOGS.LOGIN);
|
||||||
|
}, [showDialog]);
|
||||||
|
|
||||||
|
return (
|
||||||
<div className="default_container head_container">
|
<div className="default_container head_container">
|
||||||
<div className={style.container}>
|
<div className={style.container}>
|
||||||
<Logo />
|
<Logo />
|
||||||
|
@ -41,14 +49,14 @@ const HeaderUnconnected: React.FunctionComponent<IProps> = ({ username, is_user
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!is_user && (
|
{!is_user && (
|
||||||
<Group horizontal className={style.user_button}>
|
<Group horizontal className={style.user_button} onClick={onLogin}>
|
||||||
<div>ВДОХНУТЬ</div>
|
<div>ВДОХ</div>
|
||||||
<div className={style.user_avatar} />
|
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Header = connect(
|
const Header = connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
height: 96px;
|
height: 96px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.spacer {
|
.spacer {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +48,10 @@
|
||||||
&:last-child {
|
&:last-child {
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
|
|
||||||
&::after { display: none; }
|
&::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
flex: 0 !important;
|
flex: 0 !important;
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user_avatar {
|
.user_avatar {
|
||||||
|
|
|
@ -35,7 +35,7 @@ const LoginDialogUnconnected: FC<IProps> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) userSetLoginError(null);
|
if (error) userSetLoginError(null);
|
||||||
}, [username, password, error, userSetLoginError]);
|
}, [username, password]);
|
||||||
|
|
||||||
const buttons = (
|
const buttons = (
|
||||||
<Padder>
|
<Padder>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue