import { useMutation, useFlash } from '@redwoodjs/web' import { Link, routes, navigate } from '@redwoodjs/router' const DELETE_COMMENT_MUTATION = gql` mutation DeleteCommentMutation($id: String!) { deleteComment(id: $id) { id } } ` const jsonDisplay = (obj) => { return (
{JSON.stringify(obj, null, 2)}
)
}
const timeTag = (datetime) => {
return (
)
}
const checkboxInputTag = (checked) => {
return
}
const Comment = ({ comment }) => {
const { addMessage } = useFlash()
const [deleteComment] = useMutation(DELETE_COMMENT_MUTATION, {
onCompleted: () => {
navigate(routes.comments())
addMessage('Comment deleted.', { classes: 'rw-flash-success' })
},
})
const onDeleteClick = (id) => {
if (confirm('Are you sure you want to delete comment ' + id + '?')) {
deleteComment({ variables: { id } })
}
}
return (
<>
| Id | {comment.id} |
|---|---|
| Text | {comment.text} |
| User id | {comment.userId} |
| Part id | {comment.partId} |
| Created at | {timeTag(comment.createdAt)} |
| Updated at | {timeTag(comment.updatedAt)} |