Skip to content

Commit

Permalink
all toasters removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-Engg committed Jun 30, 2023
1 parent 4ec040c commit 75ee001
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
25 changes: 16 additions & 9 deletions apps/etherscan/src/app/views/CaptureKeyView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react"
import React, { useState } from "react"

import { Formik, ErrorMessage, Field } from "formik"
import { useNavigate, useLocation } from "react-router-dom"
Expand All @@ -9,15 +9,14 @@ import { SubmitButton } from "../components"
export const CaptureKeyView: React.FC = () => {
const location = useLocation()
const navigate = useNavigate()
const [msg, setMsg] = useState("")
return (
<AppContext.Consumer>
{({ apiKey, clientInstance, setAPIKey }) => {
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 <Formik
if (!apiKey) setMsg('Please add API key to continue. It should be 34 characters long')
return (
<div>
<Formik
initialValues={{ apiKey }}
validate={(values) => {
const errors = {} as any
Expand All @@ -32,7 +31,6 @@ export const CaptureKeyView: React.FC = () => {
const apiKey = values.apiKey
if (apiKey.length === 34) {
setAPIKey(values.apiKey)
clientInstance.call('notification' as any, 'toast', 'API key saved successfully!!!')
navigate((location && location.state ? location.state : '/'))
}
}}
Expand All @@ -59,11 +57,20 @@ export const CaptureKeyView: React.FC = () => {
</div>

<div>
<SubmitButton text="Save" dataId="save-api-key" disable={ errors && errors.apiKey ? true : false } />
<SubmitButton text="Save" dataId="save-api-key" disable={errors && errors.apiKey ? true : false } />
</div>
</form>
)}
</Formik>

<div
data-id="api-key-result"
className="text-primary mt-4 text-center"
style={{fontSize: "0.8em"}}
dangerouslySetInnerHTML={{ __html: msg }}
/>
</div>
)
}}
</AppContext.Consumer>
)
Expand Down
5 changes: 0 additions & 5 deletions apps/etherscan/src/app/views/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export const HomeView: React.FC = () => {
return (
<AppContext.Consumer>
{({ 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 ? (
<Navigate
to={{
Expand Down
5 changes: 0 additions & 5 deletions apps/etherscan/src/app/views/ReceiptsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ export const ReceiptsView: React.FC = () => {
return (
<AppContext.Consumer>
{({ 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 ? (
<Navigate
to={{
Expand Down

0 comments on commit 75ee001

Please sign in to comment.