From 5406a3cfdd884cecbecffdaacae7f97d20c8546e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 3 Jan 2022 22:42:47 +0000 Subject: [PATCH] feat: twilio api data confirmation dialog --- .../src/components/buttons/Button.js | 11 ++- .../src/components/buttons/Button.styles.js | 23 ++++-- .../src/pages/Customers/CustomerData.js | 80 +++++++++++++++++-- .../pages/Customers/CustomerData.styles.js | 23 +++++- .../src/pages/Customers/CustomerProfile.js | 48 ++++++----- .../Customers/components/EditableCard.js | 26 ++++-- .../src/pages/Customers/helper.js | 8 +- 7 files changed, 172 insertions(+), 47 deletions(-) diff --git a/new-lamassu-admin/src/components/buttons/Button.js b/new-lamassu-admin/src/components/buttons/Button.js index 6bd24a71..5945170a 100644 --- a/new-lamassu-admin/src/components/buttons/Button.js +++ b/new-lamassu-admin/src/components/buttons/Button.js @@ -7,8 +7,15 @@ import styles from './Button.styles' const useStyles = makeStyles(styles) const ActionButton = memo( - ({ size = 'lg', children, className, buttonClassName, ...props }) => { - const classes = useStyles({ size }) + ({ + size = 'lg', + children, + className, + buttonClassName, + backgroundColor, + ...props + }) => { + const classes = useStyles({ size, backgroundColor }) return (
)} + ) } +const RetrieveDataDialog = ({ + setRetrieve, + retrieveAditionalData, + open, + props +}) => { + const classes = useStyles() + + return ( + +
+ setRetrieve(false)}> + + +
+

{'Retrieve API data from Twilio'}

+ + {`With this action you'll be using Twilio's API to retrieve additional + data from this user. This includes name and address, if available.\n`} + {` There is a small cost from Twilio for each retrieval. Would you like + to proceed?`} + + + + + +
+ ) +} + export default CustomerData diff --git a/new-lamassu-admin/src/pages/Customers/CustomerData.styles.js b/new-lamassu-admin/src/pages/Customers/CustomerData.styles.js index 373e2f0c..9a4e2871 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomerData.styles.js +++ b/new-lamassu-admin/src/pages/Customers/CustomerData.styles.js @@ -1,4 +1,4 @@ -import { offColor } from 'src/styling/variables' +import { offColor, spacer } from 'src/styling/variables' export default { header: { @@ -45,5 +45,26 @@ export default { left: '100%', marginLeft: 15 } + }, + closeButton: { + display: 'flex', + padding: [[spacer * 2, spacer * 2, 0, spacer * 2]], + paddingRight: spacer * 1.5, + justifyContent: 'end' + }, + dialogTitle: { + margin: [[0, spacer * 2, spacer, spacer * 4 + spacer]] + }, + dialogContent: { + width: 615, + marginLeft: 16 + }, + dialogActions: { + padding: spacer * 4, + paddingTop: spacer * 2 + }, + cancelButton: { + marginRight: 8, + padding: 0 } } diff --git a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js index 9c38bdfa..3fe7cc56 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js +++ b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js @@ -439,6 +439,16 @@ const CustomerProfile = memo(() => { } }) + const retrieveAditionalData = () => + setCustomer({ + variables: { + customerId, + customerInput: { + subscriberInfo: true + } + } + }) + const onClickSidebarItem = code => setClickedItem(code) const configData = R.path(['config'])(customerResponse) ?? [] @@ -559,25 +569,6 @@ const CustomerProfile = memo(() => { }> {`${blocked ? 'Authorize' : 'Block'} customer`} - - setCustomer({ - variables: { - customerId, - customerInput: { - subscriberInfo: true - } - } - }) - }> - {`Retrieve information`} -
@@ -598,6 +589,22 @@ const CustomerProfile = memo(() => { {`Test user`}
+ + updateCustomer({ + authorizedOverride: blocked + ? OVERRIDE_AUTHORIZED + : OVERRIDE_REJECTED + }) + }> + {`${blocked ? 'Authorize' : 'Block'} customer`} + )} @@ -637,7 +644,8 @@ const CustomerProfile = memo(() => { deleteEditedData={deleteEditedData} updateCustomRequest={setCustomerCustomInfoRequest} authorizeCustomRequest={authorizeCustomRequest} - updateCustomEntry={updateCustomEntry}> + updateCustomEntry={updateCustomEntry} + retrieveAditionalData={retrieveAditionalData}> )} {isNotes && ( diff --git a/new-lamassu-admin/src/pages/Customers/components/EditableCard.js b/new-lamassu-admin/src/pages/Customers/components/EditableCard.js index 9a1e848b..8857fb85 100644 --- a/new-lamassu-admin/src/pages/Customers/components/EditableCard.js +++ b/new-lamassu-admin/src/pages/Customers/components/EditableCard.js @@ -23,6 +23,8 @@ import { ReactComponent as EditReversedIcon } from 'src/styling/icons/action/edi import { ReactComponent as AuthorizeIcon } from 'src/styling/icons/button/authorize/white.svg' import { ReactComponent as BlockIcon } from 'src/styling/icons/button/block/white.svg' import { ReactComponent as CancelReversedIcon } from 'src/styling/icons/button/cancel/white.svg' +import { ReactComponent as DataReversedIcon } from 'src/styling/icons/button/data/white.svg' +import { ReactComponent as DataIcon } from 'src/styling/icons/button/data/zodiac.svg' import { ReactComponent as ReplaceReversedIcon } from 'src/styling/icons/button/replace/white.svg' import { ReactComponent as SaveReversedIcon } from 'src/styling/icons/circle buttons/save/white.svg' import { comet } from 'src/styling/variables' @@ -118,7 +120,8 @@ const EditableCard = ({ validationSchema, initialValues, deleteEditedData, - isDeletable + retrieveAdditionalData, + hasAdditionalData = true }) => { const classes = useStyles() @@ -211,19 +214,28 @@ const EditableCard = ({
{!editing && (
- {// TODO: Remove false condition for next release - false && ( -
+
+ {false && ( deleteEditedData()}> - {`Delete`} + Delete -
- )} + )} + {!hasAdditionalData && ( + retrieveAdditionalData()}> + Retrieve API data + + )} +