All files / src/hooks/auth-api accountClosedPopup.tsx

80% Statements 4/5
50% Branches 1/2
50% Functions 1/2
80% Lines 4/5

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                2x   2x 1x     2x                                            
import NiceModal from "@ebay/nice-modal-react";
import GiveLink from "@shared/Link/GiveLink";
import { GIVE_CONFIRMATION_POP_UP } from "modals/modal_names";
 
// Matches the message returned by POST /password-resets (and POST
// /password-resets/{token}) when every merchant account the user owns is
// closed — see app/user/errors.go::ErrAccountClosed on the API side.
export const ACCOUNT_CLOSED_API_MESSAGE =
  "This account is closed. Please contact support.";
 
export const isAccountClosedError = (error: any): boolean =>
  error?.response?.status === 400 &&
  error?.response?.data?.message === ACCOUNT_CLOSED_API_MESSAGE;
 
export const showAccountClosedPopup = () => {
  NiceModal.show(GIVE_CONFIRMATION_POP_UP, {
    modalType: "warning",
    title: "Account Closed",
    description: (
      <>
        We regret to inform you that your account is currently closed. If you
        think this is an error, please reach out to our customer support team at{" "}
        <GiveLink
          link="mailto:support@givecorporation.com"
          sx={{ display: "inline" }}
        >
          support@givecorporation.com
        </GiveLink>{" "}
        for assistance.
      </>
    ),
    hideCancel: true,
    useDefaultOnClose: true,
    customSubmitBtnText: "Close",
  });
};