diff --git a/new-lamassu-admin/src/pages/Cashout/Wizard.js b/new-lamassu-admin/src/pages/Cashout/Wizard.js index 11259af1..fe018c01 100644 --- a/new-lamassu-admin/src/pages/Cashout/Wizard.js +++ b/new-lamassu-admin/src/pages/Cashout/Wizard.js @@ -11,7 +11,7 @@ import WizardSplash from './WizardSplash' import WizardStep from './WizardStep' import { DenominationsSchema } from './helper' -const LAST_STEP = 4 +const LAST_STEP = 3 const MODAL_WIDTH = 554 const MODAL_HEIGHT = 520 @@ -70,13 +70,6 @@ const Wizard = ({ machine, locale, onClose, save, error }) => { labelProp: 'display', valueProp: 'code' } - }, - { - type: 'zeroConfLimit', - display: '0-conf Limit', - schema: Yup.object().shape({ - zeroConfLimit: Yup.number().required() - }) } ] diff --git a/new-lamassu-admin/src/pages/Cashout/WizardStep.js b/new-lamassu-admin/src/pages/Cashout/WizardStep.js index 4fe2a384..e888fb2e 100644 --- a/new-lamassu-admin/src/pages/Cashout/WizardStep.js +++ b/new-lamassu-admin/src/pages/Cashout/WizardStep.js @@ -38,7 +38,7 @@ const WizardStep = ({
{name} - +
{step <= 2 && ( @@ -94,46 +94,6 @@ const WizardStep = ({ )} - - {step === 3 && ( - -
-
-
-

Edit 0-conf Limit

- - Choose a limit -
- - - {fiatCurrency} - -
-
-
- - -
-
- )} - {lastStep && (
Cash-out Bill Count diff --git a/new-lamassu-admin/src/pages/Cashout/helper.js b/new-lamassu-admin/src/pages/Cashout/helper.js index db8aad97..1b7f14b7 100644 --- a/new-lamassu-admin/src/pages/Cashout/helper.js +++ b/new-lamassu-admin/src/pages/Cashout/helper.js @@ -14,11 +14,6 @@ const DenominationsSchema = Yup.object().shape({ .label('Cassette 2 (Bottom)') .required() .min(1) - .max(currencyMax), - zeroConfLimit: Yup.number() - .label('0-conf Limit') - .required() - .min(0) .max(currencyMax) }) @@ -27,7 +22,7 @@ const getElements = (machines, { fiatCurrency } = {}) => { { name: 'id', header: 'Machine', - width: 200, + width: 300, view: it => machines.find(({ deviceId }) => deviceId === it).name, size: 'sm', editable: false @@ -36,7 +31,7 @@ const getElements = (machines, { fiatCurrency } = {}) => { name: 'top', header: 'Cassette 1 (Top)', stripe: true, - width: 200, + width: 250, textAlign: 'right', input: NumberInput, inputProps: { @@ -48,28 +43,15 @@ const getElements = (machines, { fiatCurrency } = {}) => { { name: 'bottom', header: 'Cassette 2 (Bottom)', + size: 'sm', stripe: true, textAlign: 'right', - width: 200, + width: 250, input: NumberInput, inputProps: { decimalPlaces: 0 }, - suffix: fiatCurrency, - bold: bold - }, - { - name: 'zeroConfLimit', - header: '0-conf Limit', - stripe: true, - textAlign: 'right', - width: 200, - input: NumberInput, - inputProps: { - decimalPlaces: 0 - }, - suffix: fiatCurrency, - bold: bold + suffix: fiatCurrency } ] } diff --git a/new-lamassu-admin/src/pages/Locales/Locales.js b/new-lamassu-admin/src/pages/Locales/Locales.js index a91459e5..faf88974 100644 --- a/new-lamassu-admin/src/pages/Locales/Locales.js +++ b/new-lamassu-admin/src/pages/Locales/Locales.js @@ -224,6 +224,7 @@ const Locales = ({ name: SCREEN_KEY }) => { userAccounts={data?.config?.accounts} accounts={accounts} accountsConfig={accountsConfig} + locale={locale} /> )} diff --git a/new-lamassu-admin/src/pages/Wallet/Wallet.js b/new-lamassu-admin/src/pages/Wallet/Wallet.js index a71249aa..35cc3e5d 100644 --- a/new-lamassu-admin/src/pages/Wallet/Wallet.js +++ b/new-lamassu-admin/src/pages/Wallet/Wallet.js @@ -123,6 +123,7 @@ const Wallet = ({ name: SCREEN_KEY }) => { userAccounts={data?.config?.accounts} accounts={accounts} accountsConfig={accountsConfig} + locale={data?.config && fromNamespace('locale')(data.config)} /> )} {editingSchema && ( diff --git a/new-lamassu-admin/src/pages/Wallet/Wizard.js b/new-lamassu-admin/src/pages/Wallet/Wizard.js index 01ec886b..4e3e24ac 100644 --- a/new-lamassu-admin/src/pages/Wallet/Wizard.js +++ b/new-lamassu-admin/src/pages/Wallet/Wizard.js @@ -8,7 +8,7 @@ import { toNamespace } from 'src/utils/config' import WizardSplash from './WizardSplash' import WizardStep from './WizardStep' -const LAST_STEP = 4 +const LAST_STEP = 5 const MODAL_WIDTH = 554 const contains = crypto => R.compose(R.contains(crypto), R.prop('cryptos')) @@ -33,7 +33,15 @@ const getItems = (accountsConfig, accounts, type, crypto) => { return { filled, unfilled } } -const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => { +const Wizard = ({ + coin, + onClose, + accountsConfig, + accounts, + save, + error, + locale +}) => { const [{ step, config, accountsToSave }, setState] = useState({ step: 0, config: { active: true }, @@ -77,6 +85,8 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => { return { type: 'exchange', ...exchanges } case 4: return { type: 'zeroConf', name: 'zero conf', ...zeroConfs } + case 5: + return { type: 'zeroConfLimit' } default: return null } @@ -103,6 +113,7 @@ const Wizard = ({ coin, onClose, accountsConfig, accounts, save, error }) => { {...getStepData()} onContinue={onContinue} getValue={getValue} + locale={locale} /> )} diff --git a/new-lamassu-admin/src/pages/Wallet/WizardStep.js b/new-lamassu-admin/src/pages/Wallet/WizardStep.js index 5b3828d8..8ad2c016 100644 --- a/new-lamassu-admin/src/pages/Wallet/WizardStep.js +++ b/new-lamassu-admin/src/pages/Wallet/WizardStep.js @@ -2,11 +2,13 @@ import { makeStyles } from '@material-ui/core' import classnames from 'classnames' import * as R from 'ramda' import React, { useReducer, useEffect } from 'react' +import * as Yup from 'yup' import ErrorMessage from 'src/components/ErrorMessage' import Stepper from 'src/components/Stepper' import { Button } from 'src/components/buttons' import { RadioGroup, Autocomplete } from 'src/components/inputs' +import { NumberInput } from 'src/components/inputs/formik' import { H4, Info2 } from 'src/components/typography' import FormRenderer from 'src/pages/Services/FormRenderer' import schema from 'src/pages/Services/schemas' @@ -59,7 +61,8 @@ const WizardStep = ({ onContinue, filled, unfilled, - getValue + getValue, + locale }) => { const classes = useStyles() const [{ innerError, selected, form, isNew }, dispatch] = useReducer( @@ -68,6 +71,9 @@ const WizardStep = ({ ) useEffect(() => { + if (step === 5) { + return dispatch({ type: 'form', form: { code: 'zeroConfLimit' } }) + } dispatch({ type: 'reset' }) }, [step]) @@ -78,64 +84,99 @@ const WizardStep = ({ onContinue(config, account) } + const zeroConfLimitSchema = Yup.object().shape({ + zeroConfLimit: Yup.number() + .integer() + .required() + .min(0) + .max(999999999) + }) const label = lastStep ? 'Finish' : 'Next' const displayName = name ?? type const subtitleClass = { [classes.subtitle]: true, [classes.error]: innerError } - return ( <> {startCase(type)} - -

- Select a {displayName} or set up a new one -

- { - dispatch({ type: 'select', selected: it }) - }} - labelClassName={classes.radioLabel} - radioClassName={classes.radio} - /> -
- {!R.isEmpty(unfilled) && !R.isNil(unfilled) && ( + + {step <= 4 && ( + <> +

+ Select a {displayName} or set up a new one +

{ - dispatch({ type: 'new' }) + dispatch({ type: 'select', selected: it }) }} labelClassName={classes.radioLabel} radioClassName={classes.radio} - options={[{ display: 'Set up new', code: true }]} /> - )} - {isNew && ( - { - dispatch({ type: 'form', form: it }) - }} +
+ {!R.isEmpty(unfilled) && !R.isNil(unfilled) && ( + { + dispatch({ type: 'new' }) + }} + labelClassName={classes.radioLabel} + radioClassName={classes.radio} + options={[{ display: 'Set up new', code: true }]} + /> + )} + {isNew && ( + { + dispatch({ type: 'form', form: it }) + }} + /> + )} +
+ {form && ( + + innerContinue({ [type]: form.code }, { [form.code]: it }) + } + elements={schema[form.code].elements} + validationSchema={schema[form.code].validationSchema} + value={getValue(form.code)} + buttonLabel={label} + /> + )} + + )} + {step === 5 && ( + <> +

Edit 0-conf Limit

+ + innerContinue( + { [type]: Number(it.zeroConfLimit) }, + { [form.code]: it } + ) + } + elements={[ + { + code: 'zeroConfLimit', + display: `Choose a ${locale.fiatCurrency} limit`, + component: NumberInput + } + ]} + validationSchema={zeroConfLimitSchema} + buttonLabel={label} + value={0} /> - )} -
- {form && ( - innerContinue({ [type]: form.code }, { [form.code]: it })} - elements={schema[form.code].elements} - validationSchema={schema[form.code].validationSchema} - value={getValue(form.code)} - buttonLabel={label} - /> + )} {!form && (
diff --git a/new-lamassu-admin/src/pages/Wallet/helper.js b/new-lamassu-admin/src/pages/Wallet/helper.js index 7ddbcbf7..22dc6128 100644 --- a/new-lamassu-admin/src/pages/Wallet/helper.js +++ b/new-lamassu-admin/src/pages/Wallet/helper.js @@ -1,16 +1,22 @@ import * as R from 'ramda' import * as Yup from 'yup' +import { NumberInput } from 'src/components/inputs/formik' import Autocomplete from 'src/components/inputs/formik/Autocomplete.js' const filterClass = type => R.filter(it => it.class === type) const filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos)) - +const currencyMax = 999999999 const WalletSchema = Yup.object().shape({ ticker: Yup.string().required(), wallet: Yup.string().required(), exchange: Yup.string().required(), - zeroConf: Yup.string().required() + zeroConf: Yup.string().required(), + zeroConfLimit: Yup.number() + .integer() + .required() + .min(0) + .max(currencyMax) }) const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => { @@ -100,6 +106,17 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => { optionsLimit: null, onChange } + }, + { + name: 'zeroConfLimit', + size: 'sm', + stripe: true, + view: it => it, + input: NumberInput, + width: 190 - widthAdjust, + inputProps: { + decimalPlaces: 0 + } } ] } diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/Wallet.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/Wallet.js index 0a9c77af..7707cdde 100644 --- a/new-lamassu-admin/src/pages/Wizard/components/Wallet/Wallet.js +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/Wallet.js @@ -12,6 +12,7 @@ import ChooseCoin from './ChooseCoin' import ChooseExchange from './ChooseExchange' import ChooseTicker from './ChooseTicker' import ChooseWallet from './ChooseWallet' +import ZeroConfLimit from './ZeroConfLimit' const useStyles = makeStyles(styles) @@ -36,6 +37,10 @@ const steps = [ label: 'Blockcypher', component: Blockcypher }, + { + label: 'Set 0-conf Limit', + component: ZeroConfLimit + }, { label: 'All set', component: AllSet diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/ZeroConfLimit.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ZeroConfLimit.js new file mode 100644 index 00000000..2d8c62b5 --- /dev/null +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/ZeroConfLimit.js @@ -0,0 +1,48 @@ +import { makeStyles } from '@material-ui/core' +import React from 'react' +import * as Yup from 'yup' + +import { NumberInput } from 'src/components/inputs/formik' +import { H4 } from 'src/components/typography' +import FormRenderer from 'src/pages/Services/FormRenderer' + +import styles from './Shared.styles' + +const useStyles = makeStyles(styles) + +const zeroConfLimitSchema = Yup.object().shape({ + zeroConfLimit: Yup.number() + .integer() + .required() + .min(0) + .max(999999999) +}) + +const ZeroConfLimit = ({ data: currentData, addData }) => { + const classes = useStyles() + + const submit = value => { + addData({ zeroConfLimit: value }) + } + + return ( +
+

Set the 0-conf limit

+ submit(Number(it.zeroConfLimit))} + /> +
+ ) +} + +export default ZeroConfLimit