All files / src/hooks useRedirectionModal.ts

37.5% Statements 3/8
100% Branches 0/0
25% Functions 1/4
37.5% Lines 3/8

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 35        6x   6x                                                   6x    
import { useModal } from "@ebay/nice-modal-react";
import { GIVE_CONFIRMATION_POP_UP } from "modals/modal_names";
 
export default function useRedirectionModal() {
  const { show, hide } = useModal(GIVE_CONFIRMATION_POP_UP);
 
  const showRedirectionModal = (
    onConfirm: () => void,
    onCancel?: () => void,
  ) => {
    show({
      modalType: "redirection",
      title: "You’ve received a notification on another account.",
      description:
        "Would you like to redirect to the other account to view the notification?",
      actions: {
        handleSuccess: {
          onClick: () => {
            onConfirm();
            hide();
          },
        },
        handleCancel: {
          onClick: () => {
            onCancel?.();
            hide();
          },
        },
      },
    });
  };
 
  return { showRedirectionModal };
}