import React, { useContext } from "react"
import { isString } from "lodash"
import { Alert, AlertTitle, Box } from "@mui/material"
import { faLink, faLinkSlash } from "@fortawesome/free-solid-svg-icons"
import { ConnectorContext } from "../../components/connector/sdk-connection-provider"
import { Icon } from "../../components/common/icon"
import { Address } from "../../components/common/address"
function connectionErrorMessage(error: any): string | null {
if (!error) {
return null
}
if (error.message) {
return error.message
} else if (isString(error)) {
return error.replace(/^error:\s/gi, "")
}
return null
}
export function ConnectionStatus() {
const connection = useContext(ConnectorContext)
switch (connection?.state.status) {
case "connected":
return }>
Current Status: connected
Application is connected to wallet
case "disconnected":
const error = connectionErrorMessage(connection?.state.error)
return }>
Disconnected
Application currently not connected to any wallet
{ error && Last attempt error: {error} }
case "connecting":
return
Connecting...
Connection to wallet in process
case "initializing":
return
Initializing...
Connector initialization
default:
return null
}
}