mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
displaying profile backdrop
This commit is contained in:
parent
0eae79ec08
commit
327272a08a
5 changed files with 99 additions and 6 deletions
|
@ -3,17 +3,24 @@ import { BetterScrollDialog } from '../BetterScrollDialog';
|
|||
import { ProfileInfo } from '~/containers/profile/ProfileInfo';
|
||||
import { IDialogProps } from '~/redux/types';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectAuthProfile } from '~/redux/auth/selectors';
|
||||
import { selectAuthProfile, selectAuthUser } from '~/redux/auth/selectors';
|
||||
import { ProfileMessages } from '~/containers/profile/ProfileMessages';
|
||||
import { ProfileDescription } from '~/components/profile/ProfileDescription';
|
||||
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
||||
import { IAuthState } from '~/redux/auth/types';
|
||||
import pick from 'ramda/es/pick';
|
||||
import { ProfileBackdrop } from '~/components/profile/ProfileBackdrop';
|
||||
|
||||
const TAB_CONTENT = {
|
||||
profile: <ProfileDescription />,
|
||||
messages: <ProfileMessages />,
|
||||
};
|
||||
const mapStateToProps = selectAuthProfile;
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
profile: selectAuthProfile(state),
|
||||
user: pick(['id'], selectAuthUser(state)),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
authSetProfile: AUTH_ACTIONS.authSetProfile,
|
||||
};
|
||||
|
@ -23,9 +30,9 @@ type IProps = IDialogProps & ReturnType<typeof mapStateToProps> & typeof mapDisp
|
|||
const ProfileDialogUnconnected: FC<IProps> = ({
|
||||
onRequestClose,
|
||||
authSetProfile,
|
||||
is_loading,
|
||||
user,
|
||||
tab,
|
||||
|
||||
profile: { is_loading, user, tab },
|
||||
user: { id },
|
||||
}) => {
|
||||
const setTab = useCallback((val: IAuthState['profile']['tab']) => authSetProfile({ tab: val }), [
|
||||
authSetProfile,
|
||||
|
@ -33,7 +40,16 @@ const ProfileDialogUnconnected: FC<IProps> = ({
|
|||
|
||||
return (
|
||||
<BetterScrollDialog
|
||||
header={<ProfileInfo is_loading={is_loading} user={user} tab={tab} setTab={setTab} />}
|
||||
header={
|
||||
<ProfileInfo
|
||||
is_own={user && user.id === id}
|
||||
is_loading={is_loading}
|
||||
user={user}
|
||||
tab={tab}
|
||||
setTab={setTab}
|
||||
/>
|
||||
}
|
||||
backdrop={<ProfileBackdrop cover={user && user.cover} />}
|
||||
onClose={onRequestClose}
|
||||
>
|
||||
{TAB_CONTENT[tab] || null}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue