Merge pull request #1406 from chaotixkilla/fix-missing-error-messages
Fix missing error messages
This commit is contained in:
commit
df5bc81700
14 changed files with 93 additions and 65 deletions
|
|
@ -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'])
|
||||
? {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'])
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
</P>
|
||||
{!R.isEmpty(errors) && (
|
||||
<ErrorMessage className={classes.stepErrorMessage}>
|
||||
{R.head(R.values(errors))}
|
||||
</ErrorMessage>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}}>
|
||||
<Form>
|
||||
<PromptWhenDirty />
|
||||
{fields.map((f, idx) => (
|
||||
<div className={classes.row} key={idx}>
|
||||
<Field
|
||||
editing={editing}
|
||||
name={f.name}
|
||||
width={f.width}
|
||||
placeholder={f.placeholder}
|
||||
label={f.label}
|
||||
value={f.value}
|
||||
multiline={f.multiline}
|
||||
rows={f.rows}
|
||||
onFocus={() => setError(null)}
|
||||
/>
|
||||
{({ errors }) => (
|
||||
<Form>
|
||||
<PromptWhenDirty />
|
||||
{fields.map((f, idx) => (
|
||||
<div className={classes.row} key={idx}>
|
||||
<Field
|
||||
editing={editing}
|
||||
name={f.name}
|
||||
width={f.width}
|
||||
placeholder={f.placeholder}
|
||||
label={f.label}
|
||||
value={f.value}
|
||||
multiline={f.multiline}
|
||||
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 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>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue