()
| 23 | } |
| 24 | |
| 25 | export default function useReportComment(): UseReportCommentRet { |
| 26 | const { user, showLogin } = useContext(AuthContext); |
| 27 | const { requestMethod } = useRequestProtocol(); |
| 28 | const request = requestMethod ?? gqlRequest; |
| 29 | const { mutateAsync: reportCommentAsync } = useMutation< |
| 30 | void, |
| 31 | unknown, |
| 32 | ReportCommentProps |
| 33 | >({ |
| 34 | mutationFn: (variables) => request(REPORT_COMMENT_MUTATION, variables), |
| 35 | }); |
| 36 | |
| 37 | const reportComment = async (params: ReportCommentProps) => { |
| 38 | if (!user) { |
| 39 | showLogin({ trigger: AuthTriggers.ReportPost }); |
| 40 | return { successful: false }; |
| 41 | } |
| 42 | |
| 43 | await reportCommentAsync(params); |
| 44 | |
| 45 | return { successful: true }; |
| 46 | }; |
| 47 | |
| 48 | return { reportComment }; |
| 49 | } |
no test coverage detected