diff --git a/src/components/Jam.jsx b/src/components/Jam.jsx index 9dd296f1d..70612eeb3 100644 --- a/src/components/Jam.jsx +++ b/src/components/Jam.jsx @@ -200,81 +200,90 @@ export default function Jam() {

{t('scheduler.description_destination_addresses')}

)} - { - if (collaborativeOperationRunning) { - return {} - } - - const errors = {} - - const isValidAddress = (candidate) => { - return typeof candidate !== 'undefined' && candidate !== '' - } - - if (!isValidAddress(values.dest1)) { - errors.dest1 = t('scheduler.error_invalid_destionation_address') - } - if (!isValidAddress(values.dest2)) { - errors.dest2 = t('scheduler.error_invalid_destionation_address') - } - if (!isValidAddress(values.dest3)) { - errors.dest3 = t('scheduler.error_invalid_destionation_address') - } - - return errors - }} - onSubmit={async (values) => { - if (collaborativeOperationRunning) { - await stopSchedule() - } else { - await startSchedule(values) - } - }} - > - {({ - values, - isSubmitting, - handleSubmit, - handleBlur, - handleChange, - setFieldValue, - validateForm, - isValid, - dirty, - touched, - errors, - }) => ( - <> - - - {!collaborativeOperationRunning && ( - <> - - { - setDestinationIsExternal(isToggled) - - if (!isToggled) { - const newAddresses = getNewAddresses(3, INTERNAL_DEST_ACCOUNT) - setFieldValue('dest1', newAddresses[0], true) - setFieldValue('dest2', newAddresses[1], true) - setFieldValue('dest3', newAddresses[2], true) - } else { - setFieldValue('dest1', '', false) - setFieldValue('dest2', '', false) - setFieldValue('dest3', '', false) - } - }} - disabled={isSubmitting} - /> - - {/* Todo: Testing toggle is deactivated until https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1260 is merged. */} - {/*process.env.NODE_ENV === 'development' && ( + {!walletInfo ? ( + + + + ) : ( + { + return { ...obj, [`dest${index + 1}`]: addr } + }, {})} + validate={(values) => { + if (collaborativeOperationRunning) { + return {} + } + + const errors = {} + + const isValidAddress = (candidate) => { + return typeof candidate !== 'undefined' && candidate !== '' + } + + if (!isValidAddress(values.dest1)) { + errors.dest1 = t('scheduler.error_invalid_destionation_address') + } + if (!isValidAddress(values.dest2)) { + errors.dest2 = t('scheduler.error_invalid_destionation_address') + } + if (!isValidAddress(values.dest3)) { + errors.dest3 = t('scheduler.error_invalid_destionation_address') + } + + return errors + }} + onSubmit={async (values) => { + if (collaborativeOperationRunning) { + await stopSchedule() + } else { + await startSchedule(values) + } + }} + > + {({ + values, + isSubmitting, + handleSubmit, + handleBlur, + handleChange, + setFieldValue, + validateForm, + isValid, + dirty, + touched, + errors, + }) => ( + <> + + + {!collaborativeOperationRunning && ( + <> + + { + setDestinationIsExternal(isToggled) + + if (!isToggled) { + const newAddresses = getNewAddresses(3, INTERNAL_DEST_ACCOUNT) + setFieldValue('dest1', newAddresses[0], true) + setFieldValue('dest2', newAddresses[1], true) + setFieldValue('dest3', newAddresses[2], true) + } else { + setFieldValue('dest1', '', false) + setFieldValue('dest2', '', false) + setFieldValue('dest3', '', false) + } + }} + disabled={isSubmitting} + /> + + {/* Todo: Testing toggle is deactivated until https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1260 is merged. */} + {/*process.env.NODE_ENV === 'development' && ( )*/} - - )} - {!collaborativeOperationRunning && - destinationIsExternal && - [1, 2, 3].map((i) => { - return ( - - {t('scheduler.label_destination_input', { destination: i })} - {!wallet || !walletInfo || isLoading ? ( - - - - ) : ( - - )} - - ) - })} - {!collaborativeOperationRunning && ( -

{t('scheduler.description_fees')}

- )} - -
- {collaborativeOperationRunning ? t('scheduler.button_stop') : t('scheduler.button_start')} -
-
-
- - )} -
+ + )} + {!collaborativeOperationRunning && + destinationIsExternal && + [1, 2, 3].map((i) => { + return ( + + {t('scheduler.label_destination_input', { destination: i })} + {!wallet || !walletInfo || isLoading ? ( + + + + ) : ( + + )} + + ) + })} + {!collaborativeOperationRunning && ( +

{t('scheduler.description_fees')}

+ )} + +
+ {collaborativeOperationRunning ? t('scheduler.button_stop') : t('scheduler.button_start')} +
+
+
+ + )} +
+ )} ) }