Merge pull request #1050 from chaotixkilla/fix-improve-custom-trigger-ux
Improve custom requirements trigger creation UX
This commit is contained in:
commit
d9d94101ee
4 changed files with 17 additions and 28 deletions
|
|
@ -75,6 +75,7 @@ const TriggerView = ({
|
||||||
error={error?.message}
|
error={error?.message}
|
||||||
save={add}
|
save={add}
|
||||||
onClose={toggleWizard}
|
onClose={toggleWizard}
|
||||||
|
customInfoRequests={customInfoRequests}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{R.isEmpty(triggers) && (
|
{R.isEmpty(triggers) && (
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,10 @@ const GET_CUSTOM_REQUESTS = gql`
|
||||||
const Triggers = () => {
|
const Triggers = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [wizardType, setWizard] = useState(false)
|
const [wizardType, setWizard] = useState(false)
|
||||||
const { data, loading } = useQuery(GET_CONFIG)
|
const { data, loading: configLoading } = useQuery(GET_CONFIG)
|
||||||
const { data: customInfoReqData } = useQuery(GET_CUSTOM_REQUESTS)
|
const { data: customInfoReqData, loading: customInfoLoading } = useQuery(
|
||||||
|
GET_CUSTOM_REQUESTS
|
||||||
|
)
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const [subMenu, setSubMenu] = useState(false)
|
const [subMenu, setSubMenu] = useState(false)
|
||||||
|
|
||||||
|
|
@ -94,6 +96,8 @@ const Triggers = () => {
|
||||||
return setWizard(wizardName)
|
return setWizard(wizardName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loading = configLoading || customInfoLoading
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TitleSection
|
<TitleSection
|
||||||
|
|
@ -178,7 +182,7 @@ const Triggers = () => {
|
||||||
showWizard={wizardType === 'newTrigger'}
|
showWizard={wizardType === 'newTrigger'}
|
||||||
config={data?.config ?? {}}
|
config={data?.config ?? {}}
|
||||||
toggleWizard={toggleWizard('newTrigger')}
|
toggleWizard={toggleWizard('newTrigger')}
|
||||||
customInfoRequests={customInfoRequests}
|
customInfoRequests={enabledCustomInfoRequests}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!loading && subMenu === 'advancedSettings' && (
|
{!loading && subMenu === 'advancedSettings' && (
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,14 @@ const styles = {
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const getStep = (step, currency) => {
|
const getStep = (step, currency, customInfoRequests) => {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// return txDirection
|
// return txDirection
|
||||||
case 1:
|
case 1:
|
||||||
return type(currency)
|
return type(currency)
|
||||||
case 2:
|
case 2:
|
||||||
return requirements
|
return requirements(customInfoRequests)
|
||||||
default:
|
default:
|
||||||
return Fragment
|
return Fragment
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +202,7 @@ const GetValues = ({ setValues }) => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const Wizard = ({ onClose, save, error, currency }) => {
|
const Wizard = ({ onClose, save, error, currency, customInfoRequests }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
const [liveValues, setLiveValues] = useState({})
|
const [liveValues, setLiveValues] = useState({})
|
||||||
|
|
@ -211,7 +211,7 @@ const Wizard = ({ onClose, save, error, currency }) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const isLastStep = step === LAST_STEP
|
const isLastStep = step === LAST_STEP
|
||||||
const stepOptions = getStep(step, currency)
|
const stepOptions = getStep(step, currency, customInfoRequests)
|
||||||
|
|
||||||
const onContinue = async it => {
|
const onContinue = async it => {
|
||||||
const newConfig = R.merge(config, stepOptions.schema.cast(it))
|
const newConfig = R.merge(config, stepOptions.schema.cast(it))
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { useQuery } from '@apollo/react-hooks'
|
|
||||||
import { makeStyles, Box } from '@material-ui/core'
|
import { makeStyles, Box } from '@material-ui/core'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import { Field, useFormikContext } from 'formik'
|
import { Field, useFormikContext } from 'formik'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { memo } from 'react'
|
import React, { memo } from 'react'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
@ -508,16 +506,7 @@ const requirementOptions = [
|
||||||
{ display: 'Block', code: 'block' }
|
{ display: 'Block', code: 'block' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const GET_ACTIVE_CUSTOM_REQUESTS = gql`
|
const Requirement = ({ customInfoRequests }) => {
|
||||||
query customInfoRequests($onlyEnabled: Boolean) {
|
|
||||||
customInfoRequests(onlyEnabled: $onlyEnabled) {
|
|
||||||
id
|
|
||||||
customRequest
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const Requirement = () => {
|
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const {
|
const {
|
||||||
touched,
|
touched,
|
||||||
|
|
@ -526,11 +515,6 @@ const Requirement = () => {
|
||||||
handleChange,
|
handleChange,
|
||||||
setTouched
|
setTouched
|
||||||
} = useFormikContext()
|
} = useFormikContext()
|
||||||
const { data } = useQuery(GET_ACTIVE_CUSTOM_REQUESTS, {
|
|
||||||
variables: {
|
|
||||||
onlyEnabled: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const isSuspend = values?.requirement?.requirement === 'suspend'
|
const isSuspend = values?.requirement?.requirement === 'suspend'
|
||||||
const isCustom = values?.requirement?.requirement === 'custom'
|
const isCustom = values?.requirement?.requirement === 'custom'
|
||||||
|
|
@ -546,8 +530,7 @@ const Requirement = () => {
|
||||||
(!values.requirement?.suspensionDays ||
|
(!values.requirement?.suspensionDays ||
|
||||||
values.requirement?.suspensionDays < 0)
|
values.requirement?.suspensionDays < 0)
|
||||||
|
|
||||||
const customInfoRequests = R.path(['customInfoRequests'])(data) ?? []
|
const enableCustomRequirement = customInfoRequests?.length > 0
|
||||||
const enableCustomRequirement = customInfoRequests.length > 0
|
|
||||||
const customInfoOption = {
|
const customInfoOption = {
|
||||||
display: 'Custom information requirement',
|
display: 'Custom information requirement',
|
||||||
code: 'custom'
|
code: 'custom'
|
||||||
|
|
@ -604,10 +587,11 @@ const Requirement = () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const requirements = {
|
const requirements = customInfoRequests => ({
|
||||||
schema: requirementSchema,
|
schema: requirementSchema,
|
||||||
options: requirementOptions,
|
options: requirementOptions,
|
||||||
Component: Requirement,
|
Component: Requirement,
|
||||||
|
props: { customInfoRequests },
|
||||||
initialValues: {
|
initialValues: {
|
||||||
requirement: {
|
requirement: {
|
||||||
requirement: '',
|
requirement: '',
|
||||||
|
|
@ -615,7 +599,7 @@ const requirements = {
|
||||||
customInfoRequestId: ''
|
customInfoRequestId: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
const getView = (data, code, compare) => it => {
|
const getView = (data, code, compare) => it => {
|
||||||
if (!data) return ''
|
if (!data) return ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue