All files / src/application sendContact.ts

83.33% Statements 5/6
0% Branches 0/2
80% Functions 4/5
80% Lines 4/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                      4x   1x 1x   1x              
// useSendContactMessage.ts
import { useMutation } from "@tanstack/react-query";
import { sendContactMessage } from "../infrastructure/contact.api";
import { useToastStore } from "../presentation/stores/toast.store";
 
interface ContactMessageParams {
  senderEmail: string;
  content: string;
}
 
export function useSendContactMessage() {
  const addToast = useToastStore(s => s.addToast);
 
  return useMutation<void, Error, ContactMessageParams>({
    mutationFn: (params) => sendContactMessage(params),
    onSuccess: () => {
      addToast({ type: "success", message: "Message envoyé !" });
    },
    onError: (err) => {
      addToast({ type: "error", message: err.message || "Erreur lors de l'envoi" });
    }
  });
}