Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15880 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15851 stevensc 1
import React from "react";
11347 nelberth 2
import parse from "html-react-parser";
3
 
4
import styles from "./messages.module.scss";
5
 
15851 stevensc 6
const Message = ({ message }) => {
15880 stevensc 7
  const { m, mtype, time, u, user_name } = message;
11347 nelberth 8
 
15851 stevensc 9
  const messageContent = {
15925 stevensc 10
    text: <p>{parse(emojione.shortnameToImage(m))}</p>,
15851 stevensc 11
    image: (
15925 stevensc 12
      <div className="d-flex align-item-center">
13
        <img className={styles.chatImg} src={m} alt="chat_img" />
15851 stevensc 14
        <a href={m} target="_blank" className={styles.downloadBtn}>
15
          <i className="fa ti-arrow-circle-down"></i>
16
        </a>
15925 stevensc 17
      </div>
15851 stevensc 18
    ),
19
    video: (
15925 stevensc 20
      <div className="d-flex align-item-center">
21
        <video className={styles.chatImg} src={m} preload="none" controls />
15851 stevensc 22
        <a href={m} target="_blank" className={styles.downloadBtn}>
23
          <i className="fa ti-arrow-circle-down"></i>
24
        </a>
15925 stevensc 25
      </div>
15851 stevensc 26
    ),
27
    document: (
15925 stevensc 28
      <div className="d-flex align-item-center">
29
        <img
30
          className={styles.pdfImage}
31
          src="/storage/type/default/filename/pdf.png"
32
          alt="pdf"
33
        />
15851 stevensc 34
        <a href={m} target="_blank" className={styles.downloadBtn}>
35
          <i className="fa ti-arrow-circle-down"></i>
36
        </a>
15925 stevensc 37
      </div>
15851 stevensc 38
    ),
11347 nelberth 39
  };
40
 
41
  return (
15925 stevensc 42
    <>
43
      {u !== 1 && <span className={styles.userName}>{user_name}</span>}
44
      <div
45
        className={`${styles.message} ${
46
          message.u === 1 ? styles.message_sent : styles.message_received
47
        }`}
48
      >
49
        <div className={styles.messageContainer}>
50
          {messageContent[mtype]}
51
          <span>{time}</span>
52
        </div>
53
      </div>
54
    </>
11347 nelberth 55
  );
56
};
57
 
15851 stevensc 58
export default Message;