import React, { FC } from "react";
import { noop } from "lodash";
import { TransactionStatus } from "@usedapp/core";
import { VStack } from "native-base";
import { TransText } from "../../layout";
import BasicStyledModal from "./BasicStyledModal";
import { LearnButton } from "../../buttons";
interface ITxModalProps {
type: "send" | "sign" | "signMultiClaim" | "identity" | "goodid";
isPending: boolean;
customTitle?: { title: { id: string; values: any } };
onClose?: () => void;
title?: string;
content?: string;
}
const txModalCopy = {
sign: {
title: /*i18n*/ "Please sign with \n your wallet",
content:
/*i18n*/ "To complete this action, sign with your wallet. It can take a moment for a transaction to be validated."
},
signMultiClaim: {
title: "",
content: /*i18n*/ "To complete this action, sign with your wallet."
},
goodid: {
title: /*i18n*/ "Please sign with \n your wallet",
content:
/*i18n*/ "To complete this action, sign with your wallet. It can take a moment for a transaction to be validated."
},
identity: {
title: /*i18n*/ "Sign to Verify Uniqueness",
content:
/*i18n*/ "You’ll be asked to sign with your wallet to begin the verification.You may have to do this again from time to time."
},
send: {
title: /*i18n*/ "Waiting for \n confirmation",
content: /*i18n*/ "Please wait for the transaction to be validated."
}
};
const TxModalContent = ({ content }: { content: string }) => (
);
const TxContentMultiClaim = ({ content }: { content: string }) => (
);
const TxContentIdentity = ({ content }: { content: string }) => (
);
const ContentComponent = {
sign: TxModalContent,
signMultiClaim: TxContentMultiClaim,
identity: TxContentIdentity,
send: TxModalContent,
goodid: TxModalContent
};
export const TxModal: FC = ({
isPending,
onClose = noop,
customTitle,
type,
...props
}: ITxModalProps) => {
const { title, content } = txModalCopy[type];
const Content = ContentComponent[type];
return (
}
footer={}
withOverlay="dark"
withCloseButton={false}
/>
);
};
export const TxModalStatus = ({
txStatus,
onClose
}: {
txStatus: TransactionStatus | Partial;
onClose: () => void;
}) => {
const { status } = txStatus;
//todo: add onSuccess handler
return status === "PendingSignature" || status === "CollectingSignaturePool" ? (
) : status === "Mining" ? (
) : null;
};