fix: missing error messages
This commit is contained in:
parent
c0ce1a0c42
commit
7532b5c904
14 changed files with 93 additions and 65 deletions
|
|
@ -339,7 +339,7 @@ function camelizeDeep (customer) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all available complianceTypes
|
* Get all available complianceTypes
|
||||||
* that can be overriden (excluding hard_limit)
|
* that can be overridden (excluding hard_limit)
|
||||||
*
|
*
|
||||||
* @name getComplianceTypes
|
* @name getComplianceTypes
|
||||||
* @function
|
* @function
|
||||||
|
|
@ -404,7 +404,7 @@ function enhanceAtFields (fields) {
|
||||||
*/
|
*/
|
||||||
function enhanceOverrideFields (fields, userToken) {
|
function enhanceOverrideFields (fields, userToken) {
|
||||||
if (!userToken) return fields
|
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 _.reduce(_.assign, fields, _.map((type) => {
|
||||||
return (fields[type + '_override'])
|
return (fields[type + '_override'])
|
||||||
? {
|
? {
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,7 @@ const ERow = ({ editing, disabled, lastOfGroup, newRow }) => {
|
||||||
size={rowSize}
|
size={rowSize}
|
||||||
error={editing && hasErrors}
|
error={editing && hasErrors}
|
||||||
newRow={newRow && !hasErrors}
|
newRow={newRow && !hasErrors}
|
||||||
|
shouldShowError
|
||||||
errorMessage={errorMessage}>
|
errorMessage={errorMessage}>
|
||||||
{innerElements.map((it, idx) => {
|
{innerElements.map((it, idx) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -74,13 +74,13 @@ const Commissions = ({ name: SCREEN_KEY }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveOverridesFromList = it => (_, override) => {
|
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 sameMachine = R.eqProps('machine', override)
|
||||||
const notSameOverride = it => !R.eqProps('cryptoCurrencies', override, it)
|
const notSameOverride = it => !R.eqProps('cryptoCurrencies', override, it)
|
||||||
|
|
||||||
const filterMachine = R.filter(R.both(sameMachine, notSameOverride))
|
const filterMachine = R.filter(R.both(sameMachine, notSameOverride))
|
||||||
const removeCoin = removeCoinFromOverride(cryptoOverriden)
|
const removeCoin = removeCoinFromOverride(cryptoOverridden)
|
||||||
|
|
||||||
const machineOverrides = R.map(removeCoin)(filterMachine(it))
|
const machineOverrides = R.map(removeCoin)(filterMachine(it))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ const getOverridesSchema = (values, rawData, locale) => {
|
||||||
'deviceId'
|
'deviceId'
|
||||||
)(machine)
|
)(machine)
|
||||||
|
|
||||||
const message = `${codes} already overriden for machine: ${machineView}`
|
const message = `${codes} already overridden for machine: ${machineView}`
|
||||||
|
|
||||||
return this.createError({ message })
|
return this.createError({ message })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ const allFields = (getData, onChange, auxElements = []) => {
|
||||||
return R.compose(R.join(', '), R.map(getView(data, 'code')))(it)
|
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 =>
|
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 machineData = getData(['machines'])
|
||||||
const countryData = getData(['countries'])
|
const countryData = getData(['countries'])
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import WizardSplash from './WizardSplash'
|
||||||
import WizardStep from './WizardStep'
|
import WizardStep from './WizardStep'
|
||||||
|
|
||||||
const MODAL_WIDTH = 554
|
const MODAL_WIDTH = 554
|
||||||
const MODAL_HEIGHT = 520
|
const MODAL_HEIGHT = 535
|
||||||
const CASHBOX_DEFAULT_CAPACITY = 500
|
const CASHBOX_DEFAULT_CAPACITY = 500
|
||||||
|
|
||||||
const CASSETTE_FIELDS = R.map(
|
const CASSETTE_FIELDS = R.map(
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { Formik, Form, Field } from 'formik'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
|
import ErrorMessage from 'src/components/ErrorMessage'
|
||||||
import Stepper from 'src/components/Stepper'
|
import Stepper from 'src/components/Stepper'
|
||||||
import { HoverableTooltip } from 'src/components/Tooltip'
|
import { HoverableTooltip } from 'src/components/Tooltip'
|
||||||
import { Button } from 'src/components/buttons'
|
import { Button } from 'src/components/buttons'
|
||||||
|
|
@ -94,6 +95,10 @@ const styles = {
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
color: errorColor
|
color: errorColor
|
||||||
|
},
|
||||||
|
stepErrorMessage: {
|
||||||
|
maxWidth: 275,
|
||||||
|
marginTop: 25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,6 +289,11 @@ const WizardStep = ({
|
||||||
= {numberToFiatAmount(cassetteTotal(values))}{' '}
|
= {numberToFiatAmount(cassetteTotal(values))}{' '}
|
||||||
{fiatCurrency}
|
{fiatCurrency}
|
||||||
</P>
|
</P>
|
||||||
|
{!R.isEmpty(errors) && (
|
||||||
|
<ErrorMessage className={classes.stepErrorMessage}>
|
||||||
|
{R.head(R.values(errors))}
|
||||||
|
</ErrorMessage>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ const CryptoBalanceOverrides = ({ section }) => {
|
||||||
return save(newOverrides)
|
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(
|
const suggestionFilter = R.filter(
|
||||||
it => !R.contains(it.code, overridenCryptos)
|
it => !R.contains(it.code, overriddenCryptos)
|
||||||
)
|
)
|
||||||
const suggestions = suggestionFilter(cryptoCurrencies)
|
const suggestions = suggestionFilter(cryptoCurrencies)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ const FiatBalanceOverrides = ({ config, section }) => {
|
||||||
|
|
||||||
const cashoutConfig = it => fromNamespace(it)(config)
|
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(
|
const suggestionFilter = R.filter(
|
||||||
it =>
|
it =>
|
||||||
!R.includes(it.deviceId, overridenMachines) &&
|
!R.includes(it.deviceId, overriddenMachines) &&
|
||||||
cashoutConfig(it.deviceId).active
|
cashoutConfig(it.deviceId).active
|
||||||
)
|
)
|
||||||
const suggestions = suggestionFilter(machines)
|
const suggestions = suggestionFilter(machines)
|
||||||
|
|
|
||||||
|
|
@ -153,16 +153,18 @@ const TermsConditions = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
title: Yup.string()
|
title: Yup.string('The screen title must be a string')
|
||||||
.required()
|
.required('The screen title is required')
|
||||||
.max(50, 'Too long'),
|
.max(50, 'Too long'),
|
||||||
text: Yup.string().required(),
|
text: Yup.string('The text content must be a string').required(
|
||||||
acceptButtonText: Yup.string()
|
'The text content is required'
|
||||||
.required()
|
),
|
||||||
.max(50, 'Too long'),
|
acceptButtonText: Yup.string('The accept button text must be a string')
|
||||||
cancelButtonText: Yup.string()
|
.required('The accept button text is required')
|
||||||
.required()
|
.max(50, 'The accept button text is too long'),
|
||||||
.max(50, '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 (
|
return (
|
||||||
|
|
@ -236,37 +238,42 @@ const TermsConditions = () => {
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
setError(null)
|
setError(null)
|
||||||
}}>
|
}}>
|
||||||
<Form>
|
{({ errors }) => (
|
||||||
<PromptWhenDirty />
|
<Form>
|
||||||
{fields.map((f, idx) => (
|
<PromptWhenDirty />
|
||||||
<div className={classes.row} key={idx}>
|
{fields.map((f, idx) => (
|
||||||
<Field
|
<div className={classes.row} key={idx}>
|
||||||
editing={editing}
|
<Field
|
||||||
name={f.name}
|
editing={editing}
|
||||||
width={f.width}
|
name={f.name}
|
||||||
placeholder={f.placeholder}
|
width={f.width}
|
||||||
label={f.label}
|
placeholder={f.placeholder}
|
||||||
value={f.value}
|
label={f.label}
|
||||||
multiline={f.multiline}
|
value={f.value}
|
||||||
rows={f.rows}
|
multiline={f.multiline}
|
||||||
onFocus={() => setError(null)}
|
rows={f.rows}
|
||||||
/>
|
onFocus={() => setError(null)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<div className={classnames(classes.row, classes.submit)}>
|
||||||
|
{editing && (
|
||||||
|
<>
|
||||||
|
<Link color="primary" type="submit">
|
||||||
|
Save
|
||||||
|
</Link>
|
||||||
|
<Link color="secondary" type="reset">
|
||||||
|
Cancel
|
||||||
|
</Link>
|
||||||
|
{!R.isEmpty(errors) && (
|
||||||
|
<ErrorMessage>{R.head(R.values(errors))}</ErrorMessage>
|
||||||
|
)}
|
||||||
|
{error && <ErrorMessage>Failed to save changes</ErrorMessage>}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
</Form>
|
||||||
<div className={classnames(classes.row, classes.submit)}>
|
)}
|
||||||
{editing && (
|
|
||||||
<>
|
|
||||||
<Link color="primary" type="submit">
|
|
||||||
Save
|
|
||||||
</Link>
|
|
||||||
<Link color="secondary" type="reset">
|
|
||||||
Cancel
|
|
||||||
</Link>
|
|
||||||
{error && <ErrorMessage>Failed to save changes</ErrorMessage>}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Form>
|
|
||||||
</Formik>
|
</Formik>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ const getOverridesSchema = (values, customInfoRequests) => {
|
||||||
const { requirement } = this.parent
|
const { requirement } = this.parent
|
||||||
if (R.find(R.propEq('requirement', requirement))(values)) {
|
if (R.find(R.propEq('requirement', requirement))(values)) {
|
||||||
return this.createError({
|
return this.createError({
|
||||||
message: `Requirement ${displayRequirement(
|
message: `Requirement '${displayRequirement(
|
||||||
requirement,
|
requirement,
|
||||||
customInfoRequests
|
customInfoRequests
|
||||||
)} already overriden`
|
)}' already overridden`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,9 @@ const Schema = Yup.object()
|
||||||
// TYPE
|
// TYPE
|
||||||
const typeSchema = Yup.object()
|
const typeSchema = Yup.object()
|
||||||
.shape({
|
.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.object({
|
||||||
threshold: Yup.number()
|
threshold: Yup.number()
|
||||||
.transform(transformNumber)
|
.transform(transformNumber)
|
||||||
|
|
@ -297,6 +299,8 @@ const typeSchema = Yup.object()
|
||||||
consecutiveDays: threshold => threshold.thresholdDays > 0
|
consecutiveDays: threshold => threshold.thresholdDays > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!triggerType) return
|
||||||
|
|
||||||
if (triggerType && thresholdValidator[triggerType](threshold)) return
|
if (triggerType && thresholdValidator[triggerType](threshold)) return
|
||||||
|
|
||||||
return context.createError({
|
return context.createError({
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,11 @@ const AdvancedWallet = () => {
|
||||||
|
|
||||||
const AdvancedWalletSettingsOverrides = AdvancedWalletSettings.overrides ?? []
|
const AdvancedWalletSettingsOverrides = AdvancedWalletSettings.overrides ?? []
|
||||||
|
|
||||||
const overridenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))(
|
const overriddenCryptos = R.map(R.prop(CRYPTOCURRENCY_KEY))(
|
||||||
AdvancedWalletSettingsOverrides
|
AdvancedWalletSettingsOverrides
|
||||||
)
|
)
|
||||||
const suggestionFilter = R.filter(
|
const suggestionFilter = R.filter(
|
||||||
it => !R.contains(it.code, overridenCryptos)
|
it => !R.contains(it.code, overriddenCryptos)
|
||||||
)
|
)
|
||||||
const coinSuggestions = suggestionFilter(cryptoCurrencies)
|
const coinSuggestions = suggestionFilter(cryptoCurrencies)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
} from 'src/components/inputs/formik'
|
} from 'src/components/inputs/formik'
|
||||||
import { disabledColor } from 'src/styling/variables'
|
import { disabledColor } from 'src/styling/variables'
|
||||||
import { CURRENCY_MAX } from 'src/utils/constants'
|
import { CURRENCY_MAX } from 'src/utils/constants'
|
||||||
import { transformNumber } from 'src/utils/number'
|
import { defaultToZero } from 'src/utils/number'
|
||||||
|
|
||||||
const classes = {
|
const classes = {
|
||||||
editDisabled: {
|
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 filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos))
|
||||||
|
|
||||||
const WalletSchema = Yup.object().shape({
|
const WalletSchema = Yup.object().shape({
|
||||||
ticker: Yup.string().required(),
|
ticker: Yup.string('The ticker must be a string').required(
|
||||||
wallet: Yup.string().required(),
|
'The ticker is required'
|
||||||
exchange: Yup.string().required(),
|
),
|
||||||
zeroConf: Yup.string(),
|
wallet: Yup.string('The wallet must be a string').required(
|
||||||
zeroConfLimit: Yup.number()
|
'The wallet is required'
|
||||||
.integer()
|
),
|
||||||
.min(0)
|
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)
|
.max(CURRENCY_MAX)
|
||||||
.transform(transformNumber)
|
.transform(defaultToZero)
|
||||||
})
|
})
|
||||||
|
|
||||||
const AdvancedWalletSchema = Yup.object().shape({
|
const AdvancedWalletSchema = Yup.object().shape({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue