This repository has been archived on 2025-11-04. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
qoverflow/client/src/controllers/QAControllers/CommentController.jsx
“spicecat” c7bf08de29 delete comment
2022-08-18 16:32:07 -04:00

20 lines
806 B
JavaScript

import { useUser } from 'contexts';
import { Comment } from 'components/QAComponents';
import { getCommentVote, deleteQuestionComment, updateCommentVote } from 'services/questionsServices';
export default function CommentController({ comment_id, question_id, ...props }) {
const { userData } = useUser();
const getVote = () => getCommentVote(question_id, comment_id);
const updateVote = (data) => updateCommentVote(question_id, comment_id, data);
const onDelete = async () => {
if (userData?.username === props?.creator) {
const { status } = await deleteQuestionComment(question_id, comment_id);
if (status === 200)
window.location.reload(false);
}
}
return <Comment {...{ getVote, onDelete, updateVote, ...props }} />;
}