mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
displaying user description
This commit is contained in:
parent
371f47f866
commit
7f04fe1e36
7 changed files with 59 additions and 3 deletions
|
@ -2,10 +2,8 @@
|
||||||
@include outer_shadow();
|
@include outer_shadow();
|
||||||
padding: $gap;
|
padding: $gap;
|
||||||
background: $content_bg;
|
background: $content_bg;
|
||||||
// position: relative;
|
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
// margin-bottom: 40px;
|
|
||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
src/components/profile/ProfileDescription/index.tsx
Normal file
32
src/components/profile/ProfileDescription/index.tsx
Normal 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 };
|
14
src/components/profile/ProfileDescription/styles.scss
Normal file
14
src/components/profile/ProfileDescription/styles.scss
Normal 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;
|
||||||
|
}
|
|
@ -5,9 +5,10 @@ import { IDialogProps } from '~/redux/types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectAuthProfile } from '~/redux/auth/selectors';
|
import { selectAuthProfile } from '~/redux/auth/selectors';
|
||||||
import { ProfileMessages } from '~/containers/profile/ProfileMessages';
|
import { ProfileMessages } from '~/containers/profile/ProfileMessages';
|
||||||
|
import { ProfileDescription } from '~/components/profile/ProfileDescription';
|
||||||
|
|
||||||
const TAB_CONTENT = {
|
const TAB_CONTENT = {
|
||||||
profile: <div>PROFILE</div>,
|
profile: <ProfileDescription />,
|
||||||
messages: <ProfileMessages />,
|
messages: <ProfileMessages />,
|
||||||
};
|
};
|
||||||
const mapStateToProps = selectAuthProfile;
|
const mapStateToProps = selectAuthProfile;
|
||||||
|
|
|
@ -26,6 +26,15 @@ const ProfileMessagesUnconnected: FC<IProps> = ({ profile, user: { id }, authGet
|
||||||
authGetMessages(profile.user.username);
|
authGetMessages(profile.user.username);
|
||||||
}, [profile.user]);
|
}, [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)
|
if (!profile.messages.length || profile.is_loading)
|
||||||
return <NodeNoComments is_loading={profile.is_loading_messages || profile.is_loading} />;
|
return <NodeNoComments is_loading={profile.is_loading_messages || profile.is_loading} />;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ export const EMPTY_USER: IUser = {
|
||||||
is_user: false,
|
is_user: false,
|
||||||
last_seen: null,
|
last_seen: null,
|
||||||
fullname: null,
|
fullname: null,
|
||||||
|
description: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IApiUser {
|
export interface IApiUser {
|
||||||
|
|
|
@ -15,6 +15,7 @@ export interface IUser {
|
||||||
name: string;
|
name: string;
|
||||||
last_seen: string;
|
last_seen: string;
|
||||||
fullname: string;
|
fullname: string;
|
||||||
|
description: string;
|
||||||
|
|
||||||
is_activated: boolean;
|
is_activated: boolean;
|
||||||
is_user: boolean;
|
is_user: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue