mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 05:16:41 +07:00
added messages to profile dialog
This commit is contained in:
parent
618c2e3275
commit
298ba7d586
12 changed files with 62 additions and 24 deletions
|
@ -22,13 +22,15 @@ const mapDispatchToProps = {
|
||||||
push: historyPush,
|
push: historyPush,
|
||||||
showDialog: MODAL_ACTIONS.modalShowDialog,
|
showDialog: MODAL_ACTIONS.modalShowDialog,
|
||||||
authLogout: AUTH_ACTIONS.authLogout,
|
authLogout: AUTH_ACTIONS.authLogout,
|
||||||
|
authOpenProfile: AUTH_ACTIONS.authOpenProfile,
|
||||||
};
|
};
|
||||||
|
|
||||||
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
||||||
|
|
||||||
const HeaderUnconnected: FC<IProps> = memo(
|
const HeaderUnconnected: FC<IProps> = memo(
|
||||||
({ user, user: { username, is_user, photo }, showDialog, authLogout }) => {
|
({ user, user: { username, is_user }, showDialog, authLogout, authOpenProfile }) => {
|
||||||
const onLogin = useCallback(() => showDialog(DIALOGS.LOGIN), [showDialog]);
|
const onLogin = useCallback(() => showDialog(DIALOGS.LOGIN), [showDialog]);
|
||||||
|
const onProfileClick = useCallback(() => authOpenProfile(username), [authOpenProfile, user]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.container}>
|
<div className={style.container}>
|
||||||
|
@ -41,7 +43,9 @@ const HeaderUnconnected: FC<IProps> = memo(
|
||||||
<Link to="/">flow</Link>
|
<Link to="/">flow</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{is_user && <UserButton user={user} onLogout={authLogout} />}
|
{is_user && (
|
||||||
|
<UserButton user={user} onLogout={authLogout} onProfileClick={onProfileClick} />
|
||||||
|
)}
|
||||||
|
|
||||||
{!is_user && (
|
{!is_user && (
|
||||||
<Group horizontal className={style.user_button} onClick={onLogin}>
|
<Group horizontal className={style.user_button} onClick={onLogin}>
|
||||||
|
|
|
@ -10,12 +10,13 @@ import { Link } from 'react-router-dom';
|
||||||
interface IProps {
|
interface IProps {
|
||||||
user: Partial<IUser>;
|
user: Partial<IUser>;
|
||||||
onLogout: () => void;
|
onLogout: () => void;
|
||||||
|
onProfileClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UserButton: FC<IProps> = ({ user: { username, photo }, onLogout }) => (
|
const UserButton: FC<IProps> = ({ user: { username, photo }, onProfileClick, onLogout }) => (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<Group horizontal className={styles.user_button}>
|
<Group horizontal className={styles.user_button}>
|
||||||
<Link to={`/~${username}`}>{username}</Link>
|
<div onClick={onProfileClick}>{username}</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={styles.user_avatar}
|
className={styles.user_avatar}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ERRORS } from '~/constants/errors';
|
||||||
import { t } from '~/utils/trans';
|
import { t } from '~/utils/trans';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading: boolean;
|
is_loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NodeNoComments: FC<IProps> = ({ is_loading = false }) => (
|
const NodeNoComments: FC<IProps> = ({ is_loading = false }) => (
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const API = {
|
||||||
VKONTAKTE_LOGIN: `${process.env.API_HOST}/auth/vkontakte`,
|
VKONTAKTE_LOGIN: `${process.env.API_HOST}/auth/vkontakte`,
|
||||||
ME: '/auth/',
|
ME: '/auth/',
|
||||||
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
||||||
PROFILE: (username: string) => `/user/${username}`,
|
PROFILE: (username: string) => `/auth/user/${username}`,
|
||||||
},
|
},
|
||||||
NODE: {
|
NODE: {
|
||||||
SAVE: '/node/',
|
SAVE: '/node/',
|
||||||
|
|
|
@ -5,8 +5,12 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 40px;
|
padding: 70px 20px 40px 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
@include tablet {
|
||||||
|
padding: 70px 5px 5px 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { ProfileInfo } from '~/containers/profile/ProfileInfo';
|
||||||
import { IDialogProps } from '~/redux/types';
|
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 { NodeNoComments } from '~/components/node/NodeNoComments';
|
||||||
|
import { CommentForm } from '~/components/node/CommentForm';
|
||||||
|
|
||||||
const mapStateToProps = selectAuthProfile;
|
const mapStateToProps = selectAuthProfile;
|
||||||
const mapDispatchToProps = {};
|
const mapDispatchToProps = {};
|
||||||
|
@ -14,9 +16,14 @@ type IProps = IDialogProps & ReturnType<typeof mapStateToProps> & {};
|
||||||
const ProfileDialogUnconnected: FC<IProps> = ({ onRequestClose, is_loading, user }) => (
|
const ProfileDialogUnconnected: FC<IProps> = ({ onRequestClose, is_loading, user }) => (
|
||||||
<BetterScrollDialog
|
<BetterScrollDialog
|
||||||
header={<ProfileInfo is_loading={is_loading} user={user} />}
|
header={<ProfileInfo is_loading={is_loading} user={user} />}
|
||||||
|
footer={<CommentForm id="0" />}
|
||||||
onClose={onRequestClose}
|
onClose={onRequestClose}
|
||||||
>
|
>
|
||||||
<div className={styles.example} />
|
<div className={styles.messages}>
|
||||||
|
<NodeNoComments />
|
||||||
|
<NodeNoComments />
|
||||||
|
<NodeNoComments />
|
||||||
|
</div>
|
||||||
</BetterScrollDialog>
|
</BetterScrollDialog>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
.messages {
|
||||||
|
padding: $gap;
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { IUser } from '~/redux/auth/types';
|
import { IUser } from '~/redux/auth/types';
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
import { Grid } from '~/components/containers/Grid';
|
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Placeholder } from '~/components/placeholders/Placeholder';
|
import { Placeholder } from '~/components/placeholders/Placeholder';
|
||||||
|
import { getURL, getPrettyDate } from '~/utils/dom';
|
||||||
|
import { PRESETS } from '~/constants/urls';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
user?: IUser;
|
user?: IUser;
|
||||||
|
@ -11,14 +12,23 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProfileInfo: FC<IProps> = ({ user, is_loading = false }) => (
|
const ProfileInfo: FC<IProps> = ({ user, is_loading = false }) => (
|
||||||
|
<Group>
|
||||||
<Group className={styles.wrap} horizontal>
|
<Group className={styles.wrap} horizontal>
|
||||||
<div className={styles.avatar} />
|
<div
|
||||||
|
className={styles.avatar}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url("${user && getURL(user.photo, PRESETS.avatar)}")`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Group className={styles.field}>
|
<div className={styles.field}>
|
||||||
<div className={styles.name}>{is_loading ? <Placeholder width="80%" /> : 'User Name'}</div>
|
<div className={styles.name}>
|
||||||
|
{is_loading ? <Placeholder width="80%" /> : user.username}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={styles.desription}>
|
<div className={styles.description}>
|
||||||
{is_loading ? <Placeholder /> : 'Some description here'}
|
{is_loading ? <Placeholder /> : getPrettyDate(user.last_seen)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -2,27 +2,35 @@
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: flex-start !important;
|
align-items: flex-start !important;
|
||||||
// min-height: 64px;
|
// min-height: 64px;
|
||||||
padding: $gap;
|
// padding: $gap;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
@include outer_shadow();
|
@include outer_shadow();
|
||||||
|
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
width: 140px;
|
width: 100px;
|
||||||
height: 140px;
|
height: 100px;
|
||||||
background: $content_bg;
|
background: $content_bg 50% 50% no-repeat/cover;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -60px;
|
bottom: 0;
|
||||||
left: $gap;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
padding-left: 140px;
|
padding-left: 110px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
font: $font_24_bold;
|
font: $font_24_bold;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
color: transparentize($color: white, $amount: 0.7);
|
||||||
|
font: $font_14_regular;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ export const EMPTY_USER: IUser = {
|
||||||
cover: null,
|
cover: null,
|
||||||
is_activated: false,
|
is_activated: false,
|
||||||
is_user: false,
|
is_user: false,
|
||||||
|
last_seen: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IApiUser {
|
export interface IApiUser {
|
||||||
|
|
|
@ -104,8 +104,7 @@ function* openProfile({ username }: ReturnType<typeof authOpenProfile>) {
|
||||||
return yield put(modalSetShown(false));
|
return yield put(modalSetShown(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
yield put(authSetProfile({ is_loading: false }));
|
yield put(authSetProfile({ is_loading: false, user }));
|
||||||
console.log({ username, user });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function* authSaga() {
|
function* authSaga() {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface IUser {
|
||||||
photo: IFile;
|
photo: IFile;
|
||||||
cover: IFile;
|
cover: IFile;
|
||||||
name: string;
|
name: string;
|
||||||
|
last_seen: string;
|
||||||
|
|
||||||
is_activated: boolean;
|
is_activated: boolean;
|
||||||
is_user: boolean;
|
is_user: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue