All files / src/components/Processing ProcessingSendReceipt.tsx

0% Statements 0/18
0% Branches 0/2
0% Functions 0/5
0% Lines 0/16

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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134                                                                                                                                                                                                                                                                           
// nice-modal
import NiceModal, { muiDialogV5, useModal } from "@ebay/nice-modal-react";
// mui
import {
  Box,
  DialogActions,
  Stack,
  styled,
  useMediaQuery,
  useTheme,
} from "@mui/material";
// components
import { Text } from "@common/Text";
import { Button } from "@common/Button";
import { BaseModal } from "@common/Modal";
// assets
import { CloseIcon } from "@assets/icons";
import { useSendReceipt } from "@hooks/common/useSendReceipt";
// components
import { palette } from "@palette";
import Popup from "@common/Popup/Popup";
import { Card } from "@components/ManageMoney/TransactionTable/transactions.types";
 
type IProps = {
  id: string;
  transactionID: string;
  emails: string[];
  closeAction?: () => void;
  customerID?: number;
  sourceAccount: {
    fullName: string;
    card: Card | undefined;
    email?: string | undefined;
    firstName?: string | undefined;
    lastName?: string | undefined;
    phoneNumber?: string | undefined;
    name?: string | undefined;
    slug?: string | undefined;
    type?: string | undefined;
  };
  isChargebackReversal?: boolean;
};
 
const ProcessingSendReceipt = NiceModal.create(
  ({
    id,
    closeAction,
    transactionID,
    emails,
    sourceAccount,
    customerID,
    isChargebackReversal,
  }: IProps) => {
    const modal = useModal();
    const theme = useTheme();
    const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
 
    const { isLoading, handleSubmit } = useSendReceipt({
      transactionID,
      customerID,
      isChargebackReversal,
    });
 
    const handleSend = () => {
      handleSubmit({ recipients: [...emails] }, modal);
    };
 
    const handleClose = () => {
      modal.hide();
      if (closeAction) closeAction();
    };
 
    return (
      <Popup
        {...muiDialogV5(modal)}
        title="Send Receipt"
        onCancel={() => modal.hide()}
        onSubmit={handleSend}
        actionLabel="Send Receipt"
      >
        Please confirm you want to resend the email receipt to{" "}
        {sourceAccount.fullName} at {sourceAccount.email}
      </Popup>
    );
  },
);
 
const StyledModal = styled(BaseModal)(({ theme }) => ({
  [theme.breakpoints.down(800)]: {
    "& .MuiDialog-paper": {
      margin: "0 16px",
    },
  },
 
  [theme.breakpoints.down(601)]: {
    top: "50px",
    maxHeight: "90%",
    background: "#F9FCFF",
    "& .MuiDialog-paper": {
      borderRadius: "8px",
      height: "auto !important",
    },
  },
}));
 
const textStyle = {
  fontSize: 16,
  color: palette.neutral[600],
  "@media (max-width: 600px)": {
    textAlign: "center",
  },
};
 
const StyledButton = {
  border: "none",
  backgroundColor: "transparent",
  cursor: "pointer",
  position: "absolute",
  top: 7,
  right: 6,
};
 
const StyledTitle = {
  fontSize: 20,
  fontWeight: "600",
  color: palette.neutral[800],
  my: 1,
  "@media (max-width: 600px)": {
    textAlign: "center",
  },
};
 
export default ProcessingSendReceipt;