All files / components/MessageItem MessageItem.js

100% Statements 4/4
66.66% Branches 4/6
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56              4x 1x                                                                                   4x   4x      
import React from "react";
import moment from "moment";
import styles from "./MessageItem.module.scss";
import Highlighter from "react-highlight-words";
import { ProfilePicPlaceholder } from "hc-inbox-profile";
import { profilePicPlaceholderStyle } from "../ConversationShell/ConversationShell";
 
const MessageItem = ({ user, active, query }) => {
  return (
    <div
      className={`${!active ? styles.MessageItem : styles.MessageItem__active}`}
    >
      <div className={styles.MessageItem__imgcontainer}>
        <ProfilePicPlaceholder
          name={user?.username || ""}
          id={user?.thread?.sender?.id}
          height={profilePicPlaceholderStyle.height}
          width={profilePicPlaceholderStyle.width}
          fontSize={profilePicPlaceholderStyle.fontSize}
        />
        <div className={styles.MessageItem__imgcontainer__status_circle}></div>
      </div>
      <div className={styles.MessageItem__body}>
        <div className={styles.MessageItem__body__name}>
          <small className={styles.MessageItem__body__message__small}>
            {user?.username !== null ? user?.username : "Profile Name"}
          </small>
          <small className={styles.MessageItem__body__date}>
            {moment(Number(user?.timestamp)).format("L")}
          </small>
        </div>
        <div className={styles.MessageItem__body__message}>
          <div>
            <Highlighter
              highlightClassName={styles.MessageItem__highlited_searched_query}
              // activeStyle={{ color: 'red' }}
              searchWords={[query?.parameter]}
              // autoEscape={true}
              textToHighlight={user?.body}
            />
            {/* {recentMessage?.body} */}
          </div>
 
          <small>In Chat with {user?.username}</small>
        </div>
      </div>
    </div>
  );
};
 
MessageItem.propTypes = {};
 
MessageItem.defaultProps = {};
 
export default MessageItem;