Skip to content

Commit

Permalink
Merge pull request #95 from ECN/enhanvement-use-relative-time-in-item…
Browse files Browse the repository at this point in the history
…table

Use RelativeTime component for time values in ItemTable
  • Loading branch information
campb303 authored Oct 28, 2020
2 parents 997f9b9 + 7779ad4 commit ac8570d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/ItemTable/ItemTable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import PropTypes from "prop-types";
import { useTable, useFilters, useFlexLayout, useSortBy } from "react-table";
import { makeStyles, Table, TableBody, TableCell, TableHead, TableRow, TableContainer, TableSortLabel
, Paper, Grid, useTheme, } from "@material-ui/core";
import { makeStyles, Table, TableBody, TableCell, TableHead, TableRow, TableContainer, TableSortLabel,
Paper, Grid, useTheme } from "@material-ui/core";
import { useHistory } from "react-router-dom";
import RelativeTime from "react-relative-time";
import ItemTableFilter from "../ItemTableFilter/"

export default function ItemTable({ data, onRowClick }) {
Expand Down Expand Up @@ -36,10 +37,10 @@ export default function ItemTable({ data, onRowClick }) {
{ Header: 'Subject', accessor: 'subject' },
{ Header: 'Status', accessor: 'status', },
{ Header: 'Priority', accessor: 'priority' },
{ Header: 'Last Updated', accessor: 'lastUpdated' },
{ Header: 'Last Updated', accessor: 'lastUpdated', Cell: ({ value }) => <RelativeTime value={value} /> },
{ Header: 'Department', accessor: 'department' },
{ Header: 'Building', accessor: 'building' },
{ Header: 'Date Received', accessor: 'dateReceived' },
{ Header: 'Date Received', accessor: 'dateReceived', Cell: ({ value }) => <RelativeTime value={value} /> },
], []);

const tableInstance = useTable(
Expand Down Expand Up @@ -75,7 +76,6 @@ export default function ItemTable({ data, onRowClick }) {
{column.render("Filter")}
</Grid>
<Grid item sm={2} alignItems='center' justify='center'>

<TableSortLabel {...column.getSortByToggleProps()}
active={column.isSorted ? true : false}
disableRipple={false}
Expand All @@ -96,8 +96,8 @@ export default function ItemTable({ data, onRowClick }) {
{rows.map((row, i) => {
prepareRow(row);
return (
<TableRow
onClick={ () => history.push(`/${row.original.queue}/${row.original.number}`) }
<TableRow
onClick={() => history.push(`/${row.original.queue}/${row.original.number}`)}
className={classes.bandedRows} {...row.getRowProps()}>
{row.cells.map(cell => (
<TableCell {...cell.getCellProps()}>
Expand Down

0 comments on commit ac8570d

Please sign in to comment.