mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
persisted user profile
This commit is contained in:
parent
4f86847e59
commit
8071a1644c
6 changed files with 42 additions and 17 deletions
|
@ -1,25 +1,37 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Logo } from "$components/main/Logo";
|
import { Logo } from "$components/main/Logo";
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { IUserProfile, IUserState } from "$redux/user/reducer";
|
||||||
|
|
||||||
const style = require('./style.scss');
|
const style = require('./style.scss');
|
||||||
|
|
||||||
export const Header = () => (
|
interface IHeaderProps {
|
||||||
|
username?: IUserProfile['username'],
|
||||||
|
is_user?: IUserProfile['is_user'],
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Component: React.FunctionComponent<IHeaderProps> = ({ username, is_user }) => (
|
||||||
<div className="default_container head_container">
|
<div className="default_container head_container">
|
||||||
<div className={style.container}>
|
<div className={style.container}>
|
||||||
<Logo />
|
<Logo />
|
||||||
<div className={style.spacer} />
|
<div className={style.spacer} />
|
||||||
|
{
|
||||||
|
is_user && username &&
|
||||||
|
<div className={style.user_button}>
|
||||||
|
<div className={style.user_avatar} />
|
||||||
|
{username}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div className={style.plugs}>
|
<div className={style.plugs}>
|
||||||
<div>depth</div>
|
<div>depth</div>
|
||||||
<div>boris</div>
|
<div>boris</div>
|
||||||
<div>flow</div>
|
<div>flow</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
const mapStateToProps = ({ user: { profile: { username, is_user } } }: { user: IUserState }) => ({ username, is_user });
|
||||||
<div className={style.user_button}>
|
|
||||||
<div className={style.user_avatar} />
|
export const Header = connect(mapStateToProps)(Component);
|
||||||
gvorcek
|
|
||||||
</div>
|
|
||||||
*/
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
.plugs {
|
.plugs {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
//margin: 8px;
|
//margin: 8px;
|
||||||
|
@ -31,6 +32,10 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
padding-left: $spc + $gap;
|
||||||
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
|
|
||||||
|
@ -50,11 +55,16 @@
|
||||||
padding: 0 $gap;
|
padding: 0 $gap;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
background: white;
|
||||||
|
color: $main_bg_color;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: $input_radius;
|
||||||
|
font-size: $text_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user_avatar {
|
.user_avatar {
|
||||||
width: 16px;
|
//width: 16px;
|
||||||
height: 16px;
|
//height: 16px;
|
||||||
background: transparentize(white, 0.5);
|
//background: transparentize(white, 0.5);
|
||||||
margin-right: $gap;
|
//margin-right: $gap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { routerMiddleware } from 'connected-react-router'
|
||||||
|
|
||||||
const userPersistConfig: PersistConfig = {
|
const userPersistConfig: PersistConfig = {
|
||||||
key: 'user',
|
key: 'user',
|
||||||
whitelist: ['user', 'logo', 'provider', 'speed'],
|
whitelist: ['profile'],
|
||||||
storage,
|
storage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,10 @@ export interface IUserProfile {
|
||||||
username: string,
|
username: string,
|
||||||
email: string,
|
email: string,
|
||||||
role: string,
|
role: string,
|
||||||
activated: boolean,
|
|
||||||
token: string,
|
token: string,
|
||||||
|
|
||||||
|
is_activated: boolean,
|
||||||
|
is_user: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUserFormStateLogin {
|
export interface IUserFormStateLogin {
|
||||||
|
@ -58,7 +60,8 @@ const INITIAL_STATE: IUserState = {
|
||||||
email: '',
|
email: '',
|
||||||
role: '',
|
role: '',
|
||||||
token: '',
|
token: '',
|
||||||
activated: false,
|
is_activated: false,
|
||||||
|
is_user: false,
|
||||||
},
|
},
|
||||||
form_state: {
|
form_state: {
|
||||||
login: {
|
login: {
|
||||||
|
|
|
@ -14,9 +14,9 @@ function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionC
|
||||||
|
|
||||||
if (!token) return yield put(userSetLoginError({ error: USER_STATUSES[status] || USER_ERRORS.INVALID_CREDENTIALS }));
|
if (!token) return yield put(userSetLoginError({ error: USER_STATUSES[status] || USER_ERRORS.INVALID_CREDENTIALS }));
|
||||||
|
|
||||||
const { id, role, email, activated } = user;
|
const { id, role, email, activated: is_activated } = user;
|
||||||
|
|
||||||
yield put(userSetUser({ token, id, role, email, username: user.username, activated, }));
|
yield put(userSetUser({ token, id, role, email, username: user.username, is_activated, is_user: true }));
|
||||||
yield put(push('/'));
|
yield put(push('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ $main_text_color: white;
|
||||||
$content_bg_color: #222222;
|
$content_bg_color: #222222;
|
||||||
$content_bg_secondary: darken($content_bg_color, 3%);
|
$content_bg_secondary: darken($content_bg_color, 3%);
|
||||||
|
|
||||||
$cell_bg: transparentize(white, 0.95);
|
$cell_bg: transparentize(white, 0.98);
|
||||||
|
|
||||||
$text_normal: 16px;
|
$text_normal: 16px;
|
||||||
$text_small: 14px;
|
$text_small: 14px;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue