1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fixed typings and props for node tags

This commit is contained in:
Fedor Katurov 2019-10-09 12:58:47 +07:00
parent df1c11a308
commit f9330000c2
5 changed files with 22 additions and 19 deletions

View file

@ -1,18 +1,15 @@
import React, { FC } from 'react'; import React, { FC } from 'react';
import { Tags } from '../Tags'; 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<IProps> = ({}) => ( const NodeTags: FC<IProps> = ({ is_editable, tags, onChange }) => (
<Tags <Tags tags={tags} is_editable={is_editable} onTagsChange={onChange} />
tags={[
{ title: 'Избранный', feature: 'red' },
{ title: 'Плейлист', feature: 'green' },
{ title: 'Просто' },
{ title: '+ фото', feature: 'black' },
{ title: '+ с музыкой', feature: 'black' },
]}
/>
); );
export { NodeTags }; export { NodeTags };

View file

@ -6,7 +6,7 @@ import { Tag } from '~/components/node/Tag';
type IProps = HTMLAttributes<HTMLDivElement> & { type IProps = HTMLAttributes<HTMLDivElement> & {
tags: ITag[]; tags: ITag[];
is_editable?: boolean; is_editable?: boolean;
onChange?: (tags: string[]) => void; onTagsChange?: (tags: string[]) => void;
}; };
export const Tags: FC<IProps> = ({ tags, is_editable, onChange, ...props }) => { export const Tags: FC<IProps> = ({ tags, is_editable, onChange, ...props }) => {
@ -25,7 +25,7 @@ export const Tags: FC<IProps> = ({ tags, is_editable, onChange, ...props }) => {
<Tag key={tag.title} title={tag.title} feature={tag.feature} /> <Tag key={tag.title} title={tag.title} feature={tag.feature} />
))} ))}
<Tag title={input} onInput={onInput} /> {is_editable && <Tag title={input} onInput={onInput} />}
</TagField> </TagField>
); );
}; };

View file

@ -16,8 +16,13 @@ import { NodeTags } from '~/components/node/NodeTags';
import { NODE_COMPONENTS } from '~/redux/node/constants'; import { NODE_COMPONENTS } from '~/redux/node/constants';
import * as NODE_ACTIONS from '~/redux/node/actions'; import * as NODE_ACTIONS from '~/redux/node/actions';
import { CommentForm } from '~/components/node/CommentForm'; 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 = { const mapDispatchToProps = {
nodeLoadNode: NODE_ACTIONS.nodeLoadNode, nodeLoadNode: NODE_ACTIONS.nodeLoadNode,
}; };
@ -30,10 +35,8 @@ const NodeLayoutUnconnected: FC<IProps> = ({
match: { match: {
params: { id }, params: { id },
}, },
is_loading, node: { is_loading, is_loading_comments, comments = [], current: node },
is_loading_comments, user: { is_user },
comments = [],
current: node,
nodeLoadNode, nodeLoadNode,
}) => { }) => {
useEffect(() => { useEffect(() => {
@ -64,7 +67,7 @@ const NodeLayoutUnconnected: FC<IProps> = ({
<div className={styles.panel}> <div className={styles.panel}>
<Group style={{ flex: 1, minWidth: 0 }}> <Group style={{ flex: 1, minWidth: 0 }}>
<NodeTags /> <NodeTags is_editable={is_user} tags={node.tags} onChange={console.log} />
<NodeRelated title="First album" /> <NodeRelated title="First album" />

View file

@ -37,6 +37,7 @@ export const EMPTY_NODE: INode = {
type: null, type: null,
blocks: [], blocks: [],
tags: [],
options: { options: {
flow: { flow: {

View file

@ -110,6 +110,8 @@ export interface INode {
}; };
}; };
tags: ITag[];
createdAt?: string; createdAt?: string;
updatedAt?: string; updatedAt?: string;
} }