All files / src/sections/AvatarModal GiveLogoutModal.tsx

71.42% Statements 10/14
37.5% Branches 3/8
66.66% Functions 2/3
83.33% Lines 10/12

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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                      1x         12x 12x 12x   12x       12x 6x 6x     12x         12x                                                            
import useNiceModal from "@common/Modal/ModalFactory/hooks/useNiceModal";
import { useHandleLogout } from "@hooks/common/useHandleLogout";
import GivePopup from "@shared/Popup/GivePopup";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
 
interface GiveLogoutModalProps {
  description?: string;
  onConfirm?: () => Promise<void>;
  onCancel?: () => void;
}
 
const GiveLogoutModal = ({
  description,
  onConfirm,
  onCancel,
}: GiveLogoutModalProps) => {
  const { open, onClose } = useNiceModal();
  const { submitLogout } = useHandleLogout();
  const { isMobileView } = useCustomThemeV2();
 
  const popupDescription = description
    ? description
    : "You can always log back in at any time. If you are a member of other merchants you can easily switch accounts from the sidebar.";
 
  const onSubmitLogout = async () => {
    Iif (onConfirm) await onConfirm();
    await submitLogout();
  };
 
  const handleClose = () => {
    onClose();
    if (onCancel) onCancel();
  };
 
  return (
    <GivePopup
      type="success"
      iconType="logout"
      isMobile={isMobileView}
      open={open}
      actionButtons={{
        cancel: {
          label: "Cancel",
          onClick: handleClose,
        },
        success: {
          label: "Yes, Log Out",
          onClick: onSubmitLogout,
        },
      }}
      paperSx={{
        ...(isMobileView && {
          maxHeight: "fit-content !important",
        }),
        top: "0 !important",
      }}
      onClose={handleClose}
      description={popupDescription}
      title="Log Out"
    />
  );
};
 
export default GiveLogoutModal;