All files / src/hooks/useRegistrantNotice useRegistrantNotice.ts

0% Statements 0/4
100% Branches 0/0
0% Functions 0/4
0% Lines 0/4

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 25 26 27 28 29 30 31 32 33 34                                                                   
/**
 * useRegistrantNotice hooks (Story 7.3 hardening)
 *
 * React Query mutations for previewing + sending a registrant-targeted notice (e.g. the
 * "slides are online" mail) to an event's active registrants.
 */
 
import { useMutation, type UseMutationResult } from '@tanstack/react-query';
import * as registrantNoticeService from '@/services/registrantNoticeService';
import type {
  RegistrantNoticePreviewRequest,
  RegistrantNoticePreviewResponse,
  RegistrantNoticeSendResponse,
} from '@/services/registrantNoticeService';
 
/** Preview a registrant-notice template in a chosen language. */
export function usePreviewRegistrantNotice(
  eventCode: string
): UseMutationResult<RegistrantNoticePreviewResponse, Error, RegistrantNoticePreviewRequest> {
  return useMutation({
    mutationFn: (request: RegistrantNoticePreviewRequest) =>
      registrantNoticeService.preview(eventCode, request),
  });
}
 
/** Send a registrant-notice mail to the event's active registrants. */
export function useSendRegistrantNotice(
  eventCode: string
): UseMutationResult<RegistrantNoticeSendResponse, Error, string> {
  return useMutation({
    mutationFn: (templateKey: string) => registrantNoticeService.send(eventCode, templateKey),
  });
}