parent
3f6b3a16c4
commit
ba1a3fbe4c
@ -0,0 +1,40 @@ |
||||
import React, { useEffect, useState, useContext } from 'react' |
||||
import { ethers } from 'ethers/' |
||||
|
||||
interface ConfigInputProps { |
||||
label: string |
||||
id: string |
||||
secret: boolean |
||||
initialValue: string |
||||
saveResult: (result: string) => void |
||||
} |
||||
|
||||
// Chooses one contract from the compilation output.
|
||||
export const ConfigInput: React.FC<ConfigInputProps> = ({ label, id, secret, initialValue, saveResult }) => { |
||||
const [value, setValue] = useState(initialValue) |
||||
const [enabled, setEnabled] = useState(false) |
||||
|
||||
const handleChange = () => { |
||||
setEnabled(true) |
||||
} |
||||
|
||||
const handleSave = () => { |
||||
setEnabled(false) |
||||
saveResult(value) |
||||
} |
||||
|
||||
return ( |
||||
<div className="form-group"> |
||||
<label htmlFor={id}>{label}</label> |
||||
<input type={secret ? 'password' : 'text'} className="form-control mb-2" id={id} placeholder="0x2738d13E81e..." value={value} onChange={(e) => setValue(e.target.value)} disabled={!enabled} /> |
||||
<div className="d-flex flex-row justify-content-start"> |
||||
<button type="button" className="btn btn-secondary mr-3" disabled={enabled} onClick={handleChange}> |
||||
Change |
||||
</button> |
||||
<button type="button" className="btn btn-secondary" disabled={!enabled} onClick={handleSave}> |
||||
Save |
||||
</button> |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,21 @@ |
||||
import { useState } from 'react' |
||||
import { SearchableChainDropdown, ConfigInput } from '../components' |
||||
import { Chain } from '../types/VerificationTypes' |
||||
|
||||
export const SettingsView = () => { |
||||
const [selectedChain, setSelectedChain] = useState<Chain | undefined>() |
||||
|
||||
return ( |
||||
<> |
||||
<SearchableChainDropdown label="Chain" id="network-dropdown" setSelectedChain={setSelectedChain} selectedChain={selectedChain} /> |
||||
|
||||
{selectedChain && ( |
||||
<div className="pt-2"> |
||||
<span className="font-weight-bold">Etherscan</span> |
||||
<ConfigInput label="API Key" id="etherscan-api-key" secret={true} initialValue="key" saveResult={() => {}} /> |
||||
<ConfigInput label="API URL" id="etherscan-api-url" secret={false} initialValue="url" saveResult={() => {}} /> |
||||
</div> |
||||
)} |
||||
</> |
||||
) |
||||
} |
@ -1 +1,4 @@ |
||||
export { VerifyView } from './VerifyView' |
||||
export { SettingsView } from './SettingsView' |
||||
export { LookupView } from './LookupView' |
||||
export { ReceiptsView } from './ReceiptsView' |
||||
|
Loading…
Reference in new issue