From 636cf0fc027dfc581ba7289f76dfc95cc272ac5a Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Thu, 8 May 2025 09:27:07 +0100 Subject: [PATCH] partial: few missing pages migrations --- .../src/components/tables/DataTable.jsx | 9 +- .../components/tooltips/GraphTooltip.jsx | 1 - .../src/pages/Dashboard/Footer/Footer.jsx | 1 - .../Machines/MachineComponents/Overview.jsx | 2 +- .../Transactions/DataTable.jsx | 187 ------------------ .../Transactions/Transactions.jsx | 4 +- .../OperatorInfo/SMSNotices/SMSNotices.jsx | 24 +-- .../SMSNotices/SMSNotices.styles.js | 95 --------- .../SMSNotices/SMSNoticesModal.jsx | 21 +- .../src/pages/Transactions/DetailsCard.jsx | 2 +- 10 files changed, 28 insertions(+), 318 deletions(-) delete mode 100644 new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.jsx delete mode 100644 new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js diff --git a/new-lamassu-admin/src/components/tables/DataTable.jsx b/new-lamassu-admin/src/components/tables/DataTable.jsx index 7027fec0..b1764cbd 100644 --- a/new-lamassu-admin/src/components/tables/DataTable.jsx +++ b/new-lamassu-admin/src/components/tables/DataTable.jsx @@ -105,6 +105,7 @@ const DataTable = ({ initialExpanded, onClick, loading, + maxWidth = 1200, emptyText, rowSize, ...props @@ -114,7 +115,7 @@ const DataTable = ({ useEffect(() => setExpanded(initialExpanded), [initialExpanded]) const coreWidth = R.compose(R.sum, R.map(R.prop('width')))(elements) - const expWidth = 1200 - coreWidth + const expWidth = maxWidth - coreWidth const width = coreWidth + (expandable ? expWidth : 0) const classes = useStyles({ width }) @@ -170,7 +171,11 @@ const DataTable = ({ } return ( -
+
{elements.map(({ width, className, textAlign, header }, idx) => ( diff --git a/new-lamassu-admin/src/pages/Analytics/components/tooltips/GraphTooltip.jsx b/new-lamassu-admin/src/pages/Analytics/components/tooltips/GraphTooltip.jsx index 67afc8c3..9c11e46e 100644 --- a/new-lamassu-admin/src/pages/Analytics/components/tooltips/GraphTooltip.jsx +++ b/new-lamassu-admin/src/pages/Analytics/components/tooltips/GraphTooltip.jsx @@ -1,5 +1,4 @@ import Paper from '@mui/material/Paper' -import { makeStyles } from '@mui/styles' import * as R from 'ramda' import React, { memo } from 'react' import { Info2, Label3, P } from 'src/components/typography' diff --git a/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.jsx b/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.jsx index 0e22d82c..6b751407 100644 --- a/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.jsx +++ b/new-lamassu-admin/src/pages/Dashboard/Footer/Footer.jsx @@ -1,5 +1,4 @@ import { useQuery, gql } from '@apollo/client' -import { makeStyles } from '@mui/styles' import BigNumber from 'bignumber.js' import * as R from 'ramda' import React from 'react' diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.jsx b/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.jsx index afbecce2..da3f939a 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.jsx +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.jsx @@ -47,7 +47,7 @@ const Overview = ({ data, onActionSuccess }) => {
Device ID -

+

{data.deviceId}

diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.jsx b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.jsx deleted file mode 100644 index 488df09e..00000000 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.jsx +++ /dev/null @@ -1,187 +0,0 @@ -import { makeStyles } from '@mui/styles' -import classnames from 'classnames' -import * as R from 'ramda' -import React, { useState, useEffect } from 'react' -import { - AutoSizer, - List, - CellMeasurer, - CellMeasurerCache -} from 'react-virtualized' -import { - Table, - TBody, - THead, - Tr, - Td, - Th -} from 'src/components/fake-table/Table' -import { H4 } from 'src/components/typography' -import ExpandClosedIcon from 'src/styling/icons/action/expand/closed.svg?react' -import ExpandOpenIcon from 'src/styling/icons/action/expand/open.svg?react' - -import styles from 'src/components/tables/DataTable.styles' - -const useStyles = makeStyles(styles) - -const Row = ({ - id, - elements, - data, - width, - Details, - expanded, - expandRow, - expWidth, - expandable, - onClick -}) => { - const classes = useStyles() - - const hasPointer = onClick || expandable - const trClasses = { - [classes.pointer]: hasPointer, - [classes.row]: true, - [classes.expanded]: expanded - } - - return ( -
-
-
{ - expandable && expandRow(id) - onClick && onClick(data) - }} - error={data.error} - errorMessage={data.errorMessage}> - {elements.map(({ view = it => it?.toString(), ...props }, idx) => ( - - ))} - {expandable && ( - - )} - - - {expandable && expanded && ( -
-
- - - - )} - - ) -} - -const DataTable = ({ - elements = [], - data = [], - Details, - className, - expandable, - initialExpanded, - onClick, - loading, - emptyText, - extraHeight, - ...props -}) => { - const [expanded, setExpanded] = useState(initialExpanded) - - useEffect(() => setExpanded(initialExpanded), [initialExpanded]) - - const coreWidth = R.compose(R.sum, R.map(R.prop('width')))(elements) - const expWidth = 850 - coreWidth - const width = coreWidth + (expandable ? expWidth : 0) - - const classes = useStyles({ width }) - - const expandRow = id => { - setExpanded(id === expanded ? null : id) - } - - const cache = new CellMeasurerCache({ - defaultHeight: 62, - fixedWidth: true - }) - - function rowRenderer({ index, key, parent, style }) { - return ( - -
- -
-
- ) - } - - return ( -
-
- {view(data)} - - -
-
-
- - {elements.map(({ width, className, textAlign, header }, idx) => ( - - ))} - {expandable && } - - - {loading &&

Loading...

} - {!loading && R.isEmpty(data) &&

{emptyText}

} - - {() => ( - - )} - - -
- {header} -
-
- ) -} - -export default DataTable diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.jsx b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.jsx index b44e2787..aac44707 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.jsx +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.jsx @@ -11,7 +11,7 @@ import { getStatus } from 'src/pages/Transactions/helper' import * as Customer from 'src/utils/customer' import { formatDate } from 'src/utils/timezones' -import DataTable from './DataTable' +import DataTable from 'src/components/tables/DataTable' const NUM_LOG_RESULTS = 5 @@ -164,6 +164,8 @@ const Transactions = ({ id }) => { { - const classes = useStyles(coords) - const matches = { '#code': 123, '#timestamp': formatDate(new Date(), timezone, 'HH:mm') } return ( -
-
-
+
+
+
- +

{R.isEmpty(sms?.message) ? ( No content available @@ -117,8 +113,6 @@ const SMSPreview = ({ sms, coords, timezone }) => { } const SMSNotices = () => { - const classes = useStyles() - const [showModal, setShowModal] = useState(false) const [selectedSMS, setSelectedSMS] = useState(null) const [previewOpen, setPreviewOpen] = useState(false) @@ -160,7 +154,7 @@ const SMSNotices = () => { textAlign: 'left', view: it => !R.isEmpty(TOOLTIPS[it.event]) ? ( -

+
{R.prop('messageName', it)}

{TOOLTIPS[it.event]}

@@ -237,7 +231,7 @@ const SMSNotices = () => { return ( <> -
+

SMS notices

diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js deleted file mode 100644 index 65e39737..00000000 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNotices.styles.js +++ /dev/null @@ -1,95 +0,0 @@ -import { - spacer, - fontMonospaced, - fontSize5, - fontColor -} from 'src/styling/variables' - -const styles = { - header: { - display: 'flex', - position: 'relative', - alignItems: 'center', - justifyContent: 'space-between', - width: 800 - }, - form: { - '& > *': { - marginTop: 20 - }, - display: 'flex', - flexDirection: 'column', - height: '100%' - }, - footer: { - display: 'flex', - flexDirection: 'row', - margin: [['auto', 0, spacer * 3, 0]] - }, - submit: { - margin: [['auto', 0, 0, 'auto']] - }, - smsPreview: { - position: 'absolute', - left: ({ x }) => x, - bottom: ({ y }) => y, - width: 350, - overflow: 'visible' - }, - smsPreviewContainer: { - display: 'flex', - flexDirection: 'row', - alignItems: 'flex-end', - '& > *': { - marginRight: 10 - } - }, - smsPreviewIcon: { - display: 'flex', - width: 36, - height: 36, - borderRadius: 18, - backgroundColor: '#16D6D3', - alignItems: 'center', - justifyContent: 'center' - }, - smsPreviewContent: { - width: 225, - padding: 15, - borderRadius: '15px 15px 15px 0px' - }, - chipButtons: { - width: 480, - display: 'flex', - flexDirection: 'column', - alignItems: 'space-between', - '& > div': { - marginTop: 15 - }, - '& > div:first-child': { - marginTop: 0 - }, - '& > div > div': { - margin: [[0, 5, 0, 5]] - }, - '& > div > div > span': { - lineHeight: '120%', - color: fontColor, - fontSize: fontSize5, - fontFamily: fontMonospaced, - fontWeight: 500 - }, - marginLeft: 'auto', - marginRight: 'auto' - }, - resetToDefault: { - width: 145 - }, - messageWithTooltip: { - display: 'flex', - flexDirection: 'row', - alignItems: 'center' - } -} - -export default styles diff --git a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.jsx b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.jsx index 745891b7..4939df23 100644 --- a/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.jsx +++ b/new-lamassu-admin/src/pages/OperatorInfo/SMSNotices/SMSNoticesModal.jsx @@ -1,5 +1,4 @@ import Chip from '@mui/material/Chip' -import { makeStyles } from '@mui/styles' import { Form, Formik, Field } from 'formik' import * as R from 'ramda' import React from 'react' @@ -14,10 +13,6 @@ import { ActionButton, Button } from 'src/components/buttons' import { TextInput } from 'src/components/inputs/formik' import { zircon } from 'src/styling/variables' -import styles from './SMSNotices.styles' - -const useStyles = makeStyles(styles) - const getErrorMsg = (formikErrors, formikTouched, mutationError) => { if (!formikErrors || !formikTouched) return null if (mutationError) return 'Internal server error' @@ -77,8 +72,6 @@ const SMSNoticesModal = ({ creationError, submit }) => { - const classes = useStyles() - const initialValues = { event: !R.isNil(sms) ? sms.event : '', message: !R.isNil(sms) ? sms.message : '' @@ -128,12 +121,12 @@ const SMSNoticesModal = ({ handleSubmit(values, errors, touched) }> {({ values, errors, touched, setFieldValue }) => ( -

+ setFieldValue('message', DEFAULT_MESSAGES[sms?.event]) @@ -151,9 +144,9 @@ const SMSNoticesModal = ({ {R.length(CHIPS[sms?.event]) > 0 && ( Values to attach )} -
+
{R.splitEvery(3, CHIPS[sms?.event]).map((it, idx) => ( -
+
{it.map((ite, idx2) => ( { setFieldValue( 'message', @@ -176,7 +169,7 @@ const SMSNoticesModal = ({
))}
-
+
{getErrorMsg(errors, touched, creationError) && ( {getErrorMsg(errors, touched, creationError)} @@ -185,7 +178,7 @@ const SMSNoticesModal = ({
diff --git a/new-lamassu-admin/src/pages/Transactions/DetailsCard.jsx b/new-lamassu-admin/src/pages/Transactions/DetailsCard.jsx index 1f3cd6e4..e07ec7ab 100644 --- a/new-lamassu-admin/src/pages/Transactions/DetailsCard.jsx +++ b/new-lamassu-admin/src/pages/Transactions/DetailsCard.jsx @@ -384,7 +384,7 @@ const DetailsRow = ({ it: tx, timezone }) => { {tx.id}
-
+
{errorElements} {((tx.txClass === 'cashOut' && getStatus(tx) === 'Pending') ||