All files / src/application createReport.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 5/5
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                      24x   7x 3x   1x     2x        
import { useMutation } from "@tanstack/react-query";
import { useToastStore } from "../presentation/stores/toast.store";
import { createReport } from "../infrastructure/report.api";
 
interface ReportParams {
  senderEmail: string|null;
  reason: string;
  nickId: number;
}
 
export function useCreateReport() {
  const addToast = useToastStore(s => s.addToast);
 
  return useMutation<void, Error, ReportParams>({
    mutationFn: (params) => createReport(params),
    onSuccess: () => {
      addToast({ type: "success", message: "Signalement enregistré !" });
    },
    onError: (err) => {
      addToast({ type: "error", message: err.message || "Erreur lors de l'envoi" });
    }
  });
}