mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
removed profile redux items
This commit is contained in:
parent
5b28313afd
commit
3c0571816c
55 changed files with 488 additions and 710 deletions
|
@ -1,69 +0,0 @@
|
|||
import React, { FC, useCallback, useEffect } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import { SidebarWrapper } from '~/containers/sidebars/SidebarWrapper';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectAuthProfile, selectAuthUser } from '~/redux/auth/selectors';
|
||||
import pick from 'ramda/es/pick';
|
||||
import { ProfileSidebarInfo } from '~/components/profile/ProfileSidebarInfo';
|
||||
import { Filler } from '~/components/containers/Filler';
|
||||
import { Route, Switch, useHistory, useRouteMatch } from 'react-router';
|
||||
import * as USER_ACTIONS from '~/redux/auth/actions';
|
||||
import { ProfileSidebarMenu } from '~/components/profile/ProfileSidebarMenu';
|
||||
import { useCloseOnEscape } from '~/hooks';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { ProfileSidebarSettings } from '~/components/profile/ProfileSidebarSettings';
|
||||
import classNames from 'classnames';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
profile: selectAuthProfile(state),
|
||||
user: pick(['id'], selectAuthUser(state)),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
authLoadProfile: USER_ACTIONS.authLoadProfile,
|
||||
};
|
||||
|
||||
type Props = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
||||
|
||||
const ProfileSidebarUnconnected: FC<Props> = ({
|
||||
profile: { is_loading, user },
|
||||
user: { id },
|
||||
authLoadProfile,
|
||||
}) => {
|
||||
const {
|
||||
params: { username },
|
||||
url,
|
||||
} = useRouteMatch<{ username: string }>();
|
||||
|
||||
useEffect(() => {
|
||||
authLoadProfile(username);
|
||||
}, [authLoadProfile, username]);
|
||||
|
||||
const history = useHistory();
|
||||
const basePath = url.replace(new RegExp(`\/~${username}$`), '');
|
||||
const onClose = useCallback(() => history.push(basePath), [basePath, history]);
|
||||
|
||||
useCloseOnEscape(onClose);
|
||||
|
||||
return (
|
||||
<SidebarWrapper>
|
||||
<div className={styles.close} onClick={onClose}>
|
||||
<Icon icon="close" size={32} />
|
||||
</div>
|
||||
|
||||
<Switch>
|
||||
<Route path={`${url}/settings`} component={ProfileSidebarSettings} />
|
||||
</Switch>
|
||||
|
||||
<div className={classNames(styles.wrap, styles.secondary)}>
|
||||
{!!user && <ProfileSidebarInfo is_loading={is_loading} user={user} />}
|
||||
<ProfileSidebarMenu path={url} />
|
||||
<Filler />
|
||||
</div>
|
||||
</SidebarWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
const ProfileSidebar = connect(mapStateToProps, mapDispatchToProps)(ProfileSidebarUnconnected);
|
||||
|
||||
export { ProfileSidebar };
|
|
@ -1,33 +0,0 @@
|
|||
@import "src/styles/variables";
|
||||
|
||||
.wrap {
|
||||
@include sidebar_content;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
|
||||
&.secondary {
|
||||
background: transparentize($content_bg, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.close {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
padding: $gap / 2;
|
||||
background: $content_bg;
|
||||
z-index: 6;
|
||||
border-radius: 0 0 0 $radius;
|
||||
cursor: pointer;
|
||||
transition: all 100ms;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
fill: $red;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
import React, { FC, useEffect, useRef } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { clearAllBodyScrollLocks, disableBodyScroll } from 'body-scroll-lock';
|
||||
import { useCloseOnEscape } from '~/hooks';
|
||||
import React, { FC, useEffect, useRef } from "react";
|
||||
import styles from "./styles.module.scss";
|
||||
import { createPortal } from "react-dom";
|
||||
import { clearAllBodyScrollLocks, disableBodyScroll } from "body-scroll-lock";
|
||||
import { useCloseOnEscape } from "~/hooks";
|
||||
|
||||
interface IProps {
|
||||
onClose?: () => void;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue