import { Form, MarkdownInput, SubmitButton } from '../components/form' import { gql, useMutation } from '@apollo/client' import styles from './reply.module.css' import { EditFeeButton } from './fee-button' import Button from 'react-bootstrap/Button' import Delete from './delete' import { commentSchema } from '../lib/validate' export default function CommentEdit ({ comment, editThreshold, onSuccess, onCancel }) { const [updateComment] = useMutation( gql` mutation updateComment($id: ID! $text: String!) { updateComment(id: $id, text: $text) { text } }`, { update (cache, { data: { updateComment } }) { cache.modify({ id: `Item:${comment.id}`, fields: { text () { return updateComment.text } } }) } } ) return (
{ const { error } = await updateComment({ variables: { ...values, id: comment.id } }) if (error) { throw new Error({ message: error.toString() }) } if (onSuccess) { onSuccess() } }} >
) }