• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / bento-c3dc-frontend / 21959353841

12 Feb 2026 06:33PM UTC coverage: 0.154%. Remained the same
21959353841

push

github

web-flow
Merge pull request #488 from CBIIT/C3DC-2103

C3DC-2103 added unsaved changes check when duplicating cohorts

6 of 4086 branches covered (0.15%)

Branch coverage included in aggregate %.

0 of 47 new or added lines in 10 files covered. (0.0%)

3 existing lines in 3 files now uncovered.

10 of 6325 relevant lines covered (0.16%)

0.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/CohortModal/hooks/useModalState.js
1
import { useContext, useCallback } from 'react';
×
2
import { CohortModalContext } from '../CohortModalContext';
×
NEW
3
import { confirmationTypes } from '../components/shared/ConfirmationModal';
×
4

5
/**
6
 * Custom hook for managing modal state and close operations
7
 * @param {Function} onModalClose - Callback function when modal closes
8
 * @param {Function} modalClosed - Additional cleanup function
9
 * @returns {Object} Modal state management functions
10
 */
11
export const useModalState = (onModalClose, modalClosed) => {
×
12
  const {
13
    setSelectedCohort,
×
NEW
14
    setConfirmModalProps,
×
NEW
15
    setShowConfirmation
×
UNCOV
16
  } = useContext(CohortModalContext) || {};
×
17

18
  // Close modal wrapper, handles cleanup and state reset
19
  const closeModalWrapper = useCallback(() => {
×
20
    if (typeof modalClosed === 'function') {
×
21
      modalClosed();
×
22
    }
23
    if (typeof onModalClose === 'function') {
×
24
      onModalClose();
×
25
    }
26
    if (setSelectedCohort) {
×
27
      setSelectedCohort(null);
×
28
    }
29
  }, [modalClosed, onModalClose, setSelectedCohort]);
30

31
  const unSavedChangesCheck = useCallback((hasUnsavedChanges) => {
×
32
    if (hasUnsavedChanges) {
×
NEW
33
      if (setConfirmModalProps && setShowConfirmation) {
×
NEW
34
        setConfirmModalProps({
×
NEW
35
          handleConfirm: () => closeModalWrapper(),
×
36
          deletionType: confirmationTypes.CLEAR_UNSAVED_CHANGES,
37
        });
NEW
38
        setShowConfirmation(true);
×
39
      }
40
    } else {
41
      closeModalWrapper();
×
42
    }
43
  }, [closeModalWrapper, setConfirmModalProps, setShowConfirmation]);
44

45
  return {
×
46
    closeModalWrapper,
47
    unSavedChangesCheck
48
  };
49
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc