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/layouts/ProfileLayout/index.tsx
2022-01-07 18:32:22 +07:00

64 lines
2 KiB
TypeScript

import React, { FC, useEffect } from "react";
import styles from "./styles.module.scss";
import { RouteComponentProps } from "react-router";
import { useDispatch } from "react-redux";
import { authLoadProfile } from "~/redux/auth/actions";
import { useShallowSelect } from "~/hooks/data/useShallowSelect";
import { selectAuthProfile, selectUser } from "~/redux/auth/selectors";
import { ProfilePageLeft } from "~/containers/profile/ProfilePageLeft";
import { Container } from "~/containers/main/Container";
import { FlowGrid } from "~/components/flow/FlowGrid";
import { Sticky } from "~/components/containers/Sticky";
import { ProfilePageStats } from "~/containers/profile/ProfilePageStats";
import { Card } from "~/components/containers/Card";
import { useFlowStore } from "~/store/flow/useFlowStore";
import { observer } from "mobx-react";
type Props = RouteComponentProps<{ username: string }> & {};
const ProfileLayout: FC<Props> = observer(
({
match: {
params: { username },
},
}) => {
const { nodes } = useFlowStore();
const user = useShallowSelect(selectUser);
const dispatch = useDispatch();
useEffect(() => {
dispatch(authLoadProfile(username));
}, [dispatch, username]);
const profile = useShallowSelect(selectAuthProfile);
return (
<Container className={styles.wrap}>
<div className={styles.left}>
<Sticky>
<div className={styles.row}>
<ProfilePageLeft profile={profile} username={username} />
</div>
{!!profile.user?.description && (
<div className={styles.row}>
<Card className={styles.description}>{profile.user.description}</Card>
</div>
)}
<div className={styles.row}>
<ProfilePageStats />
</div>
</Sticky>
</div>
<div className={styles.grid}>
<FlowGrid nodes={nodes} user={user} onChangeCellView={console.log} />
</div>
</Container>
);
}
);
export { ProfileLayout };