fix: make table fields show a '-' instead of an empty string when the
col content is null fix: make all notifications fields optional fix: make the notifications overrides fields valid only if the machine/ cryptocurrency and at least one of the other options are filled
This commit is contained in:
parent
bbf98b4d52
commit
f9be68f98a
6 changed files with 74 additions and 32 deletions
|
|
@ -103,7 +103,7 @@ const ECol = ({
|
||||||
textAlign,
|
textAlign,
|
||||||
suffix,
|
suffix,
|
||||||
SuffixComponent = TL2,
|
SuffixComponent = TL2,
|
||||||
view = it => it?.toString(),
|
view = it => (!it ? '-' : it.toString()),
|
||||||
inputProps = {}
|
inputProps = {}
|
||||||
} = config
|
} = config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import * as Yup from 'yup'
|
||||||
import PromptWhenDirty from 'src/components/PromptWhenDirty'
|
import PromptWhenDirty from 'src/components/PromptWhenDirty'
|
||||||
|
|
||||||
import NotificationsCtx from '../NotificationsContext'
|
import NotificationsCtx from '../NotificationsContext'
|
||||||
|
import { transformNumber } from '../helper'
|
||||||
|
|
||||||
import Header from './EditHeader'
|
import Header from './EditHeader'
|
||||||
import EditableNumber from './EditableNumber'
|
import EditableNumber from './EditableNumber'
|
||||||
|
|
@ -43,10 +44,11 @@ const SingleFieldEditableNumber = ({
|
||||||
|
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
[name]: Yup.number()
|
[name]: Yup.number()
|
||||||
|
.transform(transformNumber)
|
||||||
.integer()
|
.integer()
|
||||||
.min(min)
|
.min(min)
|
||||||
.max(max)
|
.max(max)
|
||||||
.required()
|
.nullable()
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
6
new-lamassu-admin/src/pages/Notifications/helper.js
Normal file
6
new-lamassu-admin/src/pages/Notifications/helper.js
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import _ from 'lodash/fp'
|
||||||
|
|
||||||
|
const transformNumber = value =>
|
||||||
|
_.isNumber(value) && !_.isNaN(value) ? value : null
|
||||||
|
|
||||||
|
export { transformNumber }
|
||||||
|
|
@ -7,6 +7,7 @@ import { NumberInput } from 'src/components/inputs/formik'
|
||||||
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
||||||
|
|
||||||
import NotificationsCtx from '../NotificationsContext'
|
import NotificationsCtx from '../NotificationsContext'
|
||||||
|
import { transformNumber } from '../helper'
|
||||||
|
|
||||||
const HIGH_BALANCE_KEY = 'highBalance'
|
const HIGH_BALANCE_KEY = 'highBalance'
|
||||||
const LOW_BALANCE_KEY = 'lowBalance'
|
const LOW_BALANCE_KEY = 'lowBalance'
|
||||||
|
|
@ -51,20 +52,34 @@ const CryptoBalanceOverrides = ({ section }) => {
|
||||||
[HIGH_BALANCE_KEY]: ''
|
[HIGH_BALANCE_KEY]: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const notesMin = 0
|
||||||
const currencyMax = 9999999
|
const currencyMax = 9999999
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape(
|
||||||
[CRYPTOCURRENCY_KEY]: Yup.string().required(),
|
{
|
||||||
[LOW_BALANCE_KEY]: Yup.number()
|
[CRYPTOCURRENCY_KEY]: Yup.string().required(),
|
||||||
.integer()
|
[LOW_BALANCE_KEY]: Yup.number()
|
||||||
.min(0)
|
.when(HIGH_BALANCE_KEY, {
|
||||||
.max(currencyMax)
|
is: HIGH_BALANCE_KEY => !HIGH_BALANCE_KEY,
|
||||||
.required(),
|
then: Yup.number().required()
|
||||||
[HIGH_BALANCE_KEY]: Yup.number()
|
})
|
||||||
.integer()
|
.transform(transformNumber)
|
||||||
.min(0)
|
.integer()
|
||||||
.max(currencyMax)
|
.min(notesMin)
|
||||||
.required()
|
.max(currencyMax)
|
||||||
})
|
.nullable(),
|
||||||
|
[HIGH_BALANCE_KEY]: Yup.number()
|
||||||
|
.when(LOW_BALANCE_KEY, {
|
||||||
|
is: LOW_BALANCE_KEY => !LOW_BALANCE_KEY,
|
||||||
|
then: Yup.number().required()
|
||||||
|
})
|
||||||
|
.transform(transformNumber)
|
||||||
|
.integer()
|
||||||
|
.min(notesMin)
|
||||||
|
.max(currencyMax)
|
||||||
|
.nullable()
|
||||||
|
},
|
||||||
|
[LOW_BALANCE_KEY, HIGH_BALANCE_KEY]
|
||||||
|
)
|
||||||
|
|
||||||
const viewCrypto = it =>
|
const viewCrypto = it =>
|
||||||
R.compose(
|
R.compose(
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { Cashbox } from '../../../components/inputs/cashbox/Cashbox'
|
||||||
import NotificationsCtx from '../NotificationsContext'
|
import NotificationsCtx from '../NotificationsContext'
|
||||||
import Header from '../components/EditHeader'
|
import Header from '../components/EditHeader'
|
||||||
import EditableNumber from '../components/EditableNumber'
|
import EditableNumber from '../components/EditableNumber'
|
||||||
|
import { transformNumber } from '../helper'
|
||||||
|
|
||||||
import styles from './FiatBalanceAlerts.styles.js'
|
import styles from './FiatBalanceAlerts.styles.js'
|
||||||
|
|
||||||
|
|
@ -19,6 +20,7 @@ const NAME = 'fiatBalanceAlerts'
|
||||||
|
|
||||||
const FiatBalance = ({
|
const FiatBalance = ({
|
||||||
section,
|
section,
|
||||||
|
min = 0,
|
||||||
max = Number.MAX_SAFE_INTEGER,
|
max = Number.MAX_SAFE_INTEGER,
|
||||||
fieldWidth = 80
|
fieldWidth = 80
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -31,15 +33,17 @@ const FiatBalance = ({
|
||||||
|
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
fiatBalanceCassette1: Yup.number()
|
fiatBalanceCassette1: Yup.number()
|
||||||
|
.transform(transformNumber)
|
||||||
.integer()
|
.integer()
|
||||||
.min(0)
|
.min(min)
|
||||||
.max(max)
|
.max(max)
|
||||||
.required(),
|
.nullable(),
|
||||||
fiatBalanceCassette2: Yup.number()
|
fiatBalanceCassette2: Yup.number()
|
||||||
|
.transform(transformNumber)
|
||||||
.integer()
|
.integer()
|
||||||
.min(0)
|
.min(min)
|
||||||
.max(max)
|
.max(max)
|
||||||
.required()
|
.nullable()
|
||||||
})
|
})
|
||||||
|
|
||||||
const fiatBalanceCassette1Percent =
|
const fiatBalanceCassette1Percent =
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { NumberInput } from 'src/components/inputs/formik/'
|
||||||
import Autocomplete from 'src/components/inputs/formik/Autocomplete'
|
import Autocomplete from 'src/components/inputs/formik/Autocomplete'
|
||||||
|
|
||||||
import NotificationsCtx from '../NotificationsContext'
|
import NotificationsCtx from '../NotificationsContext'
|
||||||
|
import { transformNumber } from '../helper'
|
||||||
|
|
||||||
const CASSETTE_1_KEY = 'cassette1'
|
const CASSETTE_1_KEY = 'cassette1'
|
||||||
const CASSETTE_2_KEY = 'cassette2'
|
const CASSETTE_2_KEY = 'cassette2'
|
||||||
|
|
@ -38,20 +39,34 @@ const FiatBalanceOverrides = ({ section }) => {
|
||||||
[CASSETTE_2_KEY]: ''
|
[CASSETTE_2_KEY]: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const notesMin = 0
|
||||||
const notesMax = 9999999
|
const notesMax = 9999999
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape(
|
||||||
[MACHINE_KEY]: Yup.string().required(),
|
{
|
||||||
[CASSETTE_1_KEY]: Yup.number()
|
[MACHINE_KEY]: Yup.string().required(),
|
||||||
.integer()
|
[CASSETTE_1_KEY]: Yup.number()
|
||||||
.min(0)
|
.when(CASSETTE_2_KEY, {
|
||||||
.max(notesMax)
|
is: CASSETTE_2_KEY => !CASSETTE_2_KEY,
|
||||||
.required(),
|
then: Yup.number().required()
|
||||||
[CASSETTE_2_KEY]: Yup.number()
|
})
|
||||||
.integer()
|
.transform(transformNumber)
|
||||||
.min(0)
|
.integer()
|
||||||
.max(notesMax)
|
.min(notesMin)
|
||||||
.required()
|
.max(notesMax)
|
||||||
})
|
.nullable(),
|
||||||
|
[CASSETTE_2_KEY]: Yup.number()
|
||||||
|
.when(CASSETTE_1_KEY, {
|
||||||
|
is: CASSETTE_1_KEY => !CASSETTE_1_KEY,
|
||||||
|
then: Yup.number().required()
|
||||||
|
})
|
||||||
|
.transform(transformNumber)
|
||||||
|
.integer()
|
||||||
|
.min(notesMin)
|
||||||
|
.max(notesMax)
|
||||||
|
.nullable()
|
||||||
|
},
|
||||||
|
[CASSETTE_1_KEY, CASSETTE_2_KEY]
|
||||||
|
)
|
||||||
|
|
||||||
const viewMachine = it =>
|
const viewMachine = it =>
|
||||||
R.compose(R.path(['name']), R.find(R.propEq('deviceId', it)))(machines)
|
R.compose(R.path(['name']), R.find(R.propEq('deviceId', it)))(machines)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue