diff --git a/src/components/atoms/FormikPersist.tsx b/src/components/atoms/FormikPersist.tsx index 9b2e6853d..cebf469a1 100644 --- a/src/components/atoms/FormikPersist.tsx +++ b/src/components/atoms/FormikPersist.tsx @@ -1,71 +1,71 @@ -import * as React from 'react'; -import { FormikProps, connect } from 'formik'; -import debounce from 'lodash.debounce'; -import omit from 'lodash.omit'; -import isEqual from 'react-fast-compare'; +import * as React from 'react' +import { FormikProps, connect } from 'formik' +import debounce from 'lodash.debounce' +import omit from 'lodash.omit' +import isEqual from 'react-fast-compare' export interface PersistProps { - name: string; - ignoreFields?: string[]; - debounce?: number; - isSessionStorage?: boolean; + name: string + ignoreFields?: string[] + debounce?: number + isSessionStorage?: boolean } class PersistImpl extends React.Component< PersistProps & { formik: FormikProps }, - {} + any > { static defaultProps = { - debounce: 300, - }; + debounce: 300 + } - saveForm = debounce((data: FormikProps<{}>) => { - const dataToSave = this.omitIgnoredFields(data); - console.log("data tosave",dataToSave) + saveForm = debounce((data: FormikProps) => { + const dataToSave = this.omitIgnoredFields(data) + console.log('data tosave', dataToSave) if (this.props.isSessionStorage) { - window.sessionStorage.setItem( - this.props.name, - JSON.stringify(dataToSave) - ); + window.sessionStorage.setItem(this.props.name, JSON.stringify(dataToSave)) } else { - window.localStorage.setItem(this.props.name, JSON.stringify(dataToSave)); + window.localStorage.setItem(this.props.name, JSON.stringify(dataToSave)) } - }, this.props.debounce); + }, this.props.debounce) - omitIgnoredFields = (data: FormikProps<{}>) => { - const { ignoreFields } = this.props; - console.log('omit fiel',ignoreFields) - const { values, touched, errors } = data; + omitIgnoredFields = (data: FormikProps) => { + const { ignoreFields } = this.props + console.log('omit fiel', ignoreFields) + const { values, touched, errors } = data - console.log( "vale", values, omit(values, ignoreFields)) + console.log('vale', values, omit(values, ignoreFields)) return ignoreFields - ? omit({ - ...data, - values: omit(values, ignoreFields), - touched: omit(touched, ignoreFields), - errors: omit(errors, ignoreFields), - }, ignoreFields) - : data; - }; + ? omit( + { + ...data, + values: omit(values, ignoreFields), + touched: omit(touched, ignoreFields), + errors: omit(errors, ignoreFields) + }, + ignoreFields + ) + : data + } componentDidUpdate(prevProps: PersistProps & { formik: FormikProps }) { if (!isEqual(prevProps.formik, this.props.formik)) { - this.saveForm(this.props.formik); + this.saveForm(this.props.formik) } } componentDidMount() { const maybeState = this.props.isSessionStorage ? window.sessionStorage.getItem(this.props.name) - : window.localStorage.getItem(this.props.name); + : window.localStorage.getItem(this.props.name) if (maybeState && maybeState !== null) { - this.props.formik.setFormikState(JSON.parse(maybeState)); + this.props.formik.setFormikState(JSON.parse(maybeState)) } } - render():any { - return null; + render(): any { + return null } } -export const Persist = connect(PersistImpl); \ No newline at end of file +export const Persist = connect(PersistImpl) diff --git a/src/components/pages/Publish/PublishForm.tsx b/src/components/pages/Publish/PublishForm.tsx index aad87ed79..ac4ff747e 100644 --- a/src/components/pages/Publish/PublishForm.tsx +++ b/src/components/pages/Publish/PublishForm.tsx @@ -12,11 +12,10 @@ export default function PublishForm({ content, publishStepText, isLoading - }: { - content: FormContent, - publishStepText?:string, - isLoading:boolean + content: FormContent + publishStepText?: string + isLoading: boolean }): ReactElement { const { ocean, account } = useOcean() const { @@ -34,7 +33,7 @@ export default function PublishForm({ useEffect(() => { setErrors({}) setTouched({}) - + // setSubmitting(false) }, []) @@ -62,7 +61,7 @@ export default function PublishForm({ diff --git a/src/components/pages/Publish/index.tsx b/src/components/pages/Publish/index.tsx index 6ca4a58e2..187d28750 100644 --- a/src/components/pages/Publish/index.tsx +++ b/src/components/pages/Publish/index.tsx @@ -20,7 +20,7 @@ export default function PublishPage({ }): ReactElement { const { marketFeeAddress, marketFeeAmount } = useSiteMetadata() const { accountId, ocean } = useOcean() - const { publish, publishError,isLoading,publishStepText } = usePublish() + const { publish, publishError, isLoading, publishStepText } = usePublish() const navigate = useNavigate() async function handleSubmit( @@ -104,7 +104,11 @@ export default function PublishPage({ > {({ values }) => ( <> - +