1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fix publishing when connecting wallet on publish form

This commit is contained in:
EnzoVezzaro 2022-08-23 07:08:12 -04:00
parent 66212c264c
commit f8a6edc3c6

View File

@ -1,9 +1,14 @@
import { ReactElement, useEffect } from 'react' import { ReactElement, useEffect } from 'react'
import { useFormikContext } from 'formik' import { useFormikContext } from 'formik'
import { wizardSteps, initialPublishFeedback } from './_constants' import {
wizardSteps,
initialPublishFeedback,
initialValues
} from './_constants'
import { useWeb3 } from '@context/Web3' import { useWeb3 } from '@context/Web3'
import { FormPublishData, PublishFeedback } from './_types' import { FormPublishData, PublishFeedback } from './_types'
import { getOceanConfig } from '@utils/ocean' import { getOceanConfig } from '@utils/ocean'
import router from 'next/router'
export function Steps({ export function Steps({
feedback feedback
@ -22,11 +27,15 @@ export function Steps({
setFieldValue('user.accountId', accountId) setFieldValue('user.accountId', accountId)
}, [chainId, accountId, setFieldValue]) }, [chainId, accountId, setFieldValue])
// Reset the selected baseToken on chainId change
useEffect(() => { useEffect(() => {
if (!chainId) return if (!chainId) return
setFieldValue('pricing.baseToken', null) // Reset the pricing values on chainId change
// the user needs to update the pricing schema on network changes
if (values.pricing.price) {
setFieldValue('pricing', initialValues.pricing)
router.push(`/publish/3`)
}
}, [chainId, setFieldValue]) }, [chainId, setFieldValue])
// auto-sync publish feedback into form data values // auto-sync publish feedback into form data values