1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

displaying user description

This commit is contained in:
Fedor Katurov 2019-11-12 15:31:51 +07:00
parent 371f47f866
commit 7f04fe1e36
7 changed files with 59 additions and 3 deletions

View file

@ -2,10 +2,8 @@
@include outer_shadow();
padding: $gap;
background: $content_bg;
// position: relative;
textarea {
// margin-bottom: 40px;
padding-bottom: 0 !important;
}
}

View file

@ -0,0 +1,32 @@
import React, { FC } from 'react';
import { IUser } from '~/redux/auth/types';
import { formatText } from '~/utils/dom';
import styles from './styles.scss';
import { connect } from 'react-redux';
import { selectAuthProfile } from '~/redux/auth/selectors';
import { ProfileLoader } from '~/containers/profile/ProfileLoader';
const mapStateToProps = state => ({
profile: selectAuthProfile(state),
});
type IProps = ReturnType<typeof mapStateToProps> & {};
const ProfileDescriptionUnconnected: FC<IProps> = ({ profile: { user, is_loading } }) => {
if (is_loading) return <ProfileLoader />;
return (
<div className={styles.wrap}>
{user.description && <div className={styles.content}>{formatText(user.description)}</div>}
{!user.description && (
<div className={styles.placeholder}>
{user.fullname || user.username} пока ничего не рассказал о себе
</div>
)}
</div>
);
};
const ProfileDescription = connect(mapStateToProps)(ProfileDescriptionUnconnected);
export { ProfileDescription };

View file

@ -0,0 +1,14 @@
.content {
}
.placeholder {
display: flex;
align-items: center;
justify-content: center;
min-height: 33vh;
padding: 40px;
box-sizing: border-box;
color: transparentize($color: white, $amount: 0.8);
text-transform: uppercase;
font: $font_16_semibold;
}

View file

@ -5,9 +5,10 @@ import { IDialogProps } from '~/redux/types';
import { connect } from 'react-redux';
import { selectAuthProfile } from '~/redux/auth/selectors';
import { ProfileMessages } from '~/containers/profile/ProfileMessages';
import { ProfileDescription } from '~/components/profile/ProfileDescription';
const TAB_CONTENT = {
profile: <div>PROFILE</div>,
profile: <ProfileDescription />,
messages: <ProfileMessages />,
};
const mapStateToProps = selectAuthProfile;

View file

@ -26,6 +26,15 @@ const ProfileMessagesUnconnected: FC<IProps> = ({ profile, user: { id }, authGet
authGetMessages(profile.user.username);
}, [profile.user]);
useEffect(() => {
if (profile.is_loading || !profile.user || !profile.user.username || profile.messages_error)
return;
const timer = setTimeout(() => authGetMessages(profile.user.username), 20000);
return () => clearTimeout(timer);
}, [profile.user, profile.messages]);
if (!profile.messages.length || profile.is_loading)
return <NodeNoComments is_loading={profile.is_loading_messages || profile.is_loading} />;

View file

@ -48,6 +48,7 @@ export const EMPTY_USER: IUser = {
is_user: false,
last_seen: null,
fullname: null,
description: null,
};
export interface IApiUser {

View file

@ -15,6 +15,7 @@ export interface IUser {
name: string;
last_seen: string;
fullname: string;
description: string;
is_activated: boolean;
is_user: boolean;