MCPcopy Create free account
hub / github.com/dailydotdev/apps / useReportComment

Function useReportComment

packages/shared/src/hooks/useReportComment.ts:25–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25export 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}

Callers 1

ReportCommentModalFunction · 0.85

Calls 2

useRequestProtocolFunction · 0.90
requestFunction · 0.85

Tested by

no test coverage detected