diff --git a/lib/customers.js b/lib/customers.js index d1215009..f2d51a72 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -339,7 +339,7 @@ function camelizeDeep (customer) { /** * Get all available complianceTypes - * that can be overriden (excluding hard_limit) + * that can be overridden (excluding hard_limit) * * @name getComplianceTypes * @function @@ -404,7 +404,7 @@ function enhanceAtFields (fields) { */ function enhanceOverrideFields (fields, userToken) { if (!userToken) return fields - // Populate with computedFields (user who overrode and overriden timestamps date) + // Populate with computedFields (user who overrode and overridden timestamps date) return _.reduce(_.assign, fields, _.map((type) => { return (fields[type + '_override']) ? { diff --git a/new-lamassu-admin/src/components/editableTable/Row.js b/new-lamassu-admin/src/components/editableTable/Row.js index cea0d2c9..8bee37d8 100644 --- a/new-lamassu-admin/src/components/editableTable/Row.js +++ b/new-lamassu-admin/src/components/editableTable/Row.js @@ -257,6 +257,7 @@ const ERow = ({ editing, disabled, lastOfGroup, newRow }) => { size={rowSize} error={editing && hasErrors} newRow={newRow && !hasErrors} + shouldShowError errorMessage={errorMessage}> {innerElements.map((it, idx) => { return ( diff --git a/new-lamassu-admin/src/pages/Commissions/Commissions.js b/new-lamassu-admin/src/pages/Commissions/Commissions.js index 08f48f27..d9d25a52 100644 --- a/new-lamassu-admin/src/pages/Commissions/Commissions.js +++ b/new-lamassu-admin/src/pages/Commissions/Commissions.js @@ -74,13 +74,13 @@ const Commissions = ({ name: SCREEN_KEY }) => { } const saveOverridesFromList = it => (_, override) => { - const cryptoOverriden = R.path(['cryptoCurrencies', 0], override) + const cryptoOverridden = R.path(['cryptoCurrencies', 0], override) const sameMachine = R.eqProps('machine', override) const notSameOverride = it => !R.eqProps('cryptoCurrencies', override, it) const filterMachine = R.filter(R.both(sameMachine, notSameOverride)) - const removeCoin = removeCoinFromOverride(cryptoOverriden) + const removeCoin = removeCoinFromOverride(cryptoOverridden) const machineOverrides = R.map(removeCoin)(filterMachine(it)) diff --git a/new-lamassu-admin/src/pages/Commissions/helper.js b/new-lamassu-admin/src/pages/Commissions/helper.js index 4e65dd81..fd8e2ad7 100644 --- a/new-lamassu-admin/src/pages/Commissions/helper.js +++ b/new-lamassu-admin/src/pages/Commissions/helper.js @@ -318,7 +318,7 @@ const getOverridesSchema = (values, rawData, locale) => { 'deviceId' )(machine) - const message = `${codes} already overriden for machine: ${machineView}` + const message = `${codes} already overridden for machine: ${machineView}` return this.createError({ message }) } diff --git a/new-lamassu-admin/src/pages/Locales/helper.js b/new-lamassu-admin/src/pages/Locales/helper.js index f4e9aa76..738fc75f 100644 --- a/new-lamassu-admin/src/pages/Locales/helper.js +++ b/new-lamassu-admin/src/pages/Locales/helper.js @@ -27,10 +27,10 @@ const allFields = (getData, onChange, auxElements = []) => { return R.compose(R.join(', '), R.map(getView(data, 'code')))(it) } - const overridenMachines = R.map(override => override.machine, auxElements) + const overriddenMachines = R.map(override => override.machine, auxElements) const suggestionFilter = it => - R.differenceWith((x, y) => x.deviceId === y, it, overridenMachines) + R.differenceWith((x, y) => x.deviceId === y, it, overriddenMachines) const machineData = getData(['machines']) const countryData = getData(['countries']) diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js index 3597c921..e0f18da0 100644 --- a/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js +++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/Wizard.js @@ -10,7 +10,7 @@ import WizardSplash from './WizardSplash' import WizardStep from './WizardStep' const MODAL_WIDTH = 554 -const MODAL_HEIGHT = 520 +const MODAL_HEIGHT = 535 const CASHBOX_DEFAULT_CAPACITY = 500 const CASSETTE_FIELDS = R.map( diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js index 4163525b..48294a8f 100644 --- a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js +++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js @@ -4,6 +4,7 @@ import { Formik, Form, Field } from 'formik' import * as R from 'ramda' import React from 'react' +import ErrorMessage from 'src/components/ErrorMessage' import Stepper from 'src/components/Stepper' import { HoverableTooltip } from 'src/components/Tooltip' import { Button } from 'src/components/buttons' @@ -94,6 +95,10 @@ const styles = { }, errorMessage: { color: errorColor + }, + stepErrorMessage: { + maxWidth: 275, + marginTop: 25 } } @@ -284,6 +289,11 @@ const WizardStep = ({ = {numberToFiatAmount(cassetteTotal(values))}{' '} {fiatCurrency}

+ {!R.isEmpty(errors) && ( + + {R.head(R.values(errors))} + + )} diff --git a/new-lamassu-admin/src/pages/Notifications/sections/CryptoBalanceOverrides.js b/new-lamassu-admin/src/pages/Notifications/sections/CryptoBalanceOverrides.js index e03ee79d..dcd2fb4e 100644 --- a/new-lamassu-admin/src/pages/Notifications/sections/CryptoBalanceOverrides.js +++ b/new-lamassu-admin/src/pages/Notifications/sections/CryptoBalanceOverrides.js @@ -35,9 +35,9 @@ const CryptoBalanceOverrides = ({ section }) => { return save(newOverrides) } - const overridenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))(setupValues) + const overriddenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))(setupValues) const suggestionFilter = R.filter( - it => !R.contains(it.code, overridenCryptos) + it => !R.contains(it.code, overriddenCryptos) ) const suggestions = suggestionFilter(cryptoCurrencies) diff --git a/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceOverrides.js b/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceOverrides.js index bb94a72d..73415121 100644 --- a/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceOverrides.js +++ b/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceOverrides.js @@ -47,10 +47,10 @@ const FiatBalanceOverrides = ({ config, section }) => { const cashoutConfig = it => fromNamespace(it)(config) - const overridenMachines = R.map(override => override.machine, setupValues) + const overriddenMachines = R.map(override => override.machine, setupValues) const suggestionFilter = R.filter( it => - !R.includes(it.deviceId, overridenMachines) && + !R.includes(it.deviceId, overriddenMachines) && cashoutConfig(it.deviceId).active ) const suggestions = suggestionFilter(machines) diff --git a/new-lamassu-admin/src/pages/OperatorInfo/TermsConditions.js b/new-lamassu-admin/src/pages/OperatorInfo/TermsConditions.js index de911e18..6dbc1dd5 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/TermsConditions.js +++ b/new-lamassu-admin/src/pages/OperatorInfo/TermsConditions.js @@ -153,16 +153,18 @@ const TermsConditions = () => { } const validationSchema = Yup.object().shape({ - title: Yup.string() - .required() + title: Yup.string('The screen title must be a string') + .required('The screen title is required') .max(50, 'Too long'), - text: Yup.string().required(), - acceptButtonText: Yup.string() - .required() - .max(50, 'Too long'), - cancelButtonText: Yup.string() - .required() - .max(50, 'Too long') + text: Yup.string('The text content must be a string').required( + 'The text content is required' + ), + acceptButtonText: Yup.string('The accept button text must be a string') + .required('The accept button text is required') + .max(50, 'The accept button text is too long'), + cancelButtonText: Yup.string('The cancel button text must be a string') + .required('The cancel button text is required') + .max(50, 'The cancel button text is too long') }) return ( @@ -236,37 +238,42 @@ const TermsConditions = () => { setEditing(false) setError(null) }}> -
- - {fields.map((f, idx) => ( -
- setError(null)} - /> + {({ errors }) => ( + + + {fields.map((f, idx) => ( +
+ setError(null)} + /> +
+ ))} +
+ {editing && ( + <> + + Save + + + Cancel + + {!R.isEmpty(errors) && ( + {R.head(R.values(errors))} + )} + {error && Failed to save changes} + + )}
- ))} -
- {editing && ( - <> - - Save - - - Cancel - - {error && Failed to save changes} - - )} -
- + + )} ) diff --git a/new-lamassu-admin/src/pages/Triggers/components/helper.js b/new-lamassu-admin/src/pages/Triggers/components/helper.js index d284d065..4fb30f35 100644 --- a/new-lamassu-admin/src/pages/Triggers/components/helper.js +++ b/new-lamassu-admin/src/pages/Triggers/components/helper.js @@ -52,10 +52,10 @@ const getOverridesSchema = (values, customInfoRequests) => { const _values = R.filter(it => it.id !== id, values) if (R.find(R.propEq('requirement', requirement))(_values)) { return this.createError({ - message: `Requirement ${displayRequirement( + message: `Requirement '${displayRequirement( requirement, customInfoRequests - )} already overriden` + )}' already overridden` }) } return true diff --git a/new-lamassu-admin/src/pages/Triggers/helper.js b/new-lamassu-admin/src/pages/Triggers/helper.js index 6830c99e..1e57e2b5 100644 --- a/new-lamassu-admin/src/pages/Triggers/helper.js +++ b/new-lamassu-admin/src/pages/Triggers/helper.js @@ -253,7 +253,9 @@ const Schema = Yup.object() // TYPE const typeSchema = Yup.object() .shape({ - triggerType: Yup.string().required(), + triggerType: Yup.string('The trigger type must be a string').required( + 'The trigger type is required' + ), threshold: Yup.object({ threshold: Yup.number() .transform(transformNumber) @@ -297,6 +299,8 @@ const typeSchema = Yup.object() consecutiveDays: threshold => threshold.thresholdDays > 0 } + if (!triggerType) return + if (triggerType && thresholdValidator[triggerType](threshold)) return return context.createError({ diff --git a/new-lamassu-admin/src/pages/Wallet/AdvancedWallet.js b/new-lamassu-admin/src/pages/Wallet/AdvancedWallet.js index d8ec32e8..249d4d04 100644 --- a/new-lamassu-admin/src/pages/Wallet/AdvancedWallet.js +++ b/new-lamassu-admin/src/pages/Wallet/AdvancedWallet.js @@ -67,11 +67,11 @@ const AdvancedWallet = () => { const AdvancedWalletSettingsOverrides = AdvancedWalletSettings.overrides ?? [] - const overridenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))( + const overriddenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))( AdvancedWalletSettingsOverrides ) const suggestionFilter = R.filter( - it => !R.contains(it.code, overridenCryptos) + it => !R.contains(it.code, overriddenCryptos) ) const coinSuggestions = suggestionFilter(cryptoCurrencies) diff --git a/new-lamassu-admin/src/pages/Wallet/helper.js b/new-lamassu-admin/src/pages/Wallet/helper.js index deb7f258..14f303e9 100644 --- a/new-lamassu-admin/src/pages/Wallet/helper.js +++ b/new-lamassu-admin/src/pages/Wallet/helper.js @@ -8,7 +8,7 @@ import { } from 'src/components/inputs/formik' import { disabledColor } from 'src/styling/variables' import { CURRENCY_MAX } from 'src/utils/constants' -import { transformNumber } from 'src/utils/number' +import { defaultToZero } from 'src/utils/number' const classes = { editDisabled: { @@ -19,15 +19,21 @@ const filterClass = type => R.filter(it => it.class === type) const filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos)) const WalletSchema = Yup.object().shape({ - ticker: Yup.string().required(), - wallet: Yup.string().required(), - exchange: Yup.string().required(), - zeroConf: Yup.string(), - zeroConfLimit: Yup.number() - .integer() - .min(0) + ticker: Yup.string('The ticker must be a string').required( + 'The ticker is required' + ), + wallet: Yup.string('The wallet must be a string').required( + 'The wallet is required' + ), + exchange: Yup.string('The exchange must be a string').required( + 'The exchange is required' + ), + zeroConf: Yup.string('The confidence checking must be a string'), + zeroConfLimit: Yup.number('The 0-conf limit must be an integer') + .integer('The 0-conf limit must be an integer') + .min(0, 'The 0-conf limit must be a positive integer') .max(CURRENCY_MAX) - .transform(transformNumber) + .transform(defaultToZero) }) const AdvancedWalletSchema = Yup.object().shape({