Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15853 | 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 }) => {
7
  const { m, user_name, u } = 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>}
15851 stevensc 20
          <img
21
            className={styles.chatImg}
22
            src={m}
23
            alt="chat_img"
24
            ref={type === "new" ? lastEl : undefined}
25
          />
26
        </div>
27
        <a href={m} target="_blank" className={styles.downloadBtn}>
28
          <i className="fa ti-arrow-circle-down"></i>
29
        </a>
30
      </>
31
    ),
32
    video: (
33
      <>
34
        <div className={styles.messageContainer}>
15853 stevensc 35
          {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15851 stevensc 36
          <video
37
            className={styles.chatImg}
38
            src={m}
39
            preload="none"
40
            controls
41
            ref={type === "new" ? lastEl : undefined}
42
          ></video>
43
        </div>
44
        <a href={m} target="_blank" className={styles.downloadBtn}>
45
          <i className="fa ti-arrow-circle-down"></i>
46
        </a>
47
      </>
48
    ),
49
    document: (
50
      <>
51
        <div className={styles.messageContainer}>
15853 stevensc 52
          {u !== 1 && <span className={styles.userName}>{user_name}</span>}
15851 stevensc 53
          <img
54
            className={styles.pdfImage}
55
            src="/storage/type/default/filename/pdf.png"
56
            alt="pdf"
57
            ref={type === "new" ? lastEl : undefined}
58
          />
59
        </div>
60
        <a href={m} target="_blank" className={styles.downloadBtn}>
61
          <i className="fa ti-arrow-circle-down"></i>
62
        </a>
63
      </>
64
    ),
11347 nelberth 65
  };
66
 
67
  return (
15851 stevensc 68
    <div
69
      className={`${styles.message} ${
70
        message.u === 1 ? styles.message_sent : styles.message_received
71
      }`}
72
    >
73
      {messageContent[message.mtype]}
74
    </div>
11347 nelberth 75
  );
76
};
77
 
15851 stevensc 78
export default Message;