import React from 'react' import styles from './Alerts.module.scss' export const alertMessages = ( networkName?: string, transactionHash?: string ) => ({ noAccount: 'Web3 detected, but no account. Are you logged into your MetaMask account?', noCorrectNetwork: `Please connect to Main network. You are on ${networkName} right now.`, noWeb3: 'No Web3 detected. Install MetaMask, Brave, or Mist.', transaction: `See your transaction on etherscan.io.`, waitingForUser: 'Waiting for your confirmation', waitingConfirmation: 'Waiting for network confirmation, hang on', success: 'Confirmed. You are awesome, thanks!' }) export default function Alerts({ transactionHash, message }: { transactionHash: string | null message: { text: MessageChannel; status: string } | null }) { const constructMessage = () => { let messageOutput if (transactionHash) { messageOutput = message && message.text + '
' + alertMessages(null, transactionHash).transaction } else { messageOutput = message && message.text } return messageOutput } const classes = () => { const { status } = message if (status === 'success') { return styles.success } else if (status === 'error') { return styles.error } return styles.alert } return (
) }