From 9760f02a0e33338e2c7a30b90a843ef803d78d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Tue, 8 Mar 2022 15:15:46 +0000 Subject: [PATCH 01/10] fix: custom requirements and machine name comparison standardization --- new-lamassu-admin/src/pages/AddMachine/AddMachine.js | 6 +++++- .../Triggers/CustomInfoRequests/Forms/NameOfRequirement.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/new-lamassu-admin/src/pages/AddMachine/AddMachine.js b/new-lamassu-admin/src/pages/AddMachine/AddMachine.js index 5cc36b47..f74deff2 100644 --- a/new-lamassu-admin/src/pages/AddMachine/AddMachine.js +++ b/new-lamassu-admin/src/pages/AddMachine/AddMachine.js @@ -125,7 +125,11 @@ const validationSchema = Yup.object().shape({ .test( 'unique-name', 'Machine name is already in use.', - (value, context) => !context.options.context.machineNames.includes(value) + (value, context) => + !R.any( + it => R.equals(R.toLower(it), R.toLower(value)), + context.options.context.machineNames + ) ) }) diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/NameOfRequirement.js b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/NameOfRequirement.js index 991f65f7..9450b432 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/NameOfRequirement.js +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/NameOfRequirement.js @@ -34,8 +34,8 @@ const validationSchema = existingRequirements => 'unique-name', 'A custom information requirement with that name already exists', (value, _context) => - !R.includes( - value, + !R.any( + it => R.equals(R.toLower(it), R.toLower(value)), R.map(it => it.customRequest.name, existingRequirements) ) ) From 93873306a9fa58c999769da953d051fc9ae07ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Tue, 8 Mar 2022 17:12:05 +0000 Subject: [PATCH 02/10] feat: remove 0conf steps from cashout setup wizard --- new-lamassu-admin/src/pages/Cashout/Wizard.js | 12 +---- .../src/pages/Cashout/WizardStep.js | 47 ++----------------- 2 files changed, 6 insertions(+), 53 deletions(-) diff --git a/new-lamassu-admin/src/pages/Cashout/Wizard.js b/new-lamassu-admin/src/pages/Cashout/Wizard.js index 6b7cb824..f9d5f187 100644 --- a/new-lamassu-admin/src/pages/Cashout/Wizard.js +++ b/new-lamassu-admin/src/pages/Cashout/Wizard.js @@ -17,7 +17,7 @@ const MODAL_WIDTH = 554 const MODAL_HEIGHT = 520 const Wizard = ({ machine, locale, onClose, save, error }) => { - const LAST_STEP = machine.numberOfCassettes + 2 + const LAST_STEP = machine.numberOfCassettes + 1 const [{ step, config }, setState] = useState({ step: 0, config: { active: true } @@ -66,14 +66,6 @@ const Wizard = ({ machine, locale, onClose, save, error }) => { 1 ) - steps.push({ - type: 'zeroConfLimit', - display: '0-conf Limit', - schema: Yup.object().shape({ - zeroConfLimit: Yup.number().required() - }) - }) - const schema = () => Yup.object().shape({ cassette1: Yup.number().required(), @@ -113,7 +105,7 @@ const Wizard = ({ machine, locale, onClose, save, error }) => { name={machine.name} numberOfCassettes={machine.numberOfCassettes} error={error} - lastStep={isLastStep} + isLastStep={isLastStep} steps={steps} fiatCurrency={locale.fiatCurrency} options={options} diff --git a/new-lamassu-admin/src/pages/Cashout/WizardStep.js b/new-lamassu-admin/src/pages/Cashout/WizardStep.js index f292503b..c4694c35 100644 --- a/new-lamassu-admin/src/pages/Cashout/WizardStep.js +++ b/new-lamassu-admin/src/pages/Cashout/WizardStep.js @@ -44,7 +44,7 @@ const WizardStep = ({ step, schema, error, - lastStep, + isLastStep, onContinue, steps, fiatCurrency, @@ -53,7 +53,7 @@ const WizardStep = ({ }) => { const classes = useStyles() - const label = lastStep ? 'Finish' : 'Next' + const label = isLastStep ? 'Finish' : 'Next' return ( <> @@ -62,7 +62,7 @@ const WizardStep = ({ - {step <= numberOfCassettes && ( + {!isLastStep && ( )} - {step === numberOfCassettes + 1 && ( - -
-
-
-

Edit 0-conf Limit

- - Choose a limit -
- - - {fiatCurrency} - -
-
-
- - -
-
- )} - - {lastStep && ( + {isLastStep && (
Cash Cassette Bill Count

From 2e3e050c544e9be789c943fb641ad6b7d7133c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Tue, 8 Mar 2022 17:31:44 +0000 Subject: [PATCH 03/10] refactor: replace `until` loop with `map` --- new-lamassu-admin/src/pages/Cashout/Wizard.js | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/new-lamassu-admin/src/pages/Cashout/Wizard.js b/new-lamassu-admin/src/pages/Cashout/Wizard.js index f9d5f187..826955a0 100644 --- a/new-lamassu-admin/src/pages/Cashout/Wizard.js +++ b/new-lamassu-admin/src/pages/Cashout/Wizard.js @@ -46,24 +46,18 @@ const Wizard = ({ machine, locale, onClose, save, error }) => { }) } - const steps = [] - - R.until( - R.gt(R.__, machine.numberOfCassettes), - it => { - steps.push({ - type: `cassette${it}`, - display: `Cassette ${it}`, - component: Autocomplete, - inputProps: { - options: R.map(it => ({ code: it, display: it }))(options), - labelProp: 'display', - valueProp: 'code' - } - }) - return R.add(1, it) - }, - 1 + const steps = R.map( + it => ({ + type: `cassette${it}`, + display: `Cassette ${it}`, + component: Autocomplete, + inputProps: { + options: R.map(it => ({ code: it, display: it }), options), + labelProp: 'display', + valueProp: 'code' + } + }), + R.range(1, machine.numberOfCassettes + 1) ) const schema = () => From 96bad3131766d3a9abeec7c8d97415f9038b6d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Tue, 8 Mar 2022 17:41:34 +0000 Subject: [PATCH 04/10] fix: do not store failed twilio api responses on db --- lib/customers.js | 6 +++--- lib/plugins/sms/twilio/twilio.js | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/customers.js b/lib/customers.js index ebbc76b5..d96b81de 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -130,8 +130,8 @@ async function updateCustomer (id, data, userToken) { .then(res => updateSubscriberData(id, res, userToken)) .catch(logger.error) } - invalidateCustomerNotifications(id, formattedData) - return getCustomerById(id) + invalidateCustomerNotifications(id, formattedData) + return getCustomerById(id) } /** @@ -587,7 +587,7 @@ function formatSubscriberInfo(customer) { const subscriberInfo = customer.subscriberInfo if(!subscriberInfo) return customer const result = subscriberInfo.result - if(subscriberInfo.status !== 'successful' || _.isEmpty(result)) return customer + if(_.isEmpty(result)) return _.omit(['subscriberInfo'], customer) const name = _.get('belongs_to.name')(result) const street = _.get('current_addresses[0].street_line_1')(result) diff --git a/lib/plugins/sms/twilio/twilio.js b/lib/plugins/sms/twilio/twilio.js index eb9fb0c4..bdfc3843 100644 --- a/lib/plugins/sms/twilio/twilio.js +++ b/lib/plugins/sms/twilio/twilio.js @@ -45,6 +45,12 @@ function getLookup (account, number) { .fetch({ addOns: ['lamassu_ekata'] }) }) .then(info => info.addOns.results['lamassu_ekata']) + .then(info => { + if (info.status !== 'successful') { + throw new Error(`Twilio error: ${info.message}`) + } + return info + }) .catch(err => { if (_.includes(err.code, BAD_NUMBER_CODES)) { const badNumberError = new Error(err.message) From 21d8c52ab1e406fa07675402ad3097e7ccff5d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Tue, 8 Mar 2022 17:42:22 +0000 Subject: [PATCH 05/10] refactor: fix identation issue --- lib/customers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/customers.js b/lib/customers.js index d96b81de..0f68f1ed 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -130,8 +130,8 @@ async function updateCustomer (id, data, userToken) { .then(res => updateSubscriberData(id, res, userToken)) .catch(logger.error) } - invalidateCustomerNotifications(id, formattedData) - return getCustomerById(id) + invalidateCustomerNotifications(id, formattedData) + return getCustomerById(id) } /** From b30c3b4d8cc44117b7af0296109d12816e51b86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Tue, 8 Mar 2022 18:10:41 +0000 Subject: [PATCH 06/10] feat: omit 0conf columns at the end of the initial setup wizard --- .../pages/Wizard/components/Wallet/AllSet.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/new-lamassu-admin/src/pages/Wizard/components/Wallet/AllSet.js b/new-lamassu-admin/src/pages/Wizard/components/Wallet/AllSet.js index f2653ffd..ae891826 100644 --- a/new-lamassu-admin/src/pages/Wizard/components/Wallet/AllSet.js +++ b/new-lamassu-admin/src/pages/Wizard/components/Wallet/AllSet.js @@ -70,6 +70,20 @@ const AllSet = ({ data: currentData, doContinue }) => { return saveConfig({ variables: { config } }) } + const presentableData = R.pipe( + R.omit(['coin', 'zeroConf', 'zeroConfLimit']), + toNamespace(coin) + )(currentData) + + const presentableElements = R.filter( + R.pipe( + R.prop('name'), + R.flip(R.includes)(['zeroConf', 'zeroConfLimit']), + R.not() + ), + getElements(cryptoCurrencies, accountsConfig, null, true) + ) + return ( <>

All set

@@ -82,8 +96,8 @@ const AllSet = ({ data: currentData, doContinue }) => { titleLg name="All set" namespaces={[coin]} - data={toNamespace(coin, R.omit('coin', currentData))} - elements={getElements(cryptoCurrencies, accountsConfig, true)} + data={presentableData} + elements={presentableElements} />