fix: add empty table text

This commit is contained in:
Taranto 2020-10-22 09:00:23 +01:00 committed by Josh Harvey
parent 97ffb7bdf1
commit 00387e0862
7 changed files with 81 additions and 48 deletions

View file

@ -1,4 +1,4 @@
import { makeStyles } from '@material-ui/core/styles'
import { makeStyles, Box } from '@material-ui/core'
import classnames from 'classnames'
import * as R from 'ramda'
import React, { useState } from 'react'
@ -17,6 +17,7 @@ import {
Td,
Th
} from 'src/components/fake-table/Table'
import { H4 } from 'src/components/typography'
import { ReactComponent as ExpandClosedIcon } from 'src/styling/icons/action/expand/closed.svg'
import { ReactComponent as ExpandOpenIcon } from 'src/styling/icons/action/expand/open.svg'
@ -94,6 +95,8 @@ const DataTable = ({
expandable,
shouldStartExpanded,
onClick,
loading,
emptyText,
...props
}) => {
const [expanded, setExpanded] = useState(null)
@ -143,6 +146,7 @@ const DataTable = ({
}
return (
<Box display="flex" flex="1" flexDirection="column">
<Table className={classes.table}>
<THead>
{elements.map(({ width, className, textAlign, header }, idx) => (
@ -157,6 +161,8 @@ const DataTable = ({
{expandable && <Th width={expWidth}></Th>}
</THead>
<TBody className={classes.body}>
{loading && <H4>Loading...</H4>}
{!loading && R.isEmpty(data) && <H4>{emptyText}</H4>}
<AutoSizer disableWidth>
{({ height }) => (
<List
@ -175,6 +181,7 @@ const DataTable = ({
</AutoSizer>
</TBody>
</Table>
</Box>
)
}

View file

@ -92,7 +92,7 @@ const CustomerProfile = memo(() => {
const history = useHistory()
const { id: customerId } = useParams()
const { data: customerResponse, refetch: getCustomer } = useQuery(
const { data: customerResponse, refetch: getCustomer, loading } = useQuery(
GET_CUSTOMER,
{
variables: { customerId }
@ -171,7 +171,7 @@ const CustomerProfile = memo(() => {
/>
</Box>
</div>
<TransactionsList data={sortedTransactions} />
<TransactionsList data={sortedTransactions} loading={loading} />
</>
)
})

View file

@ -24,7 +24,7 @@ const GET_CUSTOMERS = gql`
const Customers = () => {
const history = useHistory()
const { data: customersResponse } = useQuery(GET_CUSTOMERS)
const { data: customersResponse, loading } = useQuery(GET_CUSTOMERS)
const handleCustomerClicked = customer =>
history.push(`/compliance/customer/${customer.id}`)
@ -33,7 +33,13 @@ const Customers = () => {
R.path(['customers'])(customersResponse) ?? []
)
return <CustomersList data={customersData} onClick={handleCustomerClicked} />
return (
<CustomersList
data={customersData}
onClick={handleCustomerClicked}
loading={loading}
/>
)
}
export default Customers

View file

@ -14,7 +14,7 @@ import styles from './CustomersList.styles'
const useStyles = makeStyles(styles)
const CustomersList = ({ data, onClick }) => {
const CustomersList = ({ data, onClick, loading }) => {
const classes = useStyles()
const elements = [
@ -75,7 +75,13 @@ const CustomersList = ({ data, onClick }) => {
{ label: 'Cash-out', icon: <TxOutIcon /> }
]}
/>
<DataTable elements={elements} data={data} onClick={onClick} />
<DataTable
loading={loading}
emptyText="No customers so far"
elements={elements}
data={data}
onClick={onClick}
/>
</>
)
}

View file

@ -15,7 +15,7 @@ import mainStyles from '../CustomersList.styles'
const useStyles = makeStyles(mainStyles)
const TransactionsList = ({ data }) => {
const TransactionsList = ({ data, loading }) => {
const classes = useStyles()
const hasData = !(R.isEmpty(data) || R.isNil(data))
@ -82,7 +82,9 @@ const TransactionsList = ({ data }) => {
<div className={classes.titleWrapper}>
<div className={classes.titleAndButtonsContainer}>
<H4>
{hasData
{loading
? 'Loading'
: hasData
? 'All transactions from this customer'
: 'No transactions so far'}
</H4>

View file

@ -1,5 +1,5 @@
import { useQuery } from '@apollo/react-hooks'
import { makeStyles } from '@material-ui/core/styles'
import { makeStyles } from '@material-ui/core'
import BigNumber from 'bignumber.js'
import gql from 'graphql-tag'
import moment from 'moment'
@ -54,7 +54,7 @@ const GET_TRANSACTIONS = gql`
const Transactions = () => {
const classes = useStyles()
const { data: txResponse } = useQuery(GET_TRANSACTIONS, {
const { data: txResponse, loading } = useQuery(GET_TRANSACTIONS, {
variables: {
limit: NUM_LOG_RESULTS
}
@ -160,6 +160,8 @@ const Transactions = () => {
</div>
</div>
<DataTable
loading={loading}
emptyText="No transactions so far"
elements={elements}
data={R.path(['transactions'])(txResponse)}
Details={DetailsRow}

View file

@ -6,11 +6,11 @@ import React, { useState } from 'react'
import { v4 } from 'uuid'
import Tooltip from 'src/components/Tooltip'
import { Link } from 'src/components/buttons'
import { Link, Button } from 'src/components/buttons'
import { Table as EditableTable } from 'src/components/editableTable'
import { Switch } from 'src/components/inputs'
import TitleSection from 'src/components/layout/TitleSection'
import { P, Label2 } from 'src/components/typography'
import { P, Label2, H2 } from 'src/components/typography'
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
import styles from './Triggers.styles'
@ -36,7 +36,7 @@ const Triggers = () => {
const [wizard, setWizard] = useState(false)
const [error, setError] = useState(false)
const { data } = useQuery(GET_INFO)
const { data, loading } = useQuery(GET_INFO)
const triggers = fromServer(data?.config?.triggers ?? [])
const complianceConfig =
@ -108,9 +108,11 @@ const Triggers = () => {
className={classes.tableWidth}
display="flex"
justifyContent="end">
{!loading && !R.isEmpty(triggers) && (
<Link color="primary" onClick={() => setWizard(true)}>
+ Add new trigger
</Link>
)}
</Box>
<EditableTable
data={triggers}
@ -131,6 +133,14 @@ const Triggers = () => {
onClose={() => setWizard(null)}
/>
)}
{!loading && R.isEmpty(triggers) && (
<Box display="flex" alignItems="center" flexDirection="column" mt={15}>
<H2>
It seems there are no active compliance triggers on your network
</H2>
<Button onClick={() => setWizard(true)}>Add first trigger</Button>
</Box>
)}
</>
)
}