all toasters removed

pull/5370/head
Aniket-Engg 1 year ago committed by Aniket
parent 12b3db7db0
commit bad9b18e58
  1. 23
      apps/etherscan/src/app/views/CaptureKeyView.tsx
  2. 5
      apps/etherscan/src/app/views/HomeView.tsx
  3. 5
      apps/etherscan/src/app/views/ReceiptsView.tsx

@ -1,4 +1,4 @@
import React from "react" import React, { useState } from "react"
import { Formik, ErrorMessage, Field } from "formik" import { Formik, ErrorMessage, Field } from "formik"
import { useNavigate, useLocation } from "react-router-dom" import { useNavigate, useLocation } from "react-router-dom"
@ -9,15 +9,14 @@ import { SubmitButton } from "../components"
export const CaptureKeyView: React.FC = () => { export const CaptureKeyView: React.FC = () => {
const location = useLocation() const location = useLocation()
const navigate = useNavigate() const navigate = useNavigate()
const [msg, setMsg] = useState("")
return ( return (
<AppContext.Consumer> <AppContext.Consumer>
{({ apiKey, clientInstance, setAPIKey }) => { {({ apiKey, clientInstance, setAPIKey }) => {
if (!apiKey && clientInstance && clientInstance.call) { if (!apiKey) setMsg('Please add API key to continue. It should be 34 characters long')
clientInstance.call('sidePanel' as any, 'currentFocus').then((current) => { return (
if (current === 'etherscan') clientInstance.call('notification' as any, 'toast', 'Please add API key to continue') <div>
}) <Formik
}
return <Formik
initialValues={{ apiKey }} initialValues={{ apiKey }}
validate={(values) => { validate={(values) => {
const errors = {} as any const errors = {} as any
@ -32,7 +31,6 @@ export const CaptureKeyView: React.FC = () => {
const apiKey = values.apiKey const apiKey = values.apiKey
if (apiKey.length === 34) { if (apiKey.length === 34) {
setAPIKey(values.apiKey) setAPIKey(values.apiKey)
clientInstance.call('notification' as any, 'toast', 'API key saved successfully!!!')
navigate((location && location.state ? location.state : '/')) navigate((location && location.state ? location.state : '/'))
} }
}} }}
@ -64,6 +62,15 @@ export const CaptureKeyView: React.FC = () => {
</form> </form>
)} )}
</Formik> </Formik>
<div
data-id="api-key-result"
className="text-primary mt-4 text-center"
style={{fontSize: "0.8em"}}
dangerouslySetInnerHTML={{ __html: msg }}
/>
</div>
)
}} }}
</AppContext.Consumer> </AppContext.Consumer>
) )

@ -11,11 +11,6 @@ export const HomeView: React.FC = () => {
return ( return (
<AppContext.Consumer> <AppContext.Consumer>
{({ apiKey, clientInstance, setReceipts, receipts, contracts }) => { {({ apiKey, clientInstance, setReceipts, receipts, contracts }) => {
if (!apiKey && clientInstance && clientInstance.call) {
clientInstance.call('sidePanel' as any, 'currentFocus').then((current) => {
if (current === 'etherscan') clientInstance.call('notification' as any, 'toast', 'Please add API key to continue')
})
}
return !apiKey ? ( return !apiKey ? (
<Navigate <Navigate
to={{ to={{

@ -64,11 +64,6 @@ export const ReceiptsView: React.FC = () => {
return ( return (
<AppContext.Consumer> <AppContext.Consumer>
{({ apiKey, clientInstance, receipts, setReceipts }) => { {({ apiKey, clientInstance, receipts, setReceipts }) => {
if (!apiKey && clientInstance && clientInstance.call) {
clientInstance.call('sidePanel' as any, 'currentFocus').then((current) => {
if (current === 'etherscan') clientInstance.call('notification' as any, 'toast', 'Please add API key to continue')
})
}
return !apiKey ? ( return !apiKey ? (
<Navigate <Navigate
to={{ to={{

Loading…
Cancel
Save