@@ -492,24 +492,83 @@ const showNoMemberContactWarning = computed(() => {
492492 return ! hasMail || ! hasPhone ;
493493});
494494
495- // Use the appropriate composable based on entity type
496- const bulkEmailComposable =
495+ // We MUST separate the composable usages here, otherwise TypeScript infers incompatible types.
496+ const companyBulk = useBulkCompanyEmails ();
497+ const speakerBulk = useBulkSpeakerEmails ();
498+
499+ const processBulkEmails = async (
500+ templateCategory : EmailTemplateCategory ,
501+ statuses : ParticipationStatus [],
502+ entities : CompanyWithParticipation [] | SpeakerWithParticipation [],
503+ ) => {
504+ if (props .entityType === " companies" ) {
505+ return companyBulk .processBulkEmails (
506+ templateCategory ,
507+ statuses ,
508+ entities as CompanyWithParticipation [],
509+ );
510+ }
511+ return speakerBulk .processBulkEmails (
512+ templateCategory ,
513+ statuses ,
514+ entities as SpeakerWithParticipation [],
515+ );
516+ };
517+
518+ const sendProcessedEmails = async () => {
519+ if (props .entityType === " companies" ) {
520+ return companyBulk .sendProcessedEmails ();
521+ }
522+ return speakerBulk .sendProcessedEmails ();
523+ };
524+
525+ const isProcessing = computed (() =>
526+ props .entityType === " companies"
527+ ? companyBulk .isProcessing .value
528+ : speakerBulk .isProcessing .value ,
529+ );
530+
531+ const isSending = computed (() =>
532+ props .entityType === " companies"
533+ ? companyBulk .isSending .value
534+ : speakerBulk .isSending .value ,
535+ );
536+
537+ const processResult = computed (() =>
538+ props .entityType === " companies"
539+ ? companyBulk .processResult .value
540+ : speakerBulk .processResult .value ,
541+ );
542+
543+ const result = computed (() =>
544+ props .entityType === " companies"
545+ ? companyBulk .result .value
546+ : speakerBulk .result .value ,
547+ );
548+
549+ const processedCount = computed (() =>
550+ props .entityType === " companies"
551+ ? companyBulk .processedCount .value
552+ : speakerBulk .processedCount .value ,
553+ );
554+
555+ const totalToProcess = computed (() =>
497556 props .entityType === " companies"
498- ? useBulkCompanyEmails ()
499- : useBulkSpeakerEmails ();
500-
501- const {
502- processBulkEmails,
503- sendProcessedEmails,
504- isProcessing,
505- isSending ,
506- processResult,
507- result,
508- processedCount,
509- totalToProcess,
510- sentCount,
511- totalToSend,
512- } = bulkEmailComposable ;
557+ ? companyBulk . totalToProcess . value
558+ : speakerBulk . totalToProcess . value ,
559+ );
560+
561+ const sentCount = computed (() =>
562+ props . entityType === " companies "
563+ ? companyBulk . sentCount . value
564+ : speakerBulk . sentCount . value ,
565+ );
566+
567+ const totalToSend = computed (() =>
568+ props . entityType === " companies "
569+ ? companyBulk . totalToSend . value
570+ : speakerBulk . totalToSend . value ,
571+ ) ;
513572
514573const isDialogOpen = ref (false );
515574const currentStep = ref (1 );
0 commit comments