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

Function useWhatsOff

packages/shared/src/features/feedExplain/useWhatsOff.ts:27–55  ·  view source on GitHub ↗
(version: number)

Source from the content-addressed store, hash-verified

25 * runs once per submit, never on render or refetch.
26 */
27export const useWhatsOff = (version: number): UseWhatsOff => {
28 const { logEvent } = useLogContext();
29 const {
30 mutate: ask,
31 reset: clear,
32 data: answer,
33 variables: text,
34 isPending,
35 error,
36 submittedAt,
37 } = useMutation({
38 mutationFn: (complaint: string) =>
39 getWhatsOff({
40 version,
41 text: complaint,
42 supportedTypes: feedV2SupportedTypes,
43 }),
44 onSuccess: (whatsOff) => {
45 logEvent({
46 event_name: LogEvent.SubmitWhatsOff,
47 target_type: TargetType.WhatsOff,
48 target_id: whatsOff.id,
49 extra: JSON.stringify(getWhatsOffSubmitExtra(whatsOff)),
50 });
51 },
52 });
53
54 return { answer, text, isPending, error, submittedAt, ask, clear };
55};

Callers 1

WhatsOffBoxFunction · 0.90

Calls 4

useLogContextFunction · 0.90
getWhatsOffFunction · 0.90
getWhatsOffSubmitExtraFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected