fix: PR fixes

This commit is contained in:
Taranto 2020-04-20 18:04:22 +01:00 committed by Josh Harvey
parent 1f6d272aa0
commit 21f3ee59ea
9 changed files with 52 additions and 43 deletions

View file

@ -100,7 +100,7 @@ const ECol = ({ editing, config }) => {
const { values } = useFormikContext()
const classes = useStyles({ textAlign, size })
const iProps = {
const innerProps = {
fullWidth: true,
size,
bold,
@ -109,8 +109,8 @@ const ECol = ({ editing, config }) => {
}
// Autocomplete
if (iProps.options && !iProps.getLabel) {
iProps.getLabel = view
if (innerProps.options && !innerProps.getLabel) {
innerProps.getLabel = view
}
return (
@ -121,7 +121,7 @@ const ECol = ({ editing, config }) => {
bold={bold}
textAlign={textAlign}>
{editing && editable ? (
<Field name={name} component={input} {...iProps} />
<Field name={name} component={input} {...innerProps} />
) : (
values && <>{view(values[name])}</>
)}
@ -160,12 +160,12 @@ const ERow = ({ editing, disabled }) => {
const { values } = useFormikContext()
const shouldStripe = stripeWhen && stripeWhen(values) && !editing
const iElements = shouldStripe ? groupStriped(elements) : elements
const innerElements = shouldStripe ? groupStriped(elements) : elements
return (
<Tr
error={errors && errors.length}
errorMessage={errors && errors.toString()}>
{iElements.map((it, idx) => {
{innerElements.map((it, idx) => {
return <ECol key={idx} config={it} editing={editing} />
})}
{(enableEdit || enableDelete || enableToggle) && (

View file

@ -36,7 +36,7 @@ const Autocomplete = ({
const value = getValue()
const iOnChange = (evt, value) => {
const innerOnChange = (evt, value) => {
if (!valueProp) return onChange(evt, value)
const rValue = multiple ? R.map(mapToValue)(value) : mapToValue(value)
@ -48,7 +48,7 @@ const Autocomplete = ({
options={options}
multiple={multiple}
value={value}
onChange={iOnChange}
onChange={innerOnChange}
getOptionLabel={getLabel}
forcePopupIcon={false}
filterOptions={createFilterOptions({ ignoreAccents: true, limit })}

View file

@ -9,12 +9,12 @@ const SecretInput = memo(({ value, onFocus, onBlur, ...props }) => {
const previouslyFilled = !!value
const tempValue = previouslyFilled ? '' : value
const iOnFocus = event => {
const innerOnFocus = event => {
setFocused(true)
onFocus && onFocus(event)
}
const iOnBlur = event => {
const innerOnBlur = event => {
setFocused(false)
onBlur && onBlur(event)
}
@ -23,8 +23,8 @@ const SecretInput = memo(({ value, onFocus, onBlur, ...props }) => {
<TextInput
{...props}
type="password"
onFocus={iOnFocus}
onBlur={iOnBlur}
onFocus={innerOnFocus}
onBlur={innerOnBlur}
value={value}
InputProps={{ value: !focused ? tempValue : value }}
InputLabelProps={{ shrink: previouslyFilled || focused }}

View file

@ -10,7 +10,7 @@ const AutocompleteFormik = ({ options, ...props }) => {
const error = !!(touched[name] && errors[name])
const { initialValues } = useFormikContext()
const iOptions =
const innerOptions =
R.type(options) === 'Function' ? options(initialValues) : options
return (
@ -20,7 +20,7 @@ const AutocompleteFormik = ({ options, ...props }) => {
onBlur={onBlur}
value={value}
error={error}
options={iOptions}
options={innerOptions}
{...props}
/>
)

View file

@ -1,24 +1,24 @@
import React, { memo, useState } from 'react'
import QRCode from 'qrcode.react'
import classnames from 'classnames'
import { Form, Formik, FastField } from 'formik'
import { makeStyles } from '@material-ui/core/styles'
import * as Yup from 'yup'
import { gql } from 'apollo-boost'
import { useMutation } from '@apollo/react-hooks'
import { Dialog, DialogContent, SvgIcon, IconButton } from '@material-ui/core'
import { makeStyles } from '@material-ui/core/styles'
import { gql } from 'apollo-boost'
import classnames from 'classnames'
import { Form, Formik, FastField } from 'formik'
import QRCode from 'qrcode.react'
import React, { memo, useState } from 'react'
import * as Yup from 'yup'
import Title from 'src/components/Title'
import { Button } from 'src/components/buttons'
import { TextInput } from 'src/components/inputs/formik'
import Sidebar from 'src/components/layout/Sidebar'
import { Info2, P } from 'src/components/typography'
import { ReactComponent as CloseIcon } from 'src/styling/icons/action/close/zodiac.svg'
import { ReactComponent as CompleteStageIconZodiac } from 'src/styling/icons/stage/zodiac/complete.svg'
import { ReactComponent as CurrentStageIconZodiac } from 'src/styling/icons/stage/zodiac/current.svg'
import { ReactComponent as EmptyStageIconZodiac } from 'src/styling/icons/stage/zodiac/empty.svg'
import { primaryColor } from 'src/styling/variables'
import Title from 'src/components/Title'
import Sidebar from 'src/components/Sidebar'
import { Info2, P } from 'src/components/typography'
import { TextInput } from 'src/components/inputs/formik'
import { Button } from 'src/components/buttons'
import { ReactComponent as WarningIcon } from 'src/styling/icons/warning-icon/comet.svg'
import { ReactComponent as CloseIcon } from 'src/styling/icons/action/close/zodiac.svg'
import { primaryColor } from 'src/styling/variables'
import styles from './styles'

View file

@ -4,7 +4,7 @@ import * as R from 'ramda'
import React, { useState } from 'react'
import TitleSection from 'src/components/layout/TitleSection'
import { fromNamespace, toNamespace } from 'src/utils/config'
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
import Section from '../../components/layout/Section'
@ -49,12 +49,13 @@ const Notifications = ({ name: SCREEN_KEY }) => {
onError: error => setError({ error })
})
const config = data?.config && fromNamespace(SCREEN_KEY)(data.config)
const config = fromNamespace(SCREEN_KEY)(data?.config)
const machines = data?.machines
const cryptoCurrencies = data?.cryptoCurrencies
// TODO improve the way of fetching this
const currency = R.path(['locale_fiatCurrency', 'code'])(data?.config ?? {})
const currency = R.path(['fiatCurrency'])(
fromNamespace(namespaces.LOCALE)(data?.config)
)
const save = R.curry((section, rawConfig) => {
const config = toNamespace(SCREEN_KEY)(rawConfig)

View file

@ -56,12 +56,10 @@ const CryptoBalanceOverrides = ({ section }) => {
[LOW_BALANCE_KEY]: Yup.number()
.integer()
.min(0)
.max(99999999)
.required(),
[HIGH_BALANCE_KEY]: Yup.number()
.integer()
.min(0)
.max(99999999)
.required()
})

View file

@ -15,6 +15,7 @@ import Services from 'src/pages/Services/Services'
import Transactions from 'src/pages/Transactions/Transactions'
import WalletSettings from 'src/pages/Wallet/Wallet'
import MachineStatus from 'src/pages/maintenance/MachineStatus'
import { namespaces } from 'src/utils/config'
const tree = [
{
@ -38,7 +39,7 @@ const tree = [
component: MachineLogs
},
{
key: 'fuding',
key: 'funding',
label: 'Funding',
route: '/maintenance/funding',
component: Funding
@ -66,39 +67,39 @@ const tree = [
},
children: [
{
key: 'commissions',
key: namespaces.COMMISSIONS,
label: 'Commissions',
route: '/settings/commissions',
component: Commissions
},
{
key: 'locale',
key: namespaces.LOCALE,
label: 'Locale',
route: '/settings/locale',
component: Locales
},
{
key: 'services',
key: namespaces.SERVICES,
label: '3rd party services',
route: '/settings/3rd-party-services',
component: Services
},
{
key: 'notifications',
key: namespaces.NOTIFICATIONS,
label: 'Notifications',
route: '/settings/notifications',
component: Notifications
},
{
key: 'info',
key: namespaces.OPERATOR_INFO,
label: 'Operator Info',
route: '/settings/operator-info',
component: OperatorInfo
},
{
key: 'wallet',
key: namespaces.WALLETS,
label: 'Wallet',
route: '/settings/wallet',
route: '/settings/wallet-settings',
component: WalletSettings
}
]

View file

@ -1,5 +1,14 @@
import * as R from 'ramda'
const namespaces = {
WALLETS: 'wallets',
OPERATOR_INFO: 'operatorInfo',
NOTIFICATIONS: 'notifications',
SERVICES: 'services',
LOCALE: 'locale',
COMMISSIONS: 'commissions'
}
const mapKeys = R.curry((fn, obj) =>
R.fromPairs(R.map(R.adjust(0, fn), R.toPairs(obj)))
)
@ -23,4 +32,4 @@ const toNamespace = R.curry((key, config) =>
mapKeys(it => `${key}_${it}`)(config)
)
export { fromNamespace, toNamespace }
export { fromNamespace, toNamespace, namespaces }