fix: flat schema on operator info pages
This commit is contained in:
parent
d65482958a
commit
ec73f0b022
10 changed files with 106 additions and 107 deletions
|
|
@ -51,7 +51,8 @@ const ETable = ({
|
||||||
const [editingId, setEditingId] = useState(null)
|
const [editingId, setEditingId] = useState(null)
|
||||||
const [adding, setAdding] = useState(false)
|
const [adding, setAdding] = useState(false)
|
||||||
|
|
||||||
const innerSave = async it => {
|
const innerSave = async value => {
|
||||||
|
const it = validationSchema.cast(value)
|
||||||
const index = R.findIndex(R.propEq('id', it.id))(data)
|
const index = R.findIndex(R.propEq('id', it.id))(data)
|
||||||
const list = index !== -1 ? R.update(index, it, data) : R.prepend(it, data)
|
const list = index !== -1 ? R.update(index, it, data) : R.prepend(it, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ const EditableNumber = ({
|
||||||
name={name}
|
name={name}
|
||||||
component={TextInput}
|
component={TextInput}
|
||||||
textAlign="right"
|
textAlign="right"
|
||||||
type="text"
|
|
||||||
width={width}
|
width={width}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ const SingleFieldEditableNumber = ({
|
||||||
enableReinitialize
|
enableReinitialize
|
||||||
initialValues={{ [name]: (data && data[name]) ?? '' }}
|
initialValues={{ [name]: (data && data[name]) ?? '' }}
|
||||||
validationSchema={schema}
|
validationSchema={schema}
|
||||||
onSubmit={it => save(section, it)}
|
onSubmit={it => save(section, schema.cast(it))}
|
||||||
onReset={() => {
|
onReset={() => {
|
||||||
setEditing(name, false)
|
setEditing(name, false)
|
||||||
}}>
|
}}>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ const FiatBalance = ({ section }) => {
|
||||||
fiatBalanceCassette2: data?.fiatBalanceCassette2 ?? ''
|
fiatBalanceCassette2: data?.fiatBalanceCassette2 ?? ''
|
||||||
}}
|
}}
|
||||||
validationSchema={schema}
|
validationSchema={schema}
|
||||||
onSubmit={it => save(section, it)}
|
onSubmit={it => save(section, schema.cast(it))}
|
||||||
onReset={() => {
|
onReset={() => {
|
||||||
setEditing(NAME, false)
|
setEditing(NAME, false)
|
||||||
}}>
|
}}>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const FiatBalanceOverrides = ({ section }) => {
|
||||||
|
|
||||||
const overridenMachines = R.map(override => override.machine, setupValues)
|
const overridenMachines = R.map(override => override.machine, setupValues)
|
||||||
const suggestionFilter = R.filter(
|
const suggestionFilter = R.filter(
|
||||||
it => !R.contains(it.code, overridenMachines)
|
it => !R.contains(it.deviceId, overridenMachines)
|
||||||
)
|
)
|
||||||
const suggestions = suggestionFilter(machines)
|
const suggestions = suggestionFilter(machines)
|
||||||
|
|
||||||
|
|
@ -50,17 +50,21 @@ const FiatBalanceOverrides = ({ section }) => {
|
||||||
.required()
|
.required()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const viewMachine = it =>
|
||||||
|
R.compose(R.path(['name']), R.find(R.propEq('deviceId', it)))(machines)
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
{
|
{
|
||||||
name: MACHINE_KEY,
|
name: MACHINE_KEY,
|
||||||
width: 238,
|
width: 238,
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
view: R.path(['name']),
|
view: viewMachine,
|
||||||
input: Autocomplete,
|
input: Autocomplete,
|
||||||
inputProps: {
|
inputProps: {
|
||||||
options: it => R.concat(suggestions, findSuggestion(it)),
|
options: it => R.concat(suggestions, findSuggestion(it)),
|
||||||
limit: null,
|
limit: null,
|
||||||
getOptionSelected: R.eqProps('display')
|
valueProp: 'deviceId',
|
||||||
|
getLabel: R.path(['name'])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +94,7 @@ const FiatBalanceOverrides = ({ section }) => {
|
||||||
enableDelete
|
enableDelete
|
||||||
enableEdit
|
enableEdit
|
||||||
enableCreate
|
enableCreate
|
||||||
save={it => save(section, it)}
|
save={it => save(section, validationSchema.cast(it))}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
validationSchema={validationSchema}
|
validationSchema={validationSchema}
|
||||||
forceDisable={isDisabled(NAME) || !machines}
|
forceDisable={isDisabled(NAME) || !machines}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { useQuery, useMutation } from '@apollo/react-hooks'
|
import { useQuery, useMutation } from '@apollo/react-hooks'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { gql } from 'apollo-boost'
|
import { gql } from 'apollo-boost'
|
||||||
|
import * as R from 'ramda'
|
||||||
import React, { useState, memo } from 'react'
|
import React, { useState, memo } from 'react'
|
||||||
|
|
||||||
import Popper from 'src/components/Popper'
|
import Popper from 'src/components/Popper'
|
||||||
|
|
@ -9,6 +10,7 @@ import { Button } from 'src/components/buttons'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import { H4, P, Label2 } from 'src/components/typography'
|
import { H4, P, Label2 } from 'src/components/typography'
|
||||||
import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg'
|
import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg'
|
||||||
|
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
import { mainStyles } from './CoinATMRadar.styles'
|
import { mainStyles } from './CoinATMRadar.styles'
|
||||||
|
|
||||||
|
|
@ -48,17 +50,25 @@ const CoinATMRadar = memo(() => {
|
||||||
// TODO: treat errors on useMutation and useQuery
|
// TODO: treat errors on useMutation and useQuery
|
||||||
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
||||||
onCompleted: configResponse =>
|
onCompleted: configResponse =>
|
||||||
setCoinAtmRadarConfig(configResponse.saveConfig.coinAtmRadar)
|
setCoinAtmRadarConfig(
|
||||||
|
fromNamespace(namespaces.COIN_ATM_RADAR, configResponse.saveConfig)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
useQuery(GET_CONFIG, {
|
useQuery(GET_CONFIG, {
|
||||||
onCompleted: configResponse => {
|
onCompleted: configResponse => {
|
||||||
setCoinAtmRadarConfig(
|
const response = fromNamespace(
|
||||||
configResponse?.config?.coinAtmRadar ?? initialValues
|
namespaces.COIN_ATM_RADAR,
|
||||||
|
configResponse.config
|
||||||
)
|
)
|
||||||
|
const values = R.merge(initialValues, response)
|
||||||
|
setCoinAtmRadarConfig(values)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const save = it => saveConfig({ variables: { config: { coinAtmRadar: it } } })
|
const save = it =>
|
||||||
|
saveConfig({
|
||||||
|
variables: { config: toNamespace(namespaces.COIN_ATM_RADAR, it) }
|
||||||
|
})
|
||||||
|
|
||||||
const handleOpenHelpPopper = event => {
|
const handleOpenHelpPopper = event => {
|
||||||
setHelpPopperAnchorEl(helpPopperAnchorEl ? null : event.currentTarget)
|
setHelpPopperAnchorEl(helpPopperAnchorEl ? null : event.currentTarget)
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,37 @@
|
||||||
import React, { useState } from 'react'
|
|
||||||
import classnames from 'classnames'
|
|
||||||
import * as R from 'ramda'
|
|
||||||
import * as Yup from 'yup'
|
|
||||||
import { gql } from 'apollo-boost'
|
|
||||||
import { Form, Formik, Field as FormikField } from 'formik'
|
|
||||||
import { makeStyles } from '@material-ui/core'
|
|
||||||
import { useQuery, useMutation } from '@apollo/react-hooks'
|
import { useQuery, useMutation } from '@apollo/react-hooks'
|
||||||
|
import { makeStyles } from '@material-ui/core'
|
||||||
|
import { gql } from 'apollo-boost'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
import { Form, Formik, Field as FormikField } from 'formik'
|
||||||
|
import * as R from 'ramda'
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
import { Info2, Info3, Label1 } from 'src/components/typography'
|
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
|
||||||
import RadioGroupFormik from 'src/components/inputs/formik/RadioGroup'
|
|
||||||
import {
|
|
||||||
PhoneNumberInputFormik,
|
|
||||||
maskValue,
|
|
||||||
mask
|
|
||||||
} from 'src/components/inputs/formik/PhoneNumberInput'
|
|
||||||
import { Link } from 'src/components/buttons'
|
|
||||||
import ErrorMessage from 'src/components/ErrorMessage'
|
import ErrorMessage from 'src/components/ErrorMessage'
|
||||||
|
import { Link } from 'src/components/buttons'
|
||||||
|
import RadioGroupFormik from 'src/components/inputs/formik/RadioGroup'
|
||||||
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
import { Info2, Info3, Label1, Label3 } from 'src/components/typography'
|
||||||
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
||||||
import { ReactComponent as WarningIcon } from 'src/styling/icons/warning-icon/comet.svg'
|
import { ReactComponent as WarningIcon } from 'src/styling/icons/warning-icon/comet.svg'
|
||||||
|
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
styles as globalStyles,
|
styles as globalStyles,
|
||||||
contactInfoStyles
|
contactInfoStyles
|
||||||
} from './OperatorInfo.styles'
|
} from './OperatorInfo.styles'
|
||||||
|
|
||||||
|
const validationSchema = Yup.object().shape({
|
||||||
|
infoCardEnabled: Yup.boolean().required(),
|
||||||
|
fullName: Yup.string().required(),
|
||||||
|
phoneNumber: Yup.string().required(),
|
||||||
|
email: Yup.string()
|
||||||
|
.email('Please enter a valid email address')
|
||||||
|
.required(),
|
||||||
|
website: Yup.string().required(),
|
||||||
|
companyNumber: Yup.string().required()
|
||||||
|
})
|
||||||
|
|
||||||
const fieldStyles = {
|
const fieldStyles = {
|
||||||
field: {
|
field: {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
|
|
@ -38,12 +45,13 @@ const fieldStyles = {
|
||||||
'& > p:first-child': {
|
'& > p:first-child': {
|
||||||
height: 16,
|
height: 16,
|
||||||
lineHeight: '16px',
|
lineHeight: '16px',
|
||||||
paddingLeft: 3,
|
transform: 'scale(0.75)',
|
||||||
|
transformOrigin: 'left',
|
||||||
|
paddingLeft: 0,
|
||||||
margin: [[0, 0, 5, 0]]
|
margin: [[0, 0, 5, 0]]
|
||||||
},
|
},
|
||||||
'& > p:last-child': {
|
'& > p:last-child': {
|
||||||
margin: 0,
|
margin: 0
|
||||||
paddingLeft: 4
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +70,7 @@ const Field = ({ editing, field, displayValue, ...props }) => {
|
||||||
<div className={classnames(classNames)}>
|
<div className={classnames(classNames)}>
|
||||||
{!editing && (
|
{!editing && (
|
||||||
<>
|
<>
|
||||||
<Label1>{field.label}</Label1>
|
<Label3>{field.label}</Label3>
|
||||||
<Info3>{displayValue(field.value)}</Info3>
|
<Info3>{displayValue(field.value)}</Info3>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
@ -93,9 +101,6 @@ const SAVE_CONFIG = gql`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const INFO_CARD_ENABLED = 'On'
|
|
||||||
const INFO_CARD_DISABLED = 'Off'
|
|
||||||
|
|
||||||
const styles = R.merge(globalStyles, contactInfoStyles)
|
const styles = R.merge(globalStyles, contactInfoStyles)
|
||||||
|
|
||||||
const contactUseStyles = makeStyles(styles)
|
const contactUseStyles = makeStyles(styles)
|
||||||
|
|
@ -106,8 +111,7 @@ const ContactInfo = () => {
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
const { operatorInfo } = data.saveConfig
|
setInfo(fromNamespace(namespaces.CONTACT_INFO, data.saveConfig))
|
||||||
setInfo(operatorInfo)
|
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
},
|
},
|
||||||
onError: e => setError(e)
|
onError: e => setError(e)
|
||||||
|
|
@ -115,13 +119,14 @@ const ContactInfo = () => {
|
||||||
|
|
||||||
useQuery(GET_CONFIG, {
|
useQuery(GET_CONFIG, {
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
const { operatorInfo } = data.config
|
setInfo(fromNamespace(namespaces.CONTACT_INFO, data.config))
|
||||||
setInfo(operatorInfo ?? {})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const save = it => {
|
const save = it => {
|
||||||
return saveConfig({ variables: { config: { operatorInfo: it } } })
|
return saveConfig({
|
||||||
|
variables: { config: toNamespace(namespaces.CONTACT_INFO, it) }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const classes = contactUseStyles()
|
const classes = contactUseStyles()
|
||||||
|
|
@ -132,43 +137,37 @@ const ContactInfo = () => {
|
||||||
{
|
{
|
||||||
name: 'infoCardEnabled',
|
name: 'infoCardEnabled',
|
||||||
label: 'Info Card Enabled',
|
label: 'Info Card Enabled',
|
||||||
value: info.infoCardEnabled ?? INFO_CARD_DISABLED,
|
value: String(info.infoCardEnabled),
|
||||||
type: 'select',
|
|
||||||
component: RadioGroupFormik
|
component: RadioGroupFormik
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'fullName',
|
name: 'fullName',
|
||||||
label: 'Full name',
|
label: 'Full name',
|
||||||
value: info.fullName ?? '',
|
value: info.fullName ?? '',
|
||||||
type: 'text',
|
|
||||||
component: TextInputFormik
|
component: TextInputFormik
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'phoneNumber',
|
name: 'phoneNumber',
|
||||||
label: 'Phone number',
|
label: 'Phone number',
|
||||||
value: maskValue(info.phoneNumber) ?? '',
|
value: info.phoneNumber ?? '',
|
||||||
type: 'text',
|
component: TextInputFormik
|
||||||
component: PhoneNumberInputFormik
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'email',
|
name: 'email',
|
||||||
label: 'Email',
|
label: 'Email',
|
||||||
value: info.email ?? '',
|
value: info.email ?? '',
|
||||||
type: 'text',
|
|
||||||
component: TextInputFormik
|
component: TextInputFormik
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'website',
|
name: 'website',
|
||||||
label: 'Website',
|
label: 'Website',
|
||||||
value: info.website ?? '',
|
value: info.website ?? '',
|
||||||
type: 'text',
|
|
||||||
component: TextInputFormik
|
component: TextInputFormik
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'companyNumber',
|
name: 'companyNumber',
|
||||||
label: 'Company number',
|
label: 'Company number',
|
||||||
value: info.companyNumber ?? '',
|
value: info.companyNumber ?? '',
|
||||||
type: 'text',
|
|
||||||
component: TextInputFormik
|
component: TextInputFormik
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -186,27 +185,7 @@ const ContactInfo = () => {
|
||||||
email: findValue('email'),
|
email: findValue('email'),
|
||||||
website: findValue('website'),
|
website: findValue('website'),
|
||||||
companyNumber: findValue('companyNumber')
|
companyNumber: findValue('companyNumber')
|
||||||
},
|
}
|
||||||
validationSchema: Yup.object().shape({
|
|
||||||
fullName: Yup.string()
|
|
||||||
.max(100, 'Too long')
|
|
||||||
.required(),
|
|
||||||
phoneNumber: Yup.string()
|
|
||||||
.matches(mask, { excludeEmptyString: true })
|
|
||||||
.max(100, 'Too long')
|
|
||||||
.required(),
|
|
||||||
email: Yup.string()
|
|
||||||
.email('Please enter a valid email address')
|
|
||||||
.max(100, 'Too long')
|
|
||||||
.required(),
|
|
||||||
website: Yup.string()
|
|
||||||
.url('Please enter a valid url')
|
|
||||||
.max(100, 'Too long')
|
|
||||||
.required(),
|
|
||||||
companyNumber: Yup.string()
|
|
||||||
.max(30, 'Too long')
|
|
||||||
.required()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -225,9 +204,9 @@ const ContactInfo = () => {
|
||||||
<Formik
|
<Formik
|
||||||
enableReinitialize
|
enableReinitialize
|
||||||
initialValues={form.initialValues}
|
initialValues={form.initialValues}
|
||||||
validationSchema={form.validationSchema}
|
validationSchema={validationSchema}
|
||||||
onSubmit={values => save(values)}
|
onSubmit={values => save(validationSchema.cast(values))}
|
||||||
onReset={(values, bag) => {
|
onReset={() => {
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
setError(null)
|
setError(null)
|
||||||
}}>
|
}}>
|
||||||
|
|
@ -236,10 +215,10 @@ const ContactInfo = () => {
|
||||||
<Field
|
<Field
|
||||||
field={findField('infoCardEnabled')}
|
field={findField('infoCardEnabled')}
|
||||||
editing={editing}
|
editing={editing}
|
||||||
displayValue={displayTextValue}
|
displayValue={it => (it === 'true' ? 'On' : 'Off')}
|
||||||
options={[
|
options={[
|
||||||
{ label: 'On', value: INFO_CARD_ENABLED },
|
{ display: 'On', code: 'true' },
|
||||||
{ label: 'Off', value: INFO_CARD_DISABLED }
|
{ display: 'Off', code: 'false' }
|
||||||
]}
|
]}
|
||||||
className={classes.radioButtons}
|
className={classes.radioButtons}
|
||||||
resetError={() => setError(null)}
|
resetError={() => setError(null)}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,26 @@
|
||||||
import { makeStyles } from '@material-ui/core'
|
import { makeStyles } from '@material-ui/core'
|
||||||
import * as R from 'ramda'
|
import Grid from '@material-ui/core/Grid'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import Title from 'src/components/Title'
|
|
||||||
import Sidebar from 'src/components/layout/Sidebar'
|
import Sidebar from 'src/components/layout/Sidebar'
|
||||||
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
import logsStyles from '../Logs.styles'
|
|
||||||
|
|
||||||
import CoinAtmRadar from './CoinATMRadar'
|
import CoinAtmRadar from './CoinATMRadar'
|
||||||
import ContactInfo from './ContactInfo'
|
import ContactInfo from './ContactInfo'
|
||||||
import ReceiptPrinting from './ReceiptPrinting'
|
import ReceiptPrinting from './ReceiptPrinting'
|
||||||
import TermsConditions from './TermsConditions'
|
import TermsConditions from './TermsConditions'
|
||||||
|
|
||||||
const localStyles = {
|
const styles = {
|
||||||
contentWrapper: {
|
grid: {
|
||||||
width: '100%',
|
flex: 1,
|
||||||
|
height: '100%'
|
||||||
|
},
|
||||||
|
content: {
|
||||||
marginLeft: 48,
|
marginLeft: 48,
|
||||||
paddingTop: 15
|
paddingTop: 15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = R.merge(logsStyles, localStyles)
|
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const CONTACT_INFORMATION = 'Contact information'
|
const CONTACT_INFORMATION = 'Contact information'
|
||||||
|
|
@ -39,25 +38,21 @@ const OperatorInfo = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={classes.titleWrapper}>
|
<TitleSection title="Operator information"></TitleSection>
|
||||||
<div className={classes.titleAndButtonsContainer}>
|
<Grid container className={classes.grid}>
|
||||||
<Title>Operator information</Title>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className={classes.wrapper}>
|
|
||||||
<Sidebar
|
<Sidebar
|
||||||
data={pages}
|
data={pages}
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
displayName={it => it}
|
displayName={it => it}
|
||||||
onClick={it => setSelected(it)}
|
onClick={it => setSelected(it)}
|
||||||
/>
|
/>
|
||||||
<div className={classes.contentWrapper}>
|
<div className={classes.content}>
|
||||||
{isSelected(CONTACT_INFORMATION) && <ContactInfo />}
|
{isSelected(CONTACT_INFORMATION) && <ContactInfo />}
|
||||||
{isSelected(RECEIPT) && <ReceiptPrinting />}
|
{isSelected(RECEIPT) && <ReceiptPrinting />}
|
||||||
{isSelected(TERMS_CONDITIONS) && <TermsConditions />}
|
{isSelected(TERMS_CONDITIONS) && <TermsConditions />}
|
||||||
{isSelected(COIN_ATM_RADAR) && <CoinAtmRadar />}
|
{isSelected(COIN_ATM_RADAR) && <CoinAtmRadar />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
import React, { useState } from 'react'
|
|
||||||
import classnames from 'classnames'
|
|
||||||
import * as R from 'ramda'
|
|
||||||
import * as Yup from 'yup'
|
|
||||||
import { Form, Formik, Field } from 'formik'
|
|
||||||
import { gql } from 'apollo-boost'
|
|
||||||
import { makeStyles } from '@material-ui/core'
|
|
||||||
import { useQuery, useMutation } from '@apollo/react-hooks'
|
import { useQuery, useMutation } from '@apollo/react-hooks'
|
||||||
|
import { makeStyles } from '@material-ui/core'
|
||||||
|
import { gql } from 'apollo-boost'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
import { Form, Formik, Field } from 'formik'
|
||||||
|
import * as R from 'ramda'
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
import { Info2, Label2 } from 'src/components/typography'
|
import ErrorMessage from 'src/components/ErrorMessage'
|
||||||
|
import { Button } from 'src/components/buttons'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
import { Button } from 'src/components/buttons'
|
import { Info2, Label2 } from 'src/components/typography'
|
||||||
import ErrorMessage from 'src/components/ErrorMessage'
|
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
styles as globalStyles,
|
styles as globalStyles,
|
||||||
|
|
@ -40,7 +41,10 @@ const TermsConditions = () => {
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
const { termsAndConditions } = data.saveConfig
|
const termsAndConditions = fromNamespace(
|
||||||
|
namespaces.TERMS_CONDITIONS,
|
||||||
|
data.saveConfig
|
||||||
|
)
|
||||||
setFormData(termsAndConditions)
|
setFormData(termsAndConditions)
|
||||||
setShowOnScreen(termsAndConditions.show)
|
setShowOnScreen(termsAndConditions.show)
|
||||||
setError(null)
|
setError(null)
|
||||||
|
|
@ -52,7 +56,10 @@ const TermsConditions = () => {
|
||||||
|
|
||||||
useQuery(GET_CONFIG, {
|
useQuery(GET_CONFIG, {
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
const { termsAndConditions } = data.config
|
const termsAndConditions = fromNamespace(
|
||||||
|
namespaces.TERMS_CONDITIONS,
|
||||||
|
data.config
|
||||||
|
)
|
||||||
setFormData(termsAndConditions ?? {})
|
setFormData(termsAndConditions ?? {})
|
||||||
setShowOnScreen(termsAndConditions?.show ?? false)
|
setShowOnScreen(termsAndConditions?.show ?? false)
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +68,7 @@ const TermsConditions = () => {
|
||||||
const save = it => {
|
const save = it => {
|
||||||
setError(null)
|
setError(null)
|
||||||
return saveConfig({
|
return saveConfig({
|
||||||
variables: { config: { termsAndConditions: it } }
|
variables: { config: toNamespace(namespaces.TERMS_CONDITIONS, it) }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ const namespaces = {
|
||||||
NOTIFICATIONS: 'notifications',
|
NOTIFICATIONS: 'notifications',
|
||||||
SERVICES: 'services',
|
SERVICES: 'services',
|
||||||
LOCALE: 'locale',
|
LOCALE: 'locale',
|
||||||
COMMISSIONS: 'commissions'
|
COMMISSIONS: 'commissions',
|
||||||
|
CONTACT_INFO: 'contactInfo',
|
||||||
|
RECEIPT: 'receipt',
|
||||||
|
COIN_ATM_RADAR: 'coinAtmRadar',
|
||||||
|
TERMS_CONDITIONS: 'termsConditions'
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapKeys = R.curry((fn, obj) =>
|
const mapKeys = R.curry((fn, obj) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue