diff --git a/new-lamassu-admin/src/components/LogsDownloaderPopper.js b/new-lamassu-admin/src/components/LogsDownloaderPopper.js index f41dde88..dc37ef88 100644 --- a/new-lamassu-admin/src/components/LogsDownloaderPopper.js +++ b/new-lamassu-admin/src/components/LogsDownloaderPopper.js @@ -1,7 +1,7 @@ import { useLazyQuery } from '@apollo/react-hooks' import { makeStyles, ClickAwayListener } from '@material-ui/core' import classnames from 'classnames' -import { format, isSameDay } from 'date-fns/fp' +import { format } from 'date-fns/fp' import FileSaver from 'file-saver' import * as R from 'ramda' import React, { useState, useCallback } from 'react' @@ -189,7 +189,6 @@ const LogsDownloaderPopover = ({ if (!range || !range.from) return if (range.from && !range.until) range.until = new Date() - if (isSameDay(range.until, range.from)) range.until = new Date() if (selectedRadio === RANGE) { fetchLogs({ diff --git a/new-lamassu-admin/src/components/Tooltip.js b/new-lamassu-admin/src/components/Tooltip.js index 952305ee..2fa5b7f9 100644 --- a/new-lamassu-admin/src/components/Tooltip.js +++ b/new-lamassu-admin/src/components/Tooltip.js @@ -1,4 +1,5 @@ import { makeStyles, ClickAwayListener } from '@material-ui/core' +import * as R from 'ramda' import React, { useState, memo } from 'react' import Popper from 'src/components/Popper' @@ -8,9 +9,9 @@ const useStyles = makeStyles({ transparentButton: { border: 'none', backgroundColor: 'transparent', - marginTop: 4, outline: 'none', - cursor: 'pointer' + cursor: 'pointer', + marginTop: 4 }, popoverContent: ({ width }) => ({ width, @@ -69,11 +70,22 @@ const HoverableTooltip = memo(({ parentElements, children, width }) => { return (
-
- {parentElements} -
+ {!R.isNil(parentElements) && ( +
+ {parentElements} +
+ )} + {R.isNil(parentElements) && ( + + )} { const [toSHeader, noSHeader] = R.partition(R.has('doubleHeader'))(elements) @@ -31,6 +41,7 @@ const groupSecondHeader = elements => { } const Header = () => { + const classes = useStyles() const { elements, enableEdit, @@ -40,6 +51,7 @@ const Header = () => { deleteWidth, enableToggle, toggleWidth, + orderedBy, DEFAULT_COL_SIZE } = useContext(TableCtx) @@ -60,11 +72,40 @@ const Header = () => { const mapElement = ( { name, width = DEFAULT_COL_SIZE, header, textAlign }, idx - ) => ( - - {header || startCase(name)} - - ) + ) => { + const orderClasses = classnames({ + [classes.orderedBySpan]: + R.isNil(header) && !R.isNil(orderedBy) && R.equals(name, orderedBy.code) + }) + + const attachOrderedByToComplexHeader = header => { + if (!R.isNil(orderedBy) && R.equals(name, orderedBy.code)) { + try { + const cloneHeader = R.clone(header) + const children = R.path(['props', 'children'], cloneHeader) + const spanChild = R.find(it => R.equals(it.type, 'span'), children) + spanChild.props.children = R.append(' -', spanChild.props.children) + return cloneHeader + } catch (e) { + return header + } + } + return header + } + + return ( + + {!R.isNil(header) ? ( + <>{attachOrderedByToComplexHeader(header) ?? header} + ) : ( + + {startCase(name)}{' '} + {!R.isNil(orderedBy) && R.equals(name, orderedBy.code) && '-'} + + )} + + ) + } const [innerElements, HeaderElement] = groupSecondHeader(elements) diff --git a/new-lamassu-admin/src/components/editableTable/Table.js b/new-lamassu-admin/src/components/editableTable/Table.js index d3edb906..a5e66733 100644 --- a/new-lamassu-admin/src/components/editableTable/Table.js +++ b/new-lamassu-admin/src/components/editableTable/Table.js @@ -56,7 +56,8 @@ const ETable = ({ sortBy, createText = 'Add override', forceAdd = false, - tbodyWrapperClass + tbodyWrapperClass, + orderedBy = null }) => { const [editingId, setEditingId] = useState(null) const [adding, setAdding] = useState(false) @@ -155,6 +156,7 @@ const ETable = ({ actionColSize, stripeWhen, forceAdd, + orderedBy, DEFAULT_COL_SIZE } diff --git a/new-lamassu-admin/src/components/inputs/base/Select.js b/new-lamassu-admin/src/components/inputs/base/Select.js index c29ac6b0..95f5cd39 100644 --- a/new-lamassu-admin/src/components/inputs/base/Select.js +++ b/new-lamassu-admin/src/components/inputs/base/Select.js @@ -1,6 +1,7 @@ import { makeStyles } from '@material-ui/core' import classnames from 'classnames' import { useSelect } from 'downshift' +import * as R from 'ramda' import React from 'react' import { ReactComponent as Arrowdown } from 'src/styling/icons/action/arrow/regular.svg' @@ -29,7 +30,9 @@ function Select({ className, label, items, ...props }) { const selectClassNames = { [classes.select]: true, - [classes.selectFiltered]: selectedItem !== props.default, + [classes.selectFiltered]: props.defaultAsFilter + ? true + : !R.equals(selectedItem, props.default), [classes.open]: isOpen } diff --git a/new-lamassu-admin/src/components/layout/Sidebar.js b/new-lamassu-admin/src/components/layout/Sidebar.js index 820bb750..4c60d38e 100644 --- a/new-lamassu-admin/src/components/layout/Sidebar.js +++ b/new-lamassu-admin/src/components/layout/Sidebar.js @@ -27,16 +27,17 @@ const Sidebar = ({ {loading &&

Loading...

} {!loading && data?.map((it, idx) => ( -
onClick(it)}> - {itemRender ? itemRender(it, isSelected(it)) : displayName(it)} +
onClick(it)}> +
+ {itemRender ? itemRender(it, isSelected(it)) : displayName(it)} +
))} {!loading && children} diff --git a/new-lamassu-admin/src/components/layout/Sidebar.styles.js b/new-lamassu-admin/src/components/layout/Sidebar.styles.js index 2391cfce..1165ed59 100644 --- a/new-lamassu-admin/src/components/layout/Sidebar.styles.js +++ b/new-lamassu-admin/src/components/layout/Sidebar.styles.js @@ -30,7 +30,9 @@ export default { boxShadow: `-200px 0px 0px 0px ${sidebarColor}` } }, - + linkWrapper: { + cursor: 'pointer' + }, link: { extend: p, position: 'relative', diff --git a/new-lamassu-admin/src/components/layout/TitleSection.styles.js b/new-lamassu-admin/src/components/layout/TitleSection.styles.js index 05d9689b..351193da 100644 --- a/new-lamassu-admin/src/components/layout/TitleSection.styles.js +++ b/new-lamassu-admin/src/components/layout/TitleSection.styles.js @@ -19,6 +19,7 @@ export default { }, buttonText: { color: backgroundColor, + fontFamily: 'Mont', fontSize: 15 }, icon: { diff --git a/new-lamassu-admin/src/pages/Accounting/Accounting.js b/new-lamassu-admin/src/pages/Accounting/Accounting.js index c57ebea9..7175cd3d 100644 --- a/new-lamassu-admin/src/pages/Accounting/Accounting.js +++ b/new-lamassu-admin/src/pages/Accounting/Accounting.js @@ -5,7 +5,7 @@ import * as R from 'ramda' import React, { useContext } from 'react' import AppContext from 'src/AppContext' -import { Tooltip } from 'src/components/Tooltip' +import { HoverableTooltip } from 'src/components/Tooltip' import TitleSection from 'src/components/layout/TitleSection' import DataTable from 'src/components/tables/DataTable' import { H4, Info2, P } from 'src/components/typography' @@ -127,9 +127,9 @@ const Accounting = () => { {it.description} {!!it.extraInfo && ( - +

{it.extraInfo}

-
+ )}
) diff --git a/new-lamassu-admin/src/pages/Analytics/Analytics.js b/new-lamassu-admin/src/pages/Analytics/Analytics.js index 936db2ba..21c96751 100644 --- a/new-lamassu-admin/src/pages/Analytics/Analytics.js +++ b/new-lamassu-admin/src/pages/Analytics/Analytics.js @@ -300,6 +300,7 @@ const Analytics = () => { items={REPRESENTING_OPTIONS} default={REPRESENTING_OPTIONS[0]} selectedItem={representing} + defaultAsFilter />