diff options
author | Sascha <GlancingMind@outlook.com> | 2021-03-17 18:19:16 +0100 |
---|---|---|
committer | Sascha <GlancingMind@outlook.com> | 2021-03-19 17:52:12 +0100 |
commit | 0e3caba922ba5a21a7e7aa0f433d944aacf58e78 (patch) | |
tree | 96c8cb722fbdc63334972df0e782c396cd91bb95 /webui/src/pages/bug/EditCommentForm.tsx | |
parent | 9f6c045f8b6e44e47300cec181217906f48d8261 (diff) | |
download | git-bug-0e3caba922ba5a21a7e7aa0f433d944aacf58e78.tar.gz |
Update comment on submit
Diffstat (limited to 'webui/src/pages/bug/EditCommentForm.tsx')
-rw-r--r-- | webui/src/pages/bug/EditCommentForm.tsx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/webui/src/pages/bug/EditCommentForm.tsx b/webui/src/pages/bug/EditCommentForm.tsx index 46cf1e1f..f5040064 100644 --- a/webui/src/pages/bug/EditCommentForm.tsx +++ b/webui/src/pages/bug/EditCommentForm.tsx @@ -7,7 +7,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles'; import CommentInput from '../../components/CommentInput/CommentInput'; import { BugFragment } from './Bug.generated'; -import { useAddCommentMutation } from './CommentForm.generated'; +import { useEditCommentMutation } from './EditCommentform.generated'; import { AddCommentFragment } from './MessageCommentFragment.generated'; import { CreateFragment } from './MessageCreateFragment.generated'; @@ -46,14 +46,23 @@ type Props = { }; function EditCommentForm({ bug, comment, onCancelClick, onPostSubmit }: Props) { - const [addComment, { loading }] = useAddCommentMutation(); - const [issueComment, setIssueComment] = useState<string>(comment.message); + const [editComment, { loading }] = useEditCommentMutation(); + const [message, setMessage] = useState<string>(comment.message); const [inputProp, setInputProp] = useState<any>(''); const classes = useStyles({ loading }); const form = useRef<HTMLFormElement>(null); const submit = () => { - console.log('submit: ' + issueComment); + console.log('submit: ' + message + '\nTo: ' + comment.id); + editComment({ + variables: { + input: { + prefix: bug.id, + message: message, + target: comment.id, + }, + }, + }); resetForm(); if (onPostSubmit) onPostSubmit(); }; @@ -66,7 +75,7 @@ function EditCommentForm({ bug, comment, onCancelClick, onPostSubmit }: Props) { const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); - if (issueComment.length > 0) submit(); + if (message.length > 0) submit(); }; function getCancelButton() { @@ -83,7 +92,7 @@ function EditCommentForm({ bug, comment, onCancelClick, onPostSubmit }: Props) { <CommentInput inputProps={inputProp} loading={loading} - onChange={(comment: string) => setIssueComment(comment)} + onChange={(message: string) => setMessage(message)} inputText={comment.message} /> <div className={classes.actions}> @@ -93,7 +102,7 @@ function EditCommentForm({ bug, comment, onCancelClick, onPostSubmit }: Props) { variant="contained" color="primary" type="submit" - disabled={loading || issueComment.length === 0} + disabled={loading || message.length === 0} > Update Comment </Button> |