From 261775f1c6ce42d27b11c5620687257274209afb Mon Sep 17 00:00:00 2001 From: wrigh393 Date: Wed, 10 Feb 2021 16:27:27 -0500 Subject: [PATCH] Added props necessary to get user alias --- src/components/EmailHeader/EmailHeader.js | 25 ++++++++--------- src/components/ItemBodyView/ItemBodyView.js | 18 ++++++++----- src/components/MessageView/MessageView.js | 30 ++++++++++----------- src/components/UserAvatar/UserAvatar.js | 6 ++--- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/components/EmailHeader/EmailHeader.js b/src/components/EmailHeader/EmailHeader.js index d3c5ccf..7465153 100644 --- a/src/components/EmailHeader/EmailHeader.js +++ b/src/components/EmailHeader/EmailHeader.js @@ -4,7 +4,7 @@ import { Paper, Grid, makeStyles, useTheme, Typography } from "@material-ui/core import RelativeTime from "react-relative-time"; import UserAvatar from "../UserAvatar/"; -export default function EmailHeader({ datetime, from_name, from_email, to, cc }){ +export default function EmailHeader({ datetime, userAlias, from_name, from_email, to, cc }) { const theme = useTheme(); const useStyles = makeStyles({ @@ -38,15 +38,15 @@ export default function EmailHeader({ datetime, from_name, from_email, to, cc }) * return "" * @returns {string} */ - function buildEmailNameString(name, email){ - let emailNameString = ""; + function buildEmailNameString(name, email) { + let emailNameString = ""; const isNotEmpty = (value) => { return value === "" || value === null ? false : true; }; - if (isNotEmpty(name)){ + if (isNotEmpty(name)) { emailNameString += `${name}`; }; - if (isNotEmpty(email)){ + if (isNotEmpty(email)) { emailNameString += ` <${email}>` } return emailNameString; @@ -57,13 +57,13 @@ export default function EmailHeader({ datetime, from_name, from_email, to, cc }) * @param {array} Array of objects containing names and emails. * @returns {string} String of email with names. */ - function buildRecipientString(recipients){ - if (recipients.length === 0){ + function buildRecipientString(recipients) { + if (recipients.length === 0) { return "Tits"; } let recipientString = ""; - recipients.map( (recipient, index) => { + recipients.map((recipient, index) => { recipientString += buildEmailNameString(recipient.name, recipient.email); index < recipients.length - 1 ? recipientString += ", " : recipientString += ""; return true; @@ -71,13 +71,14 @@ export default function EmailHeader({ datetime, from_name, from_email, to, cc }) return recipientString; }; - return( + return ( - @@ -95,7 +96,7 @@ export default function EmailHeader({ datetime, from_name, from_email, to, cc }) {to.length === 0 ? null : <>To: {buildRecipientString(to)}} - {cc.length === 0 ? null : <>Cc: {buildRecipientString(cc)} } + {cc.length === 0 ? null : <>Cc: {buildRecipientString(cc)}} } diff --git a/src/components/ItemBodyView/ItemBodyView.js b/src/components/ItemBodyView/ItemBodyView.js index 08a57f9..f2132a0 100644 --- a/src/components/ItemBodyView/ItemBodyView.js +++ b/src/components/ItemBodyView/ItemBodyView.js @@ -11,6 +11,8 @@ import { objectIsEmpty } from "../../utilities"; export default function ItemBodyView({ item }) { + + const useStyles = makeStyles(() => ({ "Timeline-root": { padding: "0", @@ -30,22 +32,25 @@ export default function ItemBodyView({ item }) { })); const classes = useStyles(); - const generateTimelineItem = (section) => { + const generateTimelineItem = (section, item) => { + + + switch (section.type) { case "directory_information": return case "initial_message": - return + return case "edit": - return + return case "status": return case "assignment": - return + return case "reply_to_user": return case "reply_from_user": - return + return case "parse_error": return default: @@ -56,6 +61,7 @@ export default function ItemBodyView({ item }) { return ( {objectIsEmpty(item) ? "" : item.content.map((section) => ( + - {generateTimelineItem(section)} + {generateTimelineItem(section, item)} ))} diff --git a/src/components/MessageView/MessageView.js b/src/components/MessageView/MessageView.js index e902a79..22a0316 100644 --- a/src/components/MessageView/MessageView.js +++ b/src/components/MessageView/MessageView.js @@ -3,7 +3,7 @@ import PropTypes from "prop-types"; import { Paper, Typography, makeStyles, useTheme } from "@material-ui/core"; import EmailHeader from "../EmailHeader/"; -export default function MessageView({ datetime, from_name, from_email, to, cc, content }){ +export default function MessageView({ datetime, userAlias, from_name, from_email, to, cc, content }) { const theme = useTheme(); const useStyles = makeStyles({ @@ -16,7 +16,7 @@ export default function MessageView({ datetime, from_name, from_email, to, cc, c return ( - + {content.map((line) => ( line === "\n" ?
: {line} @@ -27,25 +27,25 @@ export default function MessageView({ datetime, from_name, from_email, to, cc, c }; MessageView.propTypes = { - /** Name of message sender. */ - "from_name": PropTypes.string, - /** Date the message was sent in ISO 8601 format. */ - "datetime": PropTypes.string, - /** Email address of message sender. */ - "from_email": PropTypes.string, - /** Array of people the message was sent to. */ - "to": PropTypes.array, - /** Array of people the message was cc'd to. */ + /** Name of message sender. */ + "from_name": PropTypes.string, + /** Date the message was sent in ISO 8601 format. */ + "datetime": PropTypes.string, + /** Email address of message sender. */ + "from_email": PropTypes.string, + /** Array of people the message was sent to. */ + "to": PropTypes.array, + /** Array of people the message was cc'd to. */ "cc": PropTypes.array, /** The content of the message as an array of line with non-printable characters. */ "content": PropTypes.array }; MessageView.defaultProps = { - "from_name": "Name Unavailable", - "datetime": new Date(1970, 1, 1, 0, 0, 0, 0), - "from_email": "Email Unavailable", - "to": [], + "from_name": "Name Unavailable", + "datetime": new Date(1970, 1, 1, 0, 0, 0, 0), + "from_email": "Email Unavailable", + "to": [], "cc": [], "content": [] }; \ No newline at end of file diff --git a/src/components/UserAvatar/UserAvatar.js b/src/components/UserAvatar/UserAvatar.js index 652ce37..92407aa 100644 --- a/src/components/UserAvatar/UserAvatar.js +++ b/src/components/UserAvatar/UserAvatar.js @@ -1,9 +1,9 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; import PropTypes from "prop-types"; import { Avatar } from "@material-ui/core"; -export default function UserAvatar({ name, ...avatarProps }){ - return( +export default function UserAvatar({ name, alias, ...avatarProps }) { + return ( {name === "" ? null : name.charAt(0)}