From f9330000c2fd50f9e6147480828c9b9ef691ebb9 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 9 Oct 2019 12:58:47 +0700 Subject: [PATCH] fixed typings and props for node tags --- src/components/node/NodeTags/index.tsx | 19 ++++++++----------- src/components/node/Tags/index.tsx | 4 ++-- src/containers/node/NodeLayout/index.tsx | 15 +++++++++------ src/redux/node/constants.ts | 1 + src/redux/types.ts | 2 ++ 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/components/node/NodeTags/index.tsx b/src/components/node/NodeTags/index.tsx index 40e8b8a9..3e153572 100644 --- a/src/components/node/NodeTags/index.tsx +++ b/src/components/node/NodeTags/index.tsx @@ -1,18 +1,15 @@ import React, { FC } from 'react'; import { Tags } from '../Tags'; +import { ITag } from '~/redux/types'; -interface IProps {} +interface IProps { + is_editable?: boolean; + tags: ITag[]; + onChange?: (tags: string[]) => void; +} -const NodeTags: FC = ({}) => ( - +const NodeTags: FC = ({ is_editable, tags, onChange }) => ( + ); export { NodeTags }; diff --git a/src/components/node/Tags/index.tsx b/src/components/node/Tags/index.tsx index 3792513a..013e7d66 100644 --- a/src/components/node/Tags/index.tsx +++ b/src/components/node/Tags/index.tsx @@ -6,7 +6,7 @@ import { Tag } from '~/components/node/Tag'; type IProps = HTMLAttributes & { tags: ITag[]; is_editable?: boolean; - onChange?: (tags: string[]) => void; + onTagsChange?: (tags: string[]) => void; }; export const Tags: FC = ({ tags, is_editable, onChange, ...props }) => { @@ -25,7 +25,7 @@ export const Tags: FC = ({ tags, is_editable, onChange, ...props }) => { ))} - + {is_editable && } ); }; diff --git a/src/containers/node/NodeLayout/index.tsx b/src/containers/node/NodeLayout/index.tsx index 31aad017..ebd3428c 100644 --- a/src/containers/node/NodeLayout/index.tsx +++ b/src/containers/node/NodeLayout/index.tsx @@ -16,8 +16,13 @@ import { NodeTags } from '~/components/node/NodeTags'; import { NODE_COMPONENTS } from '~/redux/node/constants'; import * as NODE_ACTIONS from '~/redux/node/actions'; import { CommentForm } from '~/components/node/CommentForm'; +import { selectUser } from '~/redux/auth/selectors'; + +const mapStateToProps = state => ({ + node: selectNode(state), + user: selectUser(state), +}); -const mapStateToProps = selectNode; const mapDispatchToProps = { nodeLoadNode: NODE_ACTIONS.nodeLoadNode, }; @@ -30,10 +35,8 @@ const NodeLayoutUnconnected: FC = ({ match: { params: { id }, }, - is_loading, - is_loading_comments, - comments = [], - current: node, + node: { is_loading, is_loading_comments, comments = [], current: node }, + user: { is_user }, nodeLoadNode, }) => { useEffect(() => { @@ -64,7 +67,7 @@ const NodeLayoutUnconnected: FC = ({
- + diff --git a/src/redux/node/constants.ts b/src/redux/node/constants.ts index 5ca22612..0f43506b 100644 --- a/src/redux/node/constants.ts +++ b/src/redux/node/constants.ts @@ -37,6 +37,7 @@ export const EMPTY_NODE: INode = { type: null, blocks: [], + tags: [], options: { flow: { diff --git a/src/redux/types.ts b/src/redux/types.ts index 8fa3b730..4c3ffead 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -110,6 +110,8 @@ export interface INode { }; }; + tags: ITag[]; + createdAt?: string; updatedAt?: string; }