Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15855 | Ir a la última revisión | | 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 = {
10
    text: (
11
      <div className={styles.messageContainer}>
15853 stevensc 12
        {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15854 stevensc 13
        <div>{parse(emojione.shortnameToImage(m))}</div>
15851 stevensc 14
      </div>
15
    ),
16
    image: (
17
      <>
18
        <div className={styles.messageContainer}>
15853 stevensc 19
          {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15855 stevensc 20
          <img className={styles.chatImg} src={m} alt="chat_img" />
15851 stevensc 21
        </div>
22
        <a href={m} target="_blank" className={styles.downloadBtn}>
23
          <i className="fa ti-arrow-circle-down"></i>
24
        </a>
25
      </>
26
    ),
27
    video: (
28
      <>
29
        <div className={styles.messageContainer}>
15853 stevensc 30
          {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15851 stevensc 31
          <video
32
            className={styles.chatImg}
33
            src={m}
34
            preload="none"
35
            controls
36
          ></video>
37
        </div>
38
        <a href={m} target="_blank" className={styles.downloadBtn}>
39
          <i className="fa ti-arrow-circle-down"></i>
40
        </a>
41
      </>
42
    ),
43
    document: (
44
      <>
45
        <div className={styles.messageContainer}>
15853 stevensc 46
          {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15851 stevensc 47
          <img
48
            className={styles.pdfImage}
49
            src="/storage/type/default/filename/pdf.png"
50
            alt="pdf"
51
          />
52
        </div>
53
        <a href={m} target="_blank" className={styles.downloadBtn}>
54
          <i className="fa ti-arrow-circle-down"></i>
55
        </a>
56
      </>
57
    ),
11347 nelberth 58
  };
59
 
60
  return (
15851 stevensc 61
    <div
62
      className={`${styles.message} ${
63
        message.u === 1 ? styles.message_sent : styles.message_received
64
      }`}
65
    >
15880 stevensc 66
      {messageContent[mtype]}
67
      <span>{time}</span>
15851 stevensc 68
    </div>
11347 nelberth 69
  );
70
};
71
 
15851 stevensc 72
export default Message;