1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00
vault-frontend/src/containers/profile/ProfilePage/index.tsx
2020-11-06 12:15:07 +07:00

54 lines
1.4 KiB
TypeScript

import React, { FC, useEffect } from 'react';
import styles from './styles.module.scss';
import { ProfilePageLeft } from '../ProfilePageLeft';
import { Switch, Route, RouteComponentProps } from 'react-router';
import { IState } from '~/redux/store';
import { selectAuthProfile } from '~/redux/auth/selectors';
import { connect } from 'react-redux';
import * as AUTH_ACTIONS from '~/redux/auth/actions';
const mapStateToProps = (state: IState) => ({
profile: selectAuthProfile(state),
});
const mapDispatchToProps = {
authLoadProfile: AUTH_ACTIONS.authLoadProfile,
};
type Props = ReturnType<typeof mapStateToProps> &
typeof mapDispatchToProps &
RouteComponentProps<{ username: string }> & {};
const ProfilePageUnconnected: FC<Props> = ({
profile,
authLoadProfile,
match: {
params: { username },
},
}) => {
useEffect(() => {
authLoadProfile(username);
}, [username]);
return (
<div className={styles.wrap}>
<div className={styles.right}>
<Switch>
<Route path="/profile/:username" render={() => <div>DEFAULT</div>} />
<Route path="/profile/:username/tab" render={() => <div>TAB</div>} />
</Switch>
</div>
<div className={styles.left}>
<ProfilePageLeft profile={profile} username={username} />
</div>
</div>
);
};
const ProfilePage = connect(
mapStateToProps,
mapDispatchToProps
)(ProfilePageUnconnected);
export { ProfilePage };