(version: number)
| 25 | * runs once per submit, never on render or refetch. |
| 26 | */ |
| 27 | export 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 | }; |
no test coverage detected