Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jan 20, 2021
1 parent fc608a6 commit 0c3f1bb
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/components/LastUpdatedCell/LastUpdatedCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@ import { red } from '@material-ui/core/colors';
import RelativeTime from 'react-relative-time';
import ItemTableCell from '../ItemTableCell';

export default function LastUpdatedCell ({ time, reactTableCellProps, classes }){
const lastUpdated = new Date(time).getTime();
const now = new Date().getTime();
const timeDelta = now - lastUpdated;
const day = 24 * 60 * 60 * 1000;
const week = day * 7;
const month = week * 4;
export default function LastUpdatedCell({ time, reactTableCellProps, classes }) {
const lastUpdated = new Date(time).getTime();
const now = new Date().getTime();
const timeDelta = now - lastUpdated;
const day = 24 * 60 * 60 * 1000;
const week = day * 7;
const month = week * 4;

let backgroundColor = "white";
if (timeDelta > day && timeDelta <= week) {
backgroundColor = red[100]
}
else if (timeDelta > week && timeDelta <= month) {
backgroundColor = red[300]
}
else if (timeDelta > month) {
backgroundColor = red[500]
}
let backgroundColor = "white";
if (timeDelta > day && timeDelta <= week) {
backgroundColor = red[100]
}
else if (timeDelta > week && timeDelta <= month) {
backgroundColor = red[300]
}
else if (timeDelta > month) {
backgroundColor = red[500]
}

return (
<ItemTableCell
classes={classes}
// Expands table cell props to allow access to style props.
{...reactTableCellProps}
// Expands style prop of table cell to allow addtion of custom styling without losing default styling.
style={{...reactTableCellProps.style, backgroundColor: backgroundColor }}
backgroundColor={backgroundColor}
>
<RelativeTime value={time} />
</ItemTableCell>
);
return (
<ItemTableCell
classes={classes}
// Expands table cell props to allow access to style props.
{...reactTableCellProps}
// Expands style prop of table cell to allow addtion of custom styling without losing default styling.
style={{ ...reactTableCellProps.style, backgroundColor: backgroundColor }}
backgroundColor={backgroundColor}
>
<RelativeTime value={time} />
</ItemTableCell>
);
}

LastUpdatedCell.propTypes = {
/** Time value in ISO8601. */
"time": PropTypes.string,
/** Props passed from ItemTable. */
"reactTableProps": PropTypes.object,
/**Object that passes classes to the component. */
"classes": PropTypes.object,
/** Time value in ISO8601. */
"time": PropTypes.string,
/** Props passed from ItemTable. */
"reactTableProps": PropTypes.object,
/**Object that passes classes to the component. */
"classes": PropTypes.object,

};

LastUpdatedCell.defaultProps = {
"time": "",
"reactTableProps": {},
"classes": {},
"time": "",
"reactTableProps": {},
"classes": {},
};

0 comments on commit 0c3f1bb

Please sign in to comment.