All files / src/features/Merchants/MerchantSidePanel/Modals/PreviewInvitationModal GivePreviewInvitationModal.tsx

100% Statements 9/9
87.5% Branches 7/8
100% Functions 2/2
100% Lines 8/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 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83                                    1x                 4x 4x 4x 4x     4x 4x                                                                               4x                
import NiceModal, { useModal } from "@ebay/nice-modal-react";
import GiveBaseModal from "@shared/modals/GiveBaseModal";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { Stack, StackProps } from "@mui/system";
import { styled, useAppTheme } from "@theme/v2/Provider";
import PreviewInvitationModalHeader from "./components/PreviewInvitationModalHeader";
import PreviewInvitationModalCard from "./components/PreviewInvitationModalCard";
import PreviewInvitationModalFooter from "./components/PreviewInvitationModalFooter";
 
type TGivePreviewInvitationModal = {
  receiverName?: string;
  receiverPAHName?: string;
  senderName?: string;
  senderLogo?: string;
  isSendingToProvider: boolean;
  isPAHFromMerchantCreation?: boolean;
};
 
const GivePreviewInvitationModal = NiceModal.create(
  ({
    receiverName,
    senderName,
    senderLogo,
    isSendingToProvider,
    receiverPAHName,
    isPAHFromMerchantCreation,
  }: TGivePreviewInvitationModal) => {
    const { isMobileView } = useCustomThemeV2();
    const { remove, visible } = useModal();
    const receiverCorrectName = receiverName || "";
    const senderCorrectName = isSendingToProvider
      ? "GivePayments Team"
      : senderName || "";
    const { palette } = useAppTheme();
    return (
      <GiveBaseModal
        data-testid="preview-invitation-modal"
        title="Preview Invitation"
        open={visible}
        onClose={remove}
        width="720px"
        showFooter={false}
        customContentPadding={"84px 20px 20px 20px"}
        PaperProps={{
          sx: {
            bgcolor: `${palette.surface?.secondary} !important`,
            ...(isMobileView ? { height: "auto !important" } : {}),
          },
        }}
      >
        <PreviewInvitationModalContainer data-testid="preview-invitation-modal-container">
          <PreviewInvitationModalHeader
            senderName={senderCorrectName}
            senderLogo={senderLogo}
            isSendingToProvider={isSendingToProvider}
          />
          <PreviewInvitationModalCard
            receiverName={receiverCorrectName}
            senderName={senderCorrectName}
            isSendingToProvider={isSendingToProvider}
            receiverPAHName={receiverPAHName}
            isPAHFromMerchantCreation={isPAHFromMerchantCreation}
          />
          <PreviewInvitationModalFooter
            isPAHFromMerchantCreation={isPAHFromMerchantCreation}
          />
        </PreviewInvitationModalContainer>
      </GiveBaseModal>
    );
  },
);
 
export default GivePreviewInvitationModal;
 
const PreviewInvitationModalContainer = styled(Stack)<StackProps>(() => ({
  alignItems: "center",
  justifyContent: "flex-start",
  gap: "48px",
  overflowY: "auto",
  height: "100%",
  width: "100%",
}));