fix: keep previous value when closing the configuration popup without

saving on locales screen

refactor: renamed enableCoin function to configureCoin

fix: keep previous value when closing the configuration popup without
saving on wallets screen

refactor: renamed enableThirdPartyService function to
configureThirdPartyService
This commit is contained in:
Liordino Neto 2020-10-25 21:08:46 -03:00 committed by Josh Harvey
parent 2a1aaaaf7e
commit e09c972547
5 changed files with 44 additions and 21 deletions

View file

@ -45,6 +45,9 @@ const GET_INFO = gql`
const Wallet = ({ name: SCREEN_KEY }) => {
const [editingSchema, setEditingSchema] = useState(null)
const [cancelServiceConfiguration, setCancelServiceConfiguration] = useState(
null
)
const [wizard, setWizard] = useState(false)
const [error, setError] = useState(false)
const { data } = useQuery(GET_INFO)
@ -71,10 +74,13 @@ const Wallet = ({ name: SCREEN_KEY }) => {
const cryptoCurrencies = data?.cryptoCurrencies ?? []
const accounts = data?.accounts ?? []
const enableThirdPartyService = it => {
const configureThirdPartyService = (it, cancel) => {
if (!it) return
if (!accounts[it]) return setEditingSchema(schemas[it])
if (!accounts[it]) {
setEditingSchema(schemas[it])
setCancelServiceConfiguration(() => () => cancel())
}
}
const shouldOverrideEdit = it => {
@ -99,7 +105,7 @@ const Wallet = ({ name: SCREEN_KEY }) => {
elements={getElements(
cryptoCurrencies,
accountsConfig,
enableThirdPartyService
configureThirdPartyService
)}
/>
{wizard && (
@ -118,7 +124,10 @@ const Wallet = ({ name: SCREEN_KEY }) => {
<Modal
title={`Edit ${editingSchema.name}`}
width={478}
handleClose={() => setEditingSchema(null)}
handleClose={() => {
cancelServiceConfiguration && cancelServiceConfiguration()
setEditingSchema(null)
}}
open={true}>
<FormRenderer
save={it =>