From 42ab9e8fa4d6c24f1d0c4928c96267fa02e738a4 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Wed, 7 May 2025 18:55:21 +0100 Subject: [PATCH] partial: trigger and transactions --- .../CopyToClipboard.jsx | 31 +- .../src/pages/Analytics/Analytics.module.css | 0 .../src/pages/Blacklist/BlacklistTable.jsx | 2 +- .../Customers/components/PhotosCarousel.jsx | 2 +- .../Customers/components/TransactionsList.jsx | 2 +- new-lamassu-admin/src/pages/Funding.jsx | 4 +- .../Machines/MachineComponents/Overview.jsx | 2 +- .../Transactions/Transactions.jsx | 16 +- .../src/pages/Transactions/DetailsCard.jsx | 96 +++-- .../pages/Transactions/DetailsCard.styles.js | 146 -------- .../src/pages/Transactions/Transactions.jsx | 64 ++-- .../pages/Transactions/Transactions.styles.js | 147 -------- .../src/pages/Transactions/helper.js | 11 +- .../CustomInfoRequests/CustomInfoRequests.jsx | 236 ++++++------- .../CustomInfoRequests.styles.js | 19 - .../CustomInfoRequests/DetailsCard.jsx | 47 +-- .../Forms/TypeFields/ChoiceList.jsx | 21 +- .../Forms/TypeFields/NumericalEntry.jsx | 15 +- .../Forms/TypeFields/TextEntry.jsx | 19 +- .../Forms/TypeFields/formStyles.styles.js | 50 --- .../Triggers/CustomInfoRequests/Wizard.jsx | 33 +- .../CustomInfoRequests/WizardSplash.jsx | 38 +- .../src/pages/Triggers/TriggerView.jsx | 7 +- .../src/pages/Triggers/Triggers.jsx | 8 +- .../src/pages/Triggers/Triggers.styles.js | 16 - .../src/pages/Triggers/Wizard.jsx | 96 ++--- .../src/pages/Triggers/helper.jsx | 332 ++++-------------- .../UserManagement/modals/CreateUserModal.jsx | 2 +- .../UserManagement/modals/Reset2FAModal.jsx | 4 +- .../modals/ResetPasswordModal.jsx | 4 +- 30 files changed, 354 insertions(+), 1116 deletions(-) rename new-lamassu-admin/src/{pages/Transactions => components}/CopyToClipboard.jsx (69%) delete mode 100644 new-lamassu-admin/src/pages/Analytics/Analytics.module.css delete mode 100644 new-lamassu-admin/src/pages/Transactions/DetailsCard.styles.js delete mode 100644 new-lamassu-admin/src/pages/Transactions/Transactions.styles.js delete mode 100644 new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/CustomInfoRequests.styles.js delete mode 100644 new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/formStyles.styles.js delete mode 100644 new-lamassu-admin/src/pages/Triggers/Triggers.styles.js diff --git a/new-lamassu-admin/src/pages/Transactions/CopyToClipboard.jsx b/new-lamassu-admin/src/components/CopyToClipboard.jsx similarity index 69% rename from new-lamassu-admin/src/pages/Transactions/CopyToClipboard.jsx rename to new-lamassu-admin/src/components/CopyToClipboard.jsx index 021b6a65..b5edad0d 100644 --- a/new-lamassu-admin/src/pages/Transactions/CopyToClipboard.jsx +++ b/new-lamassu-admin/src/components/CopyToClipboard.jsx @@ -1,25 +1,20 @@ -import { makeStyles } from '@mui/styles' import classnames from 'classnames' import * as R from 'ramda' import React, { useState, useEffect } from 'react' import { CopyToClipboard as ReactCopyToClipboard } from 'react-copy-to-clipboard' -import Popover from 'src/components/Popper' +import Popover from 'src/components/Popper.jsx' import CopyIcon from 'src/styling/icons/action/copy/copy.svg?react' -import { comet } from 'src/styling/variables' +import { comet } from 'src/styling/variables.js' -import { cpcStyles } from './Transactions.styles' - -const useStyles = makeStyles(cpcStyles) +import { Label1, Mono } from './typography/index.jsx' const CopyToClipboard = ({ className, buttonClassname, children, - variant, wrapperClassname, - removeSpace = true, - ...props + removeSpace = true }) => { const [anchorEl, setAnchorEl] = useState(null) @@ -27,8 +22,6 @@ const CopyToClipboard = ({ if (anchorEl) setTimeout(() => setAnchorEl(null), 3000) }, [anchorEl]) - const classes = useStyles() - const handleClick = event => { setAnchorEl(anchorEl ? null : event.currentTarget) } @@ -41,16 +34,17 @@ const CopyToClipboard = ({ const id = open ? 'simple-popper' : undefined return ( -
+
{children && ( <> -
+ {children} -
-
+ +
-
- )} - {showWizard && ( - { - setToBeEdited(null) - setHasError(false) - toggleWizard() - }} - toBeEdited={toBeEdited} - onSave={(...args) => handleSave(...args)} - existingRequirements={customRequests} - /> - )} - { - setDeleteDialog(false) - setHasError(false) - }} - item={`custom information request`} - extraMessage={detailedDeleteMsg} - onConfirmed={() => handleDelete(toBeDeleted)} - /> - )); + return ( + !configLoading && ( + <> + {customRequests.length > 0 && ( + it.customRequest.name + }, + { + header: 'Data entry type', + width: 300, + textAlign: 'left', + size: 'sm', + view: it => inputTypeDisplay[it.customRequest.input.type] + }, + { + header: 'Constraints', + width: 300, + textAlign: 'left', + size: 'sm', + view: it => + constraintTypeDisplay[it.customRequest.input.constraintType] + }, + { + header: 'Edit', + width: 100, + textAlign: 'center', + size: 'sm', + view: it => { + return ( + { + setToBeEdited(it) + return toggleWizard() + }} + size="large"> + + + ) + } + }, + { + header: 'Delete', + width: 100, + textAlign: 'center', + size: 'sm', + view: it => { + return ( + { + setToBeDeleted(it.id) + return setDeleteDialog(true) + }} + size="large"> + + + ) + } + } + ]} + data={customRequests} + Details={DetailsRow} + expandable + rowSize="sm" + /> + )} + {!customRequests.length && ( +
+ + It seems you haven't added any custom information requests yet. + + + Please read our{' '} + + Support Article + {' '} + on Compliance before adding new information requests. + + +
+ )} + {showWizard && ( + { + setToBeEdited(null) + setHasError(false) + toggleWizard() + }} + toBeEdited={toBeEdited} + onSave={(...args) => handleSave(...args)} + existingRequirements={customRequests} + /> + )} + { + setDeleteDialog(false) + setHasError(false) + }} + item={`custom information request`} + extraMessage={detailedDeleteMsg} + onConfirmed={() => handleDelete(toBeDeleted)} + /> + + ) + ) } export default CustomInfoRequests diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/CustomInfoRequests.styles.js b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/CustomInfoRequests.styles.js deleted file mode 100644 index 07a1bf87..00000000 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/CustomInfoRequests.styles.js +++ /dev/null @@ -1,19 +0,0 @@ -export default { - m0: { - margin: 0 - }, - mb10: { - marginBottom: 10 - }, - centerItems: { - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - height: '50%', - justifyContent: 'center' - }, - alignWithTitleSection: { - marginTop: -47, - display: 'flex' - } -} diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/DetailsCard.jsx b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/DetailsCard.jsx index 2de4ac04..fd3d0d2e 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/DetailsCard.jsx +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/DetailsCard.jsx @@ -1,32 +1,8 @@ -import { makeStyles } from '@mui/styles' -import classnames from 'classnames' import React from 'react' import { Label1, Info2 } from 'src/components/typography' -const styles = { - flex: { - display: 'flex' - }, - column: { - flexDirection: 'column' - }, - halfWidth: { - width: '50%', - marginBottom: 15, - marginRight: 50 - }, - marginTop: { - marginTop: 20 - }, - marginBottom: { - marginBottom: 20 - } -} -const useStyles = makeStyles(styles) const DetailsCard = ({ it }) => { const customRequest = it.customRequest - const classes = useStyles() - const getScreen2Data = () => { const label1Display = customRequest.input.constraintType === 'spaceSeparation' @@ -36,12 +12,12 @@ const DetailsCard = ({ it }) => { case 'text': return ( <> -
+
{label1Display} {customRequest.input.label1}
{customRequest.input.constraintType === 'spaceSeparation' && ( -
+
Second word label {customRequest.input.label2}
@@ -51,11 +27,11 @@ const DetailsCard = ({ it }) => { default: return ( <> -
+
Screen 2 input title {customRequest.screen2.title}
-
+
Screen 2 input description {customRequest.screen2.text}
@@ -87,22 +63,19 @@ const DetailsCard = ({ it }) => { return (
-
-
+
+
Screen 1 title {customRequest.screen1.title}
-
- {getScreen2Data()} -
+
{getScreen2Data()}
-
-
+
+
Screen 1 text {customRequest.screen1.text}
-
{getInputData()}
+
{getInputData()}
) diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/ChoiceList.jsx b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/ChoiceList.jsx index a171c1dd..e514d747 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/ChoiceList.jsx +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/ChoiceList.jsx @@ -1,4 +1,3 @@ -import { makeStyles } from '@mui/styles' import classnames from 'classnames' import { Field, useFormikContext, FieldArray } from 'formik' import * as R from 'ramda' @@ -10,9 +9,6 @@ import { H4 } from 'src/components/typography' import AddIconInverse from 'src/styling/icons/button/add/white.svg?react' import AddIcon from 'src/styling/icons/button/add/zodiac.svg?react' -import styles from './formStyles.styles' -const useStyles = makeStyles(styles) - const nonEmptyStr = obj => obj.text && obj.text.length const options = [ @@ -21,15 +17,14 @@ const options = [ ] const ChoiceList = () => { - const classes = useStyles() const context = useFormikContext() const choiceListRef = useRef(null) const listChoices = R.path(['values', 'listChoices'])(context) ?? [] const choiceListError = R.path(['errors', 'listChoices'])(context) ?? false const showErrorColor = { - [classes.radioSubtitle]: true, - [classes.error]: + 'mb-0': true, + 'text-tomato': !R.path(['values', 'constraintType'])(context) && R.path(['errors', 'constraintType'])(context) } @@ -56,20 +51,20 @@ const ChoiceList = () => { {({ push }) => { return ( -
-

Choices

-
+
+

Choices

+
{listChoices.map((choice, idx) => { return (
{ Icon={AddIcon} color="primary" InverseIcon={AddIconInverse} - className={classes.button} + className="w-30 h-7 mt-7" onClick={e => { e.preventDefault() return push({ text: '' }) diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/NumericalEntry.jsx b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/NumericalEntry.jsx index 5c6c364d..938d587d 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/NumericalEntry.jsx +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/NumericalEntry.jsx @@ -1,4 +1,3 @@ -import { makeStyles } from '@mui/styles' import classnames from 'classnames' import { Field, useFormikContext } from 'formik' import * as R from 'ramda' @@ -7,9 +6,6 @@ import NumberInput from 'src/components/inputs/formik/NumberInput' import RadioGroup from 'src/components/inputs/formik/RadioGroup' import { TL1, H4 } from 'src/components/typography' -import styles from './formStyles.styles' -const useStyles = makeStyles(styles) - const options = [ { display: 'None', code: 'none' }, { display: 'Date', code: 'date' }, @@ -17,7 +13,6 @@ const options = [ ] const NumericalEntry = () => { - const classes = useStyles() const context = useFormikContext() const isLength = @@ -25,8 +20,8 @@ const NumericalEntry = () => { 'length' const showErrorColor = { - [classes.radioSubtitle]: true, - [classes.error]: + 'mb-0': true, + 'text-tomat': !R.path(['values', 'constraintType'])(context) && R.path(['errors', 'constraintType'])(context) } @@ -37,13 +32,13 @@ const NumericalEntry = () => { Numerical entry constraints {isLength && ( -
+
{ decimalPlaces={0} allowNegative={false} /> - digits + digits
)} diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/TextEntry.jsx b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/TextEntry.jsx index 79f2674e..6b9ed614 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/TextEntry.jsx +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/Forms/TypeFields/TextEntry.jsx @@ -1,4 +1,3 @@ -import { makeStyles } from '@mui/styles' import classnames from 'classnames' import { Field, useFormikContext } from 'formik' import * as R from 'ramda' @@ -7,9 +6,6 @@ import RadioGroup from 'src/components/inputs/formik/RadioGroup' import TextInput from 'src/components/inputs/formik/TextInput' import { H4 } from 'src/components/typography' -import styles from './formStyles.styles' -const useStyles = makeStyles(styles) - const options = [ { display: 'None', code: 'none' }, { display: 'Email', code: 'email' }, @@ -21,11 +17,10 @@ const options = [ ] const TextEntry = () => { - const classes = useStyles() const context = useFormikContext() const showErrorColor = { - [classes.radioSubtitle]: true, - [classes.error]: + 'mt-0': true, + 'text-tomato': !R.path(['values', 'constraintType'])(context) && R.path(['errors', 'constraintType'])(context) } @@ -34,15 +29,15 @@ const TextEntry = () => { switch (context.values.constraintType) { case 'spaceSeparation': return ( -
+
{ default: return ( { <>

Text entry constraints

[ { @@ -153,7 +131,6 @@ const Wizard = ({ hasError, existingRequirements }) => { - const classes = useStyles() const isEditing = !R.isNil(toBeEdited) const [step, setStep] = useState(isEditing ? 1 : 0) @@ -206,7 +183,7 @@ const Wizard = ({ open={true}> {step > 0 && ( @@ -221,15 +198,17 @@ const Wizard = ({ initialValues={initialValues} validationSchema={stepOptions.validationSchema}> {({ errors }) => ( -
+ -
+
{(hasError || !R.isEmpty(errors)) && ( {R.head(R.values(errors)) ?? `Failed to save`} )} -
diff --git a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/WizardSplash.jsx b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/WizardSplash.jsx index b3d9ffa0..421a0402 100644 --- a/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/WizardSplash.jsx +++ b/new-lamassu-admin/src/pages/Triggers/CustomInfoRequests/WizardSplash.jsx @@ -1,43 +1,15 @@ -import { makeStyles } from '@mui/styles' import React from 'react' import { H1, P } from 'src/components/typography' import CustomReqLogo from 'src/styling/icons/compliance/custom-requirement.svg?react' import { Button } from 'src/components/buttons' -const styles = { - logo: { - maxHeight: 150, - maxWidth: 200 - }, - title: { - margin: [[24, 0, 32, 0]] - }, - text: { - margin: 0 - }, - button: { - marginTop: 'auto', - marginBottom: 58 - }, - modalContent: { - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - padding: [[0, 42]], - flex: 1 - } -} - -const useStyles = makeStyles(styles) - const WizardSplash = ({ onContinue }) => { - const classes = useStyles() return ( -
- -

Custom information request

-

+

+ +

Custom information request

+

A custom information request allows you to have an extra option to ask specific information about your customers when adding a trigger that isn't an option on the default requirements list. @@ -47,7 +19,7 @@ const WizardSplash = ({ onContinue }) => { triggers. You will still need to add a trigger with the new requirement to get this information from your customers.

-
diff --git a/new-lamassu-admin/src/pages/Triggers/TriggerView.jsx b/new-lamassu-admin/src/pages/Triggers/TriggerView.jsx index e8e208c5..6bd1f76f 100644 --- a/new-lamassu-admin/src/pages/Triggers/TriggerView.jsx +++ b/new-lamassu-admin/src/pages/Triggers/TriggerView.jsx @@ -1,5 +1,4 @@ import { useMutation, gql } from '@apollo/client' -import { makeStyles } from '@mui/styles' import * as R from 'ramda' import React, { useState } from 'react' import { H2 } from 'src/components/typography' @@ -9,12 +8,9 @@ import { Button } from 'src/components/buttons' import { Table as EditableTable } from 'src/components/editableTable' import { fromNamespace, namespaces } from 'src/utils/config' -import styles from './Triggers.styles' import Wizard from './Wizard' import { Schema, getElements, sortBy, toServer } from './helper' -const useStyles = makeStyles(styles) - const SAVE_CONFIG = gql` mutation Save($config: JSONObject) { saveConfig(config: $config) @@ -34,7 +30,6 @@ const TriggerView = ({ const currency = R.path(['fiatCurrency'])( fromNamespace(namespaces.LOCALE)(config) ) - const classes = useStyles() const [error, setError] = useState(null) const [saveConfig] = useMutation(SAVE_CONFIG, { @@ -69,7 +64,7 @@ const TriggerView = ({ error={error?.message} save={save} validationSchema={Schema} - elements={getElements(currency, classes, customInfoRequests)} + elements={getElements(currency, customInfoRequests)} /> {showWizard && ( { - const classes = useStyles() const [wizardType, setWizard] = useState(false) const { data, loading: configLoading, refetch } = useQuery(GET_CONFIG) const { data: customInfoReqData, loading: customInfoLoading } = @@ -109,7 +105,7 @@ const Triggers = () => { } const titleSectionWidth = { - [classes.tableWidth]: !subMenu === 'customInfoRequests' + 'w-230': !subMenu === 'customInfoRequests' } const setBlur = shouldBlur => { @@ -178,7 +174,7 @@ const Triggers = () => { }} value={rejectAddressReuse} /> - + {rejectAddressReuse ? 'On' : 'Off'} diff --git a/new-lamassu-admin/src/pages/Triggers/Triggers.styles.js b/new-lamassu-admin/src/pages/Triggers/Triggers.styles.js deleted file mode 100644 index ad2be31d..00000000 --- a/new-lamassu-admin/src/pages/Triggers/Triggers.styles.js +++ /dev/null @@ -1,16 +0,0 @@ -export default { - switchLabel: { - margin: 6, - width: 24 - }, - tableRadioGroup: { - flexDirection: 'row', - justifyContent: 'space-between' - }, - tableRadioLabel: { - marginRight: 0 - }, - tableWidth: { - width: 918 - } -} diff --git a/new-lamassu-admin/src/pages/Triggers/Wizard.jsx b/new-lamassu-admin/src/pages/Triggers/Wizard.jsx index abf8d94a..11f5f6c7 100644 --- a/new-lamassu-admin/src/pages/Triggers/Wizard.jsx +++ b/new-lamassu-admin/src/pages/Triggers/Wizard.jsx @@ -1,4 +1,3 @@ -import { makeStyles } from '@mui/styles' import { Form, Formik, useFormikContext } from 'formik' import * as R from 'ramda' import React, { useState, Fragment, useEffect } from 'react' @@ -8,46 +7,12 @@ import Stepper from 'src/components/Stepper' import { H5, Info3 } from 'src/components/typography' import { Button } from 'src/components/buttons' -import { comet } from 'src/styling/variables' import { singularOrPlural } from 'src/utils/string' import { type, requirements } from './helper' const LAST_STEP = 2 -const styles = { - stepper: { - margin: [[16, 0, 14, 0]] - }, - submit: { - display: 'flex', - flexDirection: 'row', - margin: [['auto', 0, 24]] - }, - button: { - marginLeft: 'auto' - }, - form: { - height: '100%', - display: 'flex', - flexDirection: 'column' - }, - infoTitle: { - margin: [[18, 0, 20, 0]] - }, - infoCurrentText: { - color: comet - }, - blankSpace: { - padding: [[0, 30]], - margin: [[0, 4, 0, 2]], - borderBottom: `1px solid ${comet}`, - display: 'inline-block' - } -} - -const useStyles = makeStyles(styles) - const getStep = ( { step, config }, currency, @@ -74,21 +39,23 @@ const getStep = ( } } -const getText = (step, config, currency, classes) => { +const getText = (step, config, currency) => { switch (step) { // case 1: // return `In ${getDirectionText(config)} transactions` case 1: - return <>If the user {getTypeText(config, currency, classes)} + return <>If the user {getTypeText(config, currency)} case 2: - return <>the user will be {getRequirementText(config, classes)}. + return <>the user will be {getRequirementText(config)}. default: return <> } } -const orUnderline = (value, classes) => { - const blankSpaceEl = +const orUnderline = value => { + const blankSpaceEl = ( + + ) return R.isEmpty(value) || R.isNil(value) ? blankSpaceEl : value } @@ -105,34 +72,34 @@ const orUnderline = (value, classes) => { // } // } -const getTypeText = (config, currency, classes) => { +const getTypeText = (config, currency) => { switch (config.triggerType) { case 'txAmount': return ( <> makes a single transaction over{' '} - {orUnderline(config.threshold.threshold, classes)} {currency} + {orUnderline(config.threshold.threshold)} {currency} ) case 'txVolume': return ( <> - makes more than {orUnderline(config.threshold.threshold, classes)}{' '} - {currency} worth of transactions within{' '} - {orUnderline(config.threshold.thresholdDays, classes)}{' '} + makes more than {orUnderline(config.threshold.threshold)} {currency}{' '} + worth of transactions within{' '} + {orUnderline(config.threshold.thresholdDays)}{' '} {singularOrPlural(config.threshold.thresholdDays, 'day', 'days')} ) case 'txVelocity': return ( <> - makes more than {orUnderline(config.threshold.threshold, classes)}{' '} + makes more than {orUnderline(config.threshold.threshold)}{' '} {singularOrPlural( config.threshold.threshold, 'transaction', 'transactions' )}{' '} - in {orUnderline(config.threshold.thresholdDays, classes)}{' '} + in {orUnderline(config.threshold.thresholdDays)}{' '} {singularOrPlural(config.threshold.thresholdDays, 'day', 'days')} ) @@ -140,7 +107,7 @@ const getTypeText = (config, currency, classes) => { return ( <> at least one transaction every day for{' '} - {orUnderline(config.threshold.thresholdDays, classes)}{' '} + {orUnderline(config.threshold.thresholdDays)}{' '} {singularOrPlural(config.threshold.thresholdDays, 'day', 'days')} ) @@ -149,7 +116,7 @@ const getTypeText = (config, currency, classes) => { } } -const getRequirementText = (config, classes) => { +const getRequirementText = config => { switch (config.requirement?.requirement) { case 'email': return <>asked to enter code provided through email verification @@ -170,8 +137,7 @@ const getRequirementText = (config, classes) => { case 'suspend': return ( <> - suspended for{' '} - {orUnderline(config.requirement.suspensionDays, classes)}{' '} + suspended for {orUnderline(config.requirement.suspensionDays)}{' '} {singularOrPlural(config.requirement.suspensionDays, 'day', 'days')} ) @@ -182,28 +148,24 @@ const getRequirementText = (config, classes) => { case 'external': return <>redirected to an external verification process default: - return orUnderline(null, classes) + return orUnderline(null) } } const InfoPanel = ({ step, config = {}, liveValues = {}, currency }) => { - const classes = useStyles() - const oldText = R.range(1, step).map((it, idx) => ( - - {getText(it, config, currency, classes)} - + {getText(it, config, currency)} )) - const newText = getText(step, liveValues, currency, classes) + const newText = getText(step, liveValues, currency) const isLastStep = step === LAST_STEP return ( <> -
Trigger overview so far
+
Trigger overview so far
{oldText} {step !== 1 && ', '} - {newText} + {newText} {!isLastStep && '...'} @@ -229,8 +191,6 @@ const Wizard = ({ emailAuth, triggers }) => { - const classes = useStyles() - const [liveValues, setLiveValues] = useState({}) const [{ step, config }, setState] = useState({ step: 1 @@ -321,11 +281,7 @@ const Wizard = ({ } infoPanelHeight={172} open={true}> - + {({ errors, touched, values }) => ( - + -
+
{error && Failed to save} {createErrorMessage(errors, touched, values) && ( {createErrorMessage(errors, touched, values)} )} -
diff --git a/new-lamassu-admin/src/pages/Triggers/helper.jsx b/new-lamassu-admin/src/pages/Triggers/helper.jsx index cd8a18c8..b6d82200 100644 --- a/new-lamassu-admin/src/pages/Triggers/helper.jsx +++ b/new-lamassu-admin/src/pages/Triggers/helper.jsx @@ -1,4 +1,3 @@ -import { makeStyles } from '@mui/styles' import classnames from 'classnames' import { Field, useFormikContext } from 'formik' import * as R from 'ramda' @@ -7,95 +6,9 @@ import { H4, Label2, Label1, Info1, Info2 } from 'src/components/typography' import * as Yup from 'yup' import { NumberInput, RadioGroup, Dropdown } from 'src/components/inputs/formik' -import { errorColor } from 'src/styling/variables' import { transformNumber } from 'src/utils/number' import { onlyFirstToUpper } from 'src/utils/string' -// import TxInIcon from 'src/styling/icons/direction/cash-in.svg?react' -// import TxOutIcon from 'src/styling/icons/direction/cash-out.svg?react' - -const useStyles = makeStyles({ - radioLabel: { - height: 40, - padding: [[0, 10]] - }, - radio: { - padding: 4, - margin: 4 - }, - radioGroup: { - flexDirection: 'row' - }, - error: { - color: errorColor - }, - specialLabel: { - height: 40, - padding: 0 - }, - specialGrid: { - display: 'grid', - gridTemplateColumns: [[182, 162, 181]] - }, - directionIcon: { - marginRight: 2 - }, - directionName: { - marginLeft: 6 - }, - thresholdWrapper: { - display: 'flex', - flexDirection: 'column' - }, - thresholdTitle: { - marginTop: 50 - }, - thresholdContentWrapper: { - display: 'flex', - flexDirection: 'row' - }, - thresholdField: { - marginRight: 6, - width: 75 - }, - description: { - marginTop: 7 - }, - space: { - marginLeft: 6, - marginRight: 6 - }, - lastSpace: { - marginLeft: 6 - }, - suspensionDays: { - width: 34 - }, - input: { - marginTop: -2 - }, - limitedInput: { - width: 50 - }, - daysInput: { - width: 60 - }, - dropdownField: { - marginTop: 16, - minWidth: 155 - }, - externalFields: { - '& > *': { - marginRight: 15 - }, - '& > *:last-child': { - marginRight: 0 - } - } -}) - -// const direction = Yup.string().required() - const triggerType = Yup.string().required() const threshold = Yup.object().shape({ threshold: Yup.number() @@ -171,92 +84,6 @@ const Schema = Yup.object() }) }) -// 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 directionOptions2 = [ -// { -// display: ( -// <> -// in -// -// ), -// code: 'cashIn' -// }, -// { -// display: ( -// <> -// out -// -// ), -// code: 'cashOut' -// }, -// { -// display: ( -// <> -// -// -// -// -// -// -// -// -// -// ), -// code: 'both' -// } -// ] - -// const Direction = () => { -// const classes = useStyles() -// const { errors } = useFormikContext() - -// const titleClass = { -// [classes.error]: errors.direction -// } - -// return ( -// <> -// -//

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

-//
-// -// -// ) -// } - -// const txDirection = { -// schema: directionSchema, -// options: directionOptions, -// Component: Direction, -// initialValues: { direction: '' } -// } - // TYPE const typeSchema = Yup.object() .shape({ @@ -314,18 +141,20 @@ const typeSchema = Yup.object() const typeOptions = [ { display: 'Transaction amount', code: 'txAmount' }, - { display: 'Transaction volume', code: 'txVolume' }, + { + display: 'Transaction volume', + code: 'txVolume' + }, { display: 'Transaction velocity', code: 'txVelocity' }, { display: 'Consecutive days', code: 'consecutiveDays' } ] const Type = ({ ...props }) => { - const classes = useStyles() const { errors, touched, values, setTouched, handleChange } = useFormikContext() const typeClass = { - [classes.error]: errors.triggerType && touched.triggerType + 'text-tomato': errors.triggerType && touched.triggerType } const containsType = R.contains(values?.triggerType) @@ -348,7 +177,7 @@ const Type = ({ ...props }) => { const triggerTypeError = !!(hasDaysError || hasAmountError) const thresholdClass = { - [classes.error]: triggerTypeError + 'text-tomato': triggerTypeError } const isRadioGroupActive = () => { @@ -369,9 +198,9 @@ const Type = ({ ...props }) => { component={RadioGroup} name="triggerType" options={typeOptions} - labelClassName={classes.radioLabel} - radioClassName={classes.radio} - className={classes.radioGroup} + labelClassName="h-10 py-0 px-3" + radioClassName="p-1 m-1" + className="flex-row" onChange={e => { handleChange(e) setTouched({ @@ -381,73 +210,58 @@ const Type = ({ ...props }) => { }} /> -
+
{isRadioGroupActive() && ( -

- Threshold -

+

Threshold

)} -
+
{isThresholdCurrencyEnabled && ( <> - - {props.currency} - + {props.currency} )} {isTransactionAmountEnabled && ( <> - - transactions - + transactions )} {isThresholdDaysEnabled && ( <> - - in - + in - days + days )} {isConsecutiveDaysEnabled && ( <> - - consecutive days - + consecutive days )}
@@ -527,16 +341,27 @@ const requirementSchema = Yup.object() const requirementOptions = [ { display: 'SMS verification', code: 'sms' }, - { display: 'Email verification', code: 'email' }, + { + display: 'Email verification', + code: 'email' + }, { display: 'ID card image', code: 'idCardPhoto' }, - { display: 'ID data', code: 'idCardData' }, + { + display: 'ID data', + code: 'idCardData' + }, { display: 'Customer camera', code: 'facephoto' }, { display: 'Sanctions', code: 'sanctions' }, - { display: 'US SSN', code: 'usSsn' }, - // { display: 'Super user', code: 'superuser' }, + { + display: 'US SSN', + code: 'usSsn' + }, // { display: 'Super user', code: 'superuser' }, { display: 'Suspend', code: 'suspend' }, { display: 'Block', code: 'block' }, - { display: 'External verification', code: 'external' } + { + display: 'External verification', + code: 'external' + } ] const hasRequirementError = (errors, touched, values) => @@ -563,7 +388,6 @@ const Requirement = ({ complianceServices, customInfoRequests = [] }) => { - const classes = useStyles() const { touched, errors, values, handleChange, setTouched } = useFormikContext() @@ -587,7 +411,10 @@ const Requirement = ({ const availableCustomRequirements = R.filter( it => !R.includes( - { triggerType: config.triggerType, id: it.id }, + { + triggerType: config.triggerType, + id: it.id + }, customRequirementsInUse ), customInfoRequests @@ -613,7 +440,7 @@ const Requirement = ({ enableCustomRequirement && options.push(customInfoOption) const titleClass = { - [classes.error]: + 'text-tomato': (!!errors.requirement && !isSuspend && !isCustom && !isExternal) || (isSuspend && hasRequirementError(errors, touched, values)) || (isCustom && hasCustomRequirementError(errors, touched, values)) || @@ -629,9 +456,9 @@ const Requirement = ({ component={RadioGroup} name="requirement.requirement" options={options} - labelClassName={classes.specialLabel} - radioClassName={classes.radio} - className={classnames(classes.radioGroup, classes.specialGrid)} + labelClassName="h-10 p-0" + radioClassName="p-1 m-1" + className="flex-row grid grid-cols-[182px_162px_181px]" onChange={e => { handleChange(e) setTouched({ @@ -641,7 +468,7 @@ const Requirement = ({ /> {isSuspend && ( )} {isExternal && ( -
+
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' - -// return ( -//
-// {showCashOut && } -// {showCashIn && } -// {displayName} -//
-// ) -// } - const customReqIdMatches = customReqId => it => { return it.id === customReqId } const RequirementInput = ({ customInfoRequests = [] }) => { const { values } = useFormikContext() - const classes = useStyles() - const requirement = values?.requirement?.requirement const customRequestId = R.path(['requirement', 'customInfoRequestId'])(values) ?? '' @@ -753,7 +563,7 @@ const RequirementInput = ({ customInfoRequests = [] }) => { {isSuspend && ( { - const classes = useStyles() const display = requirement === 'custom' ? (R.path(['customRequest', 'name'])( @@ -785,7 +594,7 @@ const RequirementView = ({
{`${display} ${isSuspend ? 'for' : ''}`} {isSuspend && ( - + {suspensionDays} )} @@ -795,12 +604,10 @@ const RequirementView = ({ } const DisplayThreshold = ({ config, currency, isEdit }) => { - const classes = useStyles() - const inputClasses = { - [classes.input]: true, - [classes.limitedInput]: config?.triggerType === 'txVelocity', - [classes.daysInput]: config?.triggerType === 'consecutiveDays' + '-mt-1': true, + 'w-13': config?.triggerType === 'txVelocity', + 'w-15': config?.triggerType === 'consecutiveDays' } const threshold = config?.threshold?.threshold @@ -834,7 +641,7 @@ const DisplayThreshold = ({ config, currency, isEdit }) => { return (
{Threshold} - + {currency}
@@ -843,14 +650,14 @@ const DisplayThreshold = ({ config, currency, isEdit }) => { return (
{Threshold} - + {currency} - + in {ThresholdDays} - + days
@@ -859,11 +666,11 @@ const DisplayThreshold = ({ config, currency, isEdit }) => { return (
{Threshold} - + transactions in {ThresholdDays} - + days
@@ -872,7 +679,7 @@ const DisplayThreshold = ({ config, currency, isEdit }) => { return (
{ThresholdDays} - + days
@@ -892,7 +699,7 @@ const ThresholdView = ({ config, currency }) => { return } -const getElements = (currency, classes, customInfoRequests) => [ +const getElements = (currency, customInfoRequests) => [ { name: 'triggerType', size: 'sm', @@ -926,18 +733,6 @@ const getElements = (currency, classes, customInfoRequests) => [ input: () => , view: (it, config) => } - // { - // 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) @@ -987,8 +782,7 @@ const toServer = triggers => export { Schema, - getElements, - // txDirection, + getElements, // txDirection, type, requirements, sortBy, diff --git a/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.jsx b/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.jsx index e6048622..8b4213d1 100644 --- a/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.jsx +++ b/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.jsx @@ -6,7 +6,7 @@ import React, { useState } from 'react' import ErrorMessage from 'src/components/ErrorMessage' import Modal from 'src/components/Modal' import { H1, H3, Info2, P, Mono } from 'src/components/typography' -import CopyToClipboard from 'src/pages/Transactions/CopyToClipboard' +import CopyToClipboard from 'src/components/CopyToClipboard.jsx' import * as Yup from 'yup' import { Button } from 'src/components/buttons' diff --git a/new-lamassu-admin/src/pages/UserManagement/modals/Reset2FAModal.jsx b/new-lamassu-admin/src/pages/UserManagement/modals/Reset2FAModal.jsx index ae1cfc49..b91f8f54 100644 --- a/new-lamassu-admin/src/pages/UserManagement/modals/Reset2FAModal.jsx +++ b/new-lamassu-admin/src/pages/UserManagement/modals/Reset2FAModal.jsx @@ -1,10 +1,10 @@ -import { useMutation, gql } from "@apollo/client"; +import { useMutation, gql } from '@apollo/client' import { makeStyles } from '@mui/styles' import React, { useEffect, useState } from 'react' import ErrorMessage from 'src/components/ErrorMessage' import Modal from 'src/components/Modal' import { Info2, P, Mono } from 'src/components/typography' -import CopyToClipboard from 'src/pages/Transactions/CopyToClipboard' +import CopyToClipboard from 'src/components/CopyToClipboard.jsx' import { urlResolver } from 'src/utils/urlResolver' diff --git a/new-lamassu-admin/src/pages/UserManagement/modals/ResetPasswordModal.jsx b/new-lamassu-admin/src/pages/UserManagement/modals/ResetPasswordModal.jsx index ca53e015..d6b36f7e 100644 --- a/new-lamassu-admin/src/pages/UserManagement/modals/ResetPasswordModal.jsx +++ b/new-lamassu-admin/src/pages/UserManagement/modals/ResetPasswordModal.jsx @@ -1,10 +1,10 @@ -import { useMutation, gql } from "@apollo/client"; +import { useMutation, gql } from '@apollo/client' import { makeStyles } from '@mui/styles' import React, { useEffect, useState } from 'react' import ErrorMessage from 'src/components/ErrorMessage' import Modal from 'src/components/Modal' import { Info2, P, Mono } from 'src/components/typography' -import CopyToClipboard from 'src/pages/Transactions/CopyToClipboard' +import CopyToClipboard from 'src/components/CopyToClipboard.jsx' import { urlResolver } from 'src/utils/urlResolver'