All files / src/components/Modals SessionExpiredModal.tsx

100% Statements 9/9
50% Branches 1/2
100% Functions 2/2
100% Lines 9/9

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 36 37 38 39 40 41 42 43 44 45            1x 7x 7x 7x 7x   7x 1x 1x     7x                                                      
import NiceModal, { useModal } from "@ebay/nice-modal-react";
import useNiceModal from "@common/Modal/ModalFactory/hooks/useNiceModal";
import GivePopup from "@shared/Popup/GivePopup";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useResetApp } from "@hooks/common/useHandleLogout";
 
const SessionExpiredModal = NiceModal.create(() => {
  const modal = useModal();
  const { open, onClose } = useNiceModal();
  const { isMobileView } = useCustomThemeV2();
  const { handleReset } = useResetApp();
 
  const handleLogin = () => {
    modal.hide();
    handleReset(); // This will clear data and navigate to login
  };
 
  return (
    <GivePopup
      type="destructive"
      iconType="warning"
      isMobile={isMobileView}
      open={open}
      buttons={[
        {
          label: "Login",
          onClick: handleLogin,
          variant: "filled",
          color: "primary",
        },
      ]}
      paperSx={{
        ...(isMobileView && {
          maxHeight: "fit-content !important",
        }),
      }}
      onClose={onClose}
      description="For your security, your session has ended. Please log in again to continue."
      title="Session Expired"
    />
  );
});
 
export default SessionExpiredModal;