aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Post.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r--vnext/src/ui/Post.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/vnext/src/ui/Post.js b/vnext/src/ui/Post.js
index dc1c7a9d..662f9f78 100644
--- a/vnext/src/ui/Post.js
+++ b/vnext/src/ui/Post.js
@@ -1,16 +1,18 @@
-import React, { memo } from 'react';
+import React, { useState } from 'react';
import ReactRouterPropTypes from 'react-router-prop-types';
import { UserType } from './Types';
import qs from 'qs';
+import Button from './Button';
import MessageInput from './MessageInput';
import { post, update } from '../api';
-function PostComponent({ location, visitor, history }) {
+export default function Post({ location, visitor, history }) {
let draftMessage = (location.state || {}).draft || {};
+ let [draft, setDraft] = useState(draftMessage.body);
let params = qs.parse(window.location.search.substring(1));
let postMessage = (template) => {
const { attach, body } = template;
@@ -23,18 +25,32 @@ function PostComponent({ location, visitor, history }) {
}
}).catch(console.log);
};
+ let appendTag = (tag) => {
+ setDraft(prevDraft => {
+ return `${prevDraft || ''} *${tag} `;
+ });
+ };
return (
<div className="msg-cont">
- <MessageInput rows="7" text={params.body || draftMessage.body || ''} data={{ mid: 0, timestamp: '0' }} onSend={postMessage}>
+ <MessageInput rows="7" text={params.body || draft || ''} data={{ mid: 0, timestamp: '0' }} onSend={postMessage}>
*weather It is very cold today!
- </MessageInput>
+ </MessageInput>
+ {
+ visitor.tagStats &&
+ <div style={{ padding: '6px' }}>
+ <p>Tags:</p>
+ {
+ visitor.tagStats.map(t => {
+ return (<Button key={t.tag} onClick={() => { appendTag(t.tag); }}>{t.tag}</Button>);
+ })
+ }
+ </div>
+ }
</div>
);
}
-export default memo(PostComponent);
-
-PostComponent.propTypes = {
+Post.propTypes = {
location: ReactRouterPropTypes.location,
history: ReactRouterPropTypes.history.isRequired,
visitor: UserType