From c37ac25d591e645faa01b054755684344c5db4ca Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Mon, 21 Sep 2020 00:26:40 -0400 Subject: [PATCH] Update ItemMetadataView to show subject, avatar, name, alias, email and date --- .../ItemMetadataView/ItemMetadataView.js | 84 ++++++++++++++----- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/src/components/ItemMetadataView/ItemMetadataView.js b/src/components/ItemMetadataView/ItemMetadataView.js index f6fda1e..7c7877c 100644 --- a/src/components/ItemMetadataView/ItemMetadataView.js +++ b/src/components/ItemMetadataView/ItemMetadataView.js @@ -1,24 +1,58 @@ import React from 'react'; -import PropTypes from 'prop-types' -import { makeStyles, Grid, Paper } from '@material-ui/core'; -import { Alert } from '@material-ui/lab' +import PropTypes from 'prop-types'; +import { makeStyles, Card, CardHeader, Avatar, Typography } from '@material-ui/core'; +import { Alert } from '@material-ui/lab'; +import webqueue2Theme from "../../theme"; +import UserAvatar from "../UserAvatar/"; export default function ItemMetadataView({item}){ + + const theme = webqueue2Theme(false); + const useStyles = makeStyles({ + "verticalPadding": { + paddingTop: theme.spacing(1), + paddingBottom: theme.spacing(1), + }, + "removeCardHeaderPadding": { + padding: "0" + } + }); + const classes = useStyles(); + const LockedAlert = () => { return ( {item.isLocked} ); - } - const useStyles = makeStyles({ - "gridContainer": { - paddingTop: ".75em", - } - }); + }; - const classes = useStyles(); + + /** + * Returns the title for the user. + * @example + * // Has alias and name + * return "campb303 (Justin Campbell)" + * // Has alias but no name + * return "campb303" + * // Has no alias and no name + * return "" + * @returns {string} + */ + function buildTitle(){ + let title = ""; + const isNotEmpty = (value) => { + return value === "" || value === null ? false : true; + }; + if (isNotEmpty(item.userName)){ + title += `${item.userName}`; + }; + if (isNotEmpty(item.userEmail)){ + title += ` <${item.userEmail}>` + } + return title; + }; const metadataFields = ["userEmail", "userAlias", "subject", "dateReceived", "assignedTo", "status", "priority", "department", "building"]; @@ -26,19 +60,23 @@ export default function ItemMetadataView({item}){ return( <> {item.isLocked ? LockedAlert() : ""} - - {metadataFields.map((field) => { - const title = field.toUpperCase(); - const subtitle = item[field] === undefined ? "Unknown" : item[field]; - return ( - - - {title}: {subtitle} - - - ); - })} - + + + {item.subject} + + + + } + title={buildTitle()} + subheader={Date(item.dateReceived)} + classes={{root: classes.removeCardHeaderPadding}} + /> + + + + Status, assignments, priority, refile, archive and delete controls coming soon to a theater near you. + ); }