mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added boris route
This commit is contained in:
parent
c8ca961935
commit
cf16cbf0f9
7 changed files with 70 additions and 13 deletions
|
@ -17,6 +17,7 @@ import { BlurWrapper } from '~/components/containers/BlurWrapper';
|
|||
import { PageCover } from '~/components/containers/PageCover';
|
||||
import { NodeLayout } from './node/NodeLayout';
|
||||
import { BottomContainer } from '~/containers/main/BottomContainer';
|
||||
import { BorisLayout } from './node/BorisLayout';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
modal: selectModal(state),
|
||||
|
@ -41,6 +42,7 @@ const Component: FC<IProps> = ({ modal: { is_shown } }) => {
|
|||
<Route path={URLS.EXAMPLES.EDITOR} component={EditorExample} />
|
||||
<Route path="/examples/horizontal" component={HorizontalExample} />
|
||||
<Route path="/post:id" component={NodeLayout} />
|
||||
<Route path="/boris" component={BorisLayout} />
|
||||
|
||||
<Redirect to="/" />
|
||||
</Switch>
|
||||
|
|
45
src/containers/node/BorisLayout/index.tsx
Normal file
45
src/containers/node/BorisLayout/index.tsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import React, { FC, useEffect } from 'react';
|
||||
import { RouteComponentProps } from 'react-router';
|
||||
import * as NODE_ACTIONS from '~/redux/node/actions';
|
||||
import { selectNode } from '~/redux/node/selectors';
|
||||
import { selectUser } from '~/redux/auth/selectors';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
node: selectNode(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
nodeLoadNode: NODE_ACTIONS.nodeLoadNode,
|
||||
nodeUpdateTags: NODE_ACTIONS.nodeUpdateTags,
|
||||
nodeSetCoverImage: NODE_ACTIONS.nodeSetCoverImage,
|
||||
nodeEdit: NODE_ACTIONS.nodeEdit,
|
||||
nodeLike: NODE_ACTIONS.nodeLike,
|
||||
nodeStar: NODE_ACTIONS.nodeStar,
|
||||
};
|
||||
|
||||
type IProps = ReturnType<typeof mapStateToProps> &
|
||||
typeof mapDispatchToProps &
|
||||
RouteComponentProps<{ id: string }> & {};
|
||||
|
||||
const id = 696;
|
||||
|
||||
const BorisLayoutUnconnected: FC<IProps> = ({
|
||||
node: { is_loading, is_loading_comments, comments = [], current: node, related },
|
||||
nodeLoadNode,
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
if (is_loading) return;
|
||||
nodeLoadNode(id);
|
||||
}, [nodeLoadNode, id]);
|
||||
|
||||
return <div>{comments.length}</div>;
|
||||
};
|
||||
|
||||
const BorisLayout = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(BorisLayoutUnconnected);
|
||||
|
||||
export { BorisLayout };
|
|
@ -25,7 +25,7 @@ const mapStateToProps = state => ({
|
|||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
nodeLoadNode: NODE_ACTIONS.nodeLoadNode,
|
||||
nodeGotoNode: NODE_ACTIONS.nodeGotoNode,
|
||||
nodeUpdateTags: NODE_ACTIONS.nodeUpdateTags,
|
||||
nodeSetCoverImage: NODE_ACTIONS.nodeSetCoverImage,
|
||||
nodeEdit: NODE_ACTIONS.nodeEdit,
|
||||
|
@ -45,7 +45,7 @@ const NodeLayoutUnconnected: FC<IProps> = memo(
|
|||
node: { is_loading, is_loading_comments, comments = [], current: node, related },
|
||||
user,
|
||||
user: { is_user },
|
||||
nodeLoadNode,
|
||||
nodeGotoNode,
|
||||
nodeUpdateTags,
|
||||
nodeEdit,
|
||||
nodeLike,
|
||||
|
@ -58,8 +58,8 @@ const NodeLayoutUnconnected: FC<IProps> = memo(
|
|||
|
||||
useEffect(() => {
|
||||
if (is_loading) return;
|
||||
nodeLoadNode(parseInt(id, 10), null);
|
||||
}, [nodeLoadNode, id]);
|
||||
nodeGotoNode(parseInt(id, 10), null);
|
||||
}, [nodeGotoNode, id]);
|
||||
|
||||
const onTagsChange = useCallback(
|
||||
(tags: string[]) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue