feat: implement EmptyTable component
This commit is contained in:
parent
48c8d808b0
commit
00e820191f
5 changed files with 42 additions and 7 deletions
30
new-lamassu-admin/src/components/table/EmptyTable.js
Normal file
30
new-lamassu-admin/src/components/table/EmptyTable.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { makeStyles } from '@material-ui/core'
|
||||||
|
import React, { memo } from 'react'
|
||||||
|
|
||||||
|
import { H4 } from 'src/components/typography'
|
||||||
|
import { ReactComponent as EmptyTableIcon } from 'src/styling/icons/table/empty-table.svg'
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
emptyTable: {
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: 52
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
|
const EmptyTable = memo(({ message }) => {
|
||||||
|
const classes = useStyles()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes.emptyTable}>
|
||||||
|
<EmptyTableIcon />
|
||||||
|
<H4>{message}</H4>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export default EmptyTable
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import EditCell from './EditCell'
|
import EditCell from './EditCell'
|
||||||
|
import EmptyTable from './EmptyTable'
|
||||||
import Table from './Table'
|
import Table from './Table'
|
||||||
import TableBody from './TableBody'
|
import TableBody from './TableBody'
|
||||||
import TableCell from './TableCell'
|
import TableCell from './TableCell'
|
||||||
|
|
@ -8,6 +9,7 @@ import TableRow from './TableRow'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
EditCell,
|
EditCell,
|
||||||
|
EmptyTable,
|
||||||
Table,
|
Table,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ import {
|
||||||
Td,
|
Td,
|
||||||
Th
|
Th
|
||||||
} from 'src/components/fake-table/Table'
|
} from 'src/components/fake-table/Table'
|
||||||
|
import { EmptyTable } from 'src/components/table'
|
||||||
import { H4 } from 'src/components/typography'
|
import { H4 } from 'src/components/typography'
|
||||||
import { ReactComponent as ExpandClosedIcon } from 'src/styling/icons/action/expand/closed.svg'
|
import { ReactComponent as ExpandClosedIcon } from 'src/styling/icons/action/expand/closed.svg'
|
||||||
import { ReactComponent as ExpandOpenIcon } from 'src/styling/icons/action/expand/open.svg'
|
import { ReactComponent as ExpandOpenIcon } from 'src/styling/icons/action/expand/open.svg'
|
||||||
import { ReactComponent as EmptyTableIcon } from 'src/styling/icons/table/empty-table.svg'
|
|
||||||
|
|
||||||
import styles from './DataTable.styles'
|
import styles from './DataTable.styles'
|
||||||
|
|
||||||
|
|
@ -168,12 +168,7 @@ const DataTable = ({
|
||||||
</THead>
|
</THead>
|
||||||
<TBody className={classes.body}>
|
<TBody className={classes.body}>
|
||||||
{loading && <H4>Loading...</H4>}
|
{loading && <H4>Loading...</H4>}
|
||||||
{!loading && R.isEmpty(data) && (
|
{!loading && R.isEmpty(data) && <EmptyTable message={emptyText} />}
|
||||||
<div className={classes.emptyTable}>
|
|
||||||
<EmptyTableIcon />
|
|
||||||
<H4>{emptyText}</H4>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<AutoSizer disableWidth>
|
<AutoSizer disableWidth>
|
||||||
{({ height }) => (
|
{({ height }) => (
|
||||||
<List
|
<List
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
|
import { EmptyTable } from 'src/components/table'
|
||||||
import { P, Label2 } from 'src/components/typography'
|
import { P, Label2 } from 'src/components/typography'
|
||||||
import { fromNamespace, toNamespace } from 'src/utils/config'
|
import { fromNamespace, toNamespace } from 'src/utils/config'
|
||||||
|
|
||||||
|
|
@ -113,6 +114,7 @@ const CashOut = ({ name: SCREEN_KEY }) => {
|
||||||
disableRowEdit={R.compose(R.not, R.path(['active']))}
|
disableRowEdit={R.compose(R.not, R.path(['active']))}
|
||||||
elements={getElements(machines, locale)}
|
elements={getElements(machines, locale)}
|
||||||
/>
|
/>
|
||||||
|
{R.isEmpty(config) && <EmptyTable message="No machines so far" />}
|
||||||
{wizard && (
|
{wizard && (
|
||||||
<Wizard
|
<Wizard
|
||||||
machine={R.find(R.propEq('deviceId', wizard))(machines)}
|
machine={R.find(R.propEq('deviceId', wizard))(machines)}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { useQuery, useMutation } from '@apollo/react-hooks'
|
import { useQuery, useMutation } from '@apollo/react-hooks'
|
||||||
import { makeStyles } from '@material-ui/core'
|
import { makeStyles } from '@material-ui/core'
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
import * as R from 'ramda'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
|
|
@ -8,6 +9,7 @@ import { Table as EditableTable } from 'src/components/editableTable'
|
||||||
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
import { NumberInput } from 'src/components/inputs/formik'
|
import { NumberInput } from 'src/components/inputs/formik'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
|
import { EmptyTable } from 'src/components/table'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
|
|
||||||
import styles from './CashCassettes.styles.js'
|
import styles from './CashCassettes.styles.js'
|
||||||
|
|
@ -172,6 +174,10 @@ const CashCassettes = () => {
|
||||||
save={onSave}
|
save={onSave}
|
||||||
validationSchema={ValidationSchema}
|
validationSchema={ValidationSchema}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{data && R.isEmpty(data.machines) && (
|
||||||
|
<EmptyTable message="No machines so far" />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue