1- import React from "react"
1+ import React , { useState } from "react"
22
33import { Formik , ErrorMessage , Field } from "formik"
44import { useNavigate , useLocation } from "react-router-dom"
@@ -9,15 +9,14 @@ import { SubmitButton } from "../components"
99export const CaptureKeyView : React . FC = ( ) => {
1010 const location = useLocation ( )
1111 const navigate = useNavigate ( )
12+ const [ msg , setMsg ] = useState ( "" )
1213 return (
1314 < AppContext . Consumer >
1415 { ( { apiKey, clientInstance, setAPIKey } ) => {
15- if ( ! apiKey && clientInstance && clientInstance . call ) {
16- clientInstance . call ( 'sidePanel' as any , 'currentFocus' ) . then ( ( current ) => {
17- if ( current === 'etherscan' ) clientInstance . call ( 'notification' as any , 'toast' , 'Please add API key to continue' )
18- } )
19- }
20- return < Formik
16+ if ( ! apiKey ) setMsg ( 'Please add API key to continue. It should be 34 characters long' )
17+ return (
18+ < div >
19+ < Formik
2120 initialValues = { { apiKey } }
2221 validate = { ( values ) => {
2322 const errors = { } as any
@@ -32,7 +31,6 @@ export const CaptureKeyView: React.FC = () => {
3231 const apiKey = values . apiKey
3332 if ( apiKey . length === 34 ) {
3433 setAPIKey ( values . apiKey )
35- clientInstance . call ( 'notification' as any , 'toast' , 'API key saved successfully!!!' )
3634 navigate ( ( location && location . state ? location . state : '/' ) )
3735 }
3836 } }
@@ -59,11 +57,20 @@ export const CaptureKeyView: React.FC = () => {
5957 </ div >
6058
6159 < div >
62- < SubmitButton text = "Save" dataId = "save-api-key" disable = { errors && errors . apiKey ? true : false } />
60+ < SubmitButton text = "Save" dataId = "save-api-key" disable = { errors && errors . apiKey ? true : false } />
6361 </ div >
6462 </ form >
6563 ) }
6664 </ Formik >
65+
66+ < div
67+ data-id = "api-key-result"
68+ className = "text-primary mt-4 text-center"
69+ style = { { fontSize : "0.8em" } }
70+ dangerouslySetInnerHTML = { { __html : msg } }
71+ />
72+ </ div >
73+ )
6774 } }
6875 </ AppContext . Consumer >
6976 )
0 commit comments