chore: change string returns to JSX elements
This commit is contained in:
parent
3b33ae0255
commit
3532b1849f
1 changed files with 54 additions and 52 deletions
|
|
@ -60,21 +60,22 @@ const getStep = (step, currency) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getText = (step, config, currency) => {
|
const getText = (step, config, currency, classes) => {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// return `In ${getDirectionText(config)} transactions`
|
// return `In ${getDirectionText(config)} transactions`
|
||||||
case 1:
|
case 1:
|
||||||
return `If the user ${getTypeText(config, currency)}`
|
return <>If the user {getTypeText(config, currency, classes)}</>
|
||||||
case 2:
|
case 2:
|
||||||
return `the user will be ${getRequirementText(config)}.`
|
return <>the user will be {getRequirementText(config, classes)}.</>
|
||||||
default:
|
default:
|
||||||
return ''
|
return <></>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const orUnderline = value => {
|
const orUnderline = (value, classes) => {
|
||||||
return R.isEmpty(value) || R.isNil(value) ? '⎼⎼⎼⎼⎼ ' : value
|
const blankSpaceEl = <span className={classes.blankSpace}></span>
|
||||||
|
return R.isEmpty(value) || R.isNil(value) ? blankSpaceEl : value
|
||||||
}
|
}
|
||||||
|
|
||||||
// const getDirectionText = config => {
|
// const getDirectionText = config => {
|
||||||
|
|
@ -90,79 +91,80 @@ const orUnderline = value => {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const getTypeText = (config, currency) => {
|
const getTypeText = (config, currency, classes) => {
|
||||||
switch (config.triggerType) {
|
switch (config.triggerType) {
|
||||||
case 'txAmount':
|
case 'txAmount':
|
||||||
return `makes a single transaction over ${orUnderline(
|
return (
|
||||||
config.threshold.threshold
|
<>
|
||||||
)} ${currency}`
|
makes a single transaction over{' '}
|
||||||
|
{orUnderline(config.threshold.threshold, classes)} {currency}
|
||||||
|
</>
|
||||||
|
)
|
||||||
case 'txVolume':
|
case 'txVolume':
|
||||||
return `makes ${orUnderline(
|
return (
|
||||||
config.threshold.threshold
|
<>
|
||||||
)} ${currency} worth of transactions within ${orUnderline(
|
makes {orUnderline(config.threshold.threshold, classes)} {currency}{' '}
|
||||||
config.threshold.thresholdDays
|
worth of transactions within{' '}
|
||||||
)} days`
|
{orUnderline(config.threshold.thresholdDays, classes)} days
|
||||||
|
</>
|
||||||
|
)
|
||||||
case 'txVelocity':
|
case 'txVelocity':
|
||||||
return `makes ${orUnderline(
|
return (
|
||||||
config.threshold.threshold
|
<>
|
||||||
)} transactions in ${orUnderline(config.threshold.thresholdDays)} days`
|
makes {orUnderline(config.threshold.threshold, classes)} transactions
|
||||||
|
in {orUnderline(config.threshold.thresholdDays, classes)} days
|
||||||
|
</>
|
||||||
|
)
|
||||||
case 'consecutiveDays':
|
case 'consecutiveDays':
|
||||||
return `at least one transaction every day for ${orUnderline(
|
return (
|
||||||
config.threshold.thresholdDays
|
<>
|
||||||
)} days`
|
at least one transaction every day for{' '}
|
||||||
|
{orUnderline(config.threshold.thresholdDays, classes)} days
|
||||||
|
</>
|
||||||
|
)
|
||||||
default:
|
default:
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRequirementText = config => {
|
const getRequirementText = (config, classes) => {
|
||||||
switch (config.requirement?.requirement) {
|
switch (config.requirement?.requirement) {
|
||||||
case 'sms':
|
case 'sms':
|
||||||
return 'asked to enter code provided through SMS verification'
|
return <>asked to enter code provided through SMS verification</>
|
||||||
case 'idCardPhoto':
|
case 'idCardPhoto':
|
||||||
return 'asked to scan a ID with photo'
|
return <>asked to scan a ID with photo</>
|
||||||
case 'idCardData':
|
case 'idCardData':
|
||||||
return 'asked to scan a ID'
|
return <>asked to scan a ID</>
|
||||||
case 'facephoto':
|
case 'facephoto':
|
||||||
return 'asked to have a photo taken'
|
return <>asked to have a photo taken</>
|
||||||
case 'usSsn':
|
case 'usSsn':
|
||||||
return 'asked to input his social security number'
|
return <>asked to input his social security number</>
|
||||||
case 'sanctions':
|
case 'sanctions':
|
||||||
return 'matched against the OFAC sanctions list'
|
return <>matched against the OFAC sanctions list</>
|
||||||
case 'superuser':
|
case 'superuser':
|
||||||
return ''
|
return <></>
|
||||||
case 'suspend':
|
case 'suspend':
|
||||||
return `suspended for ${orUnderline(
|
return (
|
||||||
config.requirement.suspensionDays
|
<>
|
||||||
)} days`
|
suspended for{' '}
|
||||||
|
{orUnderline(config.requirement.suspensionDays, classes)} days
|
||||||
|
</>
|
||||||
|
)
|
||||||
case 'block':
|
case 'block':
|
||||||
return 'blocked'
|
return <>blocked</>
|
||||||
default:
|
default:
|
||||||
return orUnderline(null)
|
return orUnderline(null, classes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const InfoPanel = ({ step, config = {}, liveValues = {}, currency }) => {
|
const InfoPanel = ({ step, config = {}, liveValues = {}, currency }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
const oldText = R.range(1, step)
|
const oldText = R.range(1, step).map(it =>
|
||||||
.map(it => getText(it, config, currency))
|
getText(it, config, currency, classes)
|
||||||
.join(', ')
|
|
||||||
const newText = getText(step, liveValues, currency)
|
|
||||||
const isLastStep = step === LAST_STEP
|
|
||||||
|
|
||||||
const newTextParts = newText.split('⎼⎼⎼⎼⎼ ')
|
|
||||||
const mapIndexed = R.addIndex(R.map)
|
|
||||||
const newTextElements = mapIndexed((it, idx) => {
|
|
||||||
return idx === newTextParts.length - 1 ? (
|
|
||||||
<span className={classes.infoCurrentText}>{it}</span>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<span className={classes.infoCurrentText}>{it}</span>
|
|
||||||
<span className={classes.blankSpace}></span>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
})(newTextParts)
|
const newText = getText(step, liveValues, currency, classes)
|
||||||
|
const isLastStep = step === LAST_STEP
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -170,7 +172,7 @@ const InfoPanel = ({ step, config = {}, liveValues = {}, currency }) => {
|
||||||
<Info3 noMargin className={classes.infoText}>
|
<Info3 noMargin className={classes.infoText}>
|
||||||
{oldText}
|
{oldText}
|
||||||
{step !== 1 && ', '}
|
{step !== 1 && ', '}
|
||||||
{newTextElements}
|
{newText}
|
||||||
{!isLastStep && '...'}
|
{!isLastStep && '...'}
|
||||||
</Info3>
|
</Info3>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue