error color

pull/5370/head
Aniket-Engg 2 years ago committed by Aniket
parent 81d2c4d408
commit 17bb30a38c
  1. 20
      apps/etherscan/src/app/views/ReceiptsView.tsx

@ -12,7 +12,7 @@ interface FormValues {
} }
export const ReceiptsView: React.FC = () => { export const ReceiptsView: React.FC = () => {
const [results, setResults] = useState("") const [results, setResults] = useState({succeed: false, message: ''})
const onGetReceiptStatus = async ( const onGetReceiptStatus = async (
values: FormValues, values: FormValues,
clientInstance: any, clientInstance: any,
@ -21,7 +21,10 @@ export const ReceiptsView: React.FC = () => {
try { try {
const network = await getNetworkName(clientInstance) const network = await getNetworkName(clientInstance)
if (network === "vm") { if (network === "vm") {
setResults("Cannot verify in the selected network") setResults({
succeed: false,
message: "Cannot verify in the selected network"
})
return return
} }
const etherscanApi = getEtherScanApi(network) const etherscanApi = getEtherScanApi(network)
@ -30,9 +33,15 @@ export const ReceiptsView: React.FC = () => {
apiKey, apiKey,
etherscanApi etherscanApi
) )
setResults(result.result) setResults({
succeed: result.status === '1' ? true : false,
message: result.result
})
} catch (error: any) { } catch (error: any) {
setResults(error.message) setResults({
succeed: false,
message: error.message
})
} }
} }
@ -93,8 +102,9 @@ export const ReceiptsView: React.FC = () => {
marginTop: "2em", marginTop: "2em",
fontSize: "0.8em", fontSize: "0.8em",
textAlign: "center", textAlign: "center",
color: results['succeed'] ? "green" : "red"
}} }}
dangerouslySetInnerHTML={{ __html: results }} dangerouslySetInnerHTML={{ __html: results.message ? results.message : '' }}
/> />
<ReceiptsTable receipts={receipts} /> <ReceiptsTable receipts={receipts} />

Loading…
Cancel
Save