From f7f5cba7c27e3d921c24eb9c183382795439b7a1 Mon Sep 17 00:00:00 2001 From: Taranto Date: Sun, 11 Oct 2020 18:45:16 +0100 Subject: [PATCH] chore: remove direction option from trigger page --- .../src/pages/Triggers/Triggers.js | 24 +- .../src/pages/Triggers/Triggers.styles.js | 3 + .../src/pages/Triggers/Wizard.js | 40 ++-- .../src/pages/Triggers/helper.js | 220 +++++++++--------- 4 files changed, 151 insertions(+), 136 deletions(-) diff --git a/new-lamassu-admin/src/pages/Triggers/Triggers.js b/new-lamassu-admin/src/pages/Triggers/Triggers.js index 018401c8..a8b8fa6f 100644 --- a/new-lamassu-admin/src/pages/Triggers/Triggers.js +++ b/new-lamassu-admin/src/pages/Triggers/Triggers.js @@ -50,7 +50,9 @@ const Triggers = () => { }) const add = rawConfig => { - const toSave = R.concat([{ id: v4(), ...rawConfig }])(triggers) + const toSave = R.concat([{ id: v4(), direction: 'both', ...rawConfig }])( + triggers + ) setError(false) return saveConfig({ variables: { config: { triggers: toServer(toSave) } } }) } @@ -73,9 +75,13 @@ const Triggers = () => { return ( <> - + - +

Reject reused addresses

{

- setWizard(true)}> - + Add new trigger -
+ + setWizard(true)}> + + Add new trigger + + { switch (step) { + // case 1: + // return txDirection case 1: - return txDirection - case 2: return type - case 3: + case 2: return requirements default: return Fragment @@ -56,11 +56,11 @@ const getStep = step => { const getText = (step, config, currency) => { switch (step) { + // case 1: + // return `In ${getDirectionText(config)} transactions` case 1: - return `In ${getDirectionText(config)} transactions` + return `If the user ${getTypeText(config, currency)}` case 2: - return `if the user ${getTypeText(config, currency)}` - case 3: return `the user will be ${getRequirementText(config)}.` default: return '' @@ -71,18 +71,18 @@ const orUnderline = value => { return R.isEmpty(value) || R.isNil(value) ? '⎼⎼⎼⎼⎼ ' : value } -const getDirectionText = config => { - switch (config.direction) { - case 'both': - return 'both cash-in and cash-out' - case 'cashIn': - return 'cash-in' - case 'cashOut': - return 'cash-out' - default: - return orUnderline(null) - } -} +// const getDirectionText = config => { +// switch (config.direction) { +// case 'both': +// return 'both cash-in and cash-out' +// case 'cashIn': +// return 'cash-in' +// case 'cashOut': +// return 'cash-out' +// default: +// return orUnderline(null) +// } +// } const getTypeText = (config, currency) => { switch (config.triggerType) { diff --git a/new-lamassu-admin/src/pages/Triggers/helper.js b/new-lamassu-admin/src/pages/Triggers/helper.js index c0544dfb..eb77d15d 100644 --- a/new-lamassu-admin/src/pages/Triggers/helper.js +++ b/new-lamassu-admin/src/pages/Triggers/helper.js @@ -7,8 +7,8 @@ import * as Yup from 'yup' import { TextInput, RadioGroup } from 'src/components/inputs/formik' import { H4, Label2, Label1, Info2 } from 'src/components/typography' -import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' -import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' +// import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' +// import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' import { errorColor } from 'src/styling/variables' const useStyles = makeStyles({ @@ -68,7 +68,7 @@ const useStyles = makeStyles({ } }) -const direction = Yup.string().required('Required') +// const direction = Yup.string().required('Required') const triggerType = Yup.string().required('Required') const threshold = Yup.object().shape({ threshold: Yup.number(), @@ -82,95 +82,95 @@ const requirement = Yup.object().shape({ const Schema = Yup.object().shape({ triggerType, requirement, - threshold, - direction + threshold + // direction }) -// Direction -const directionSchema = Yup.object().shape({ direction }) +// Direction V2 only +// const directionSchema = Yup.object().shape({ direction }) -const directionOptions = [ - { - display: 'Both', - code: 'both' - }, - { - display: 'Only cash-in', - code: 'cashIn' - }, - { - display: 'Only cash-out', - code: 'cashOut' - } -] +// const directionOptions = [ +// { +// display: 'Both', +// code: 'both' +// }, +// { +// display: 'Only cash-in', +// code: 'cashIn' +// }, +// { +// display: 'Only cash-out', +// code: 'cashOut' +// } +// ] -const directionOptions2 = [ - { - display: ( - <> - in - - ), - code: 'cashIn' - }, - { - display: ( - <> - out - - ), - code: 'cashOut' - }, - { - display: ( - <> - - - - - - - - - - ), - code: 'both' - } -] +// const directionOptions2 = [ +// { +// display: ( +// <> +// in +// +// ), +// code: 'cashIn' +// }, +// { +// display: ( +// <> +// out +// +// ), +// code: 'cashOut' +// }, +// { +// display: ( +// <> +// +// +// +// +// +// +// +// +// +// ), +// code: 'both' +// } +// ] -const Direction = () => { - const classes = useStyles() - const { errors } = useFormikContext() +// const Direction = () => { +// const classes = useStyles() +// const { errors } = useFormikContext() - const titleClass = { - [classes.error]: errors.direction - } +// const titleClass = { +// [classes.error]: errors.direction +// } - return ( - <> - -

- In which type of transactions will it trigger? -

-
- - - ) -} +// return ( +// <> +// +//

+// In which type of transactions will it trigger? +//

+//
+// +// +// ) +// } -const txDirection = { - schema: directionSchema, - options: directionOptions, - Component: Direction, - initialValues: { direction: '' } -} +// const txDirection = { +// schema: directionSchema, +// options: directionOptions, +// Component: Direction, +// initialValues: { direction: '' } +// } // TYPE const typeSchema = Yup.object().shape({ @@ -317,20 +317,20 @@ const getView = (data, code, compare) => it => { return R.compose(R.prop(code), R.find(R.propEq(compare ?? 'code', it)))(data) } -const DirectionDisplay = ({ code }) => { - const classes = useStyles() - const displayName = getView(directionOptions, 'display')(code) - const showCashIn = code === 'cashIn' || code === 'both' - const showCashOut = code === 'cashOut' || code === 'both' +// const DirectionDisplay = ({ code }) => { +// const classes = useStyles() +// const displayName = getView(directionOptions, 'display')(code) +// const showCashIn = code === 'cashIn' || code === 'both' +// const showCashOut = code === 'cashOut' || code === 'both' - return ( -
- {showCashOut && } - {showCashIn && } - {displayName} -
- ) -} +// return ( +//
+// {showCashOut && } +// {showCashIn && } +// {displayName} +//
+// ) +// } const RequirementInput = () => { const { values } = useFormikContext() @@ -505,19 +505,19 @@ const getElements = (currency, classes) => [ textAlign: 'right', input: () => , view: (it, config) => - }, - { - name: 'direction', - size: 'sm', - width: 282, - view: it => , - input: RadioGroup, - inputProps: { - labelClassName: classes.tableRadioLabel, - className: classes.tableRadioGroup, - options: directionOptions2 - } } + // { + // name: 'direction', + // size: 'sm', + // width: 282, + // view: it => , + // input: RadioGroup, + // inputProps: { + // labelClassName: classes.tableRadioLabel, + // className: classes.tableRadioGroup, + // options: directionOptions2 + // } + // } ] const triggerOrder = R.map(R.prop('code'))(typeOptions) @@ -555,7 +555,7 @@ const toServer = triggers => export { Schema, getElements, - txDirection, + // txDirection, type, requirements, sortBy,