Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3089 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3089 Rev 5334
Línea 1... Línea 1...
1
import React, { useState } from "react";
1
import React, { useState } from 'react'
2
import parse from "html-react-parser";
2
import parse from 'html-react-parser'
3
import styled from "styled-components";
3
import styled from 'styled-components'
4
import LikeButton from "../like-button/LikeButton";
4
import LikeButton from '../like-button/LikeButton'
5
import { addNotification } from "../../../../redux/notification/notification.actions";
5
import { addNotification } from '../../../../redux/notification/notification.actions'
6
import { useDispatch } from "react-redux";
6
import { useDispatch } from 'react-redux'
Línea 7... Línea 7...
7
 
7
 
8
const StyledChatImgMessage = styled.div`
8
const StyledChatImgMessage = styled.div`
9
  display: flex;
9
  display: flex;
10
  justify-content: center;
10
  justify-content: center;
Línea 29... Línea 29...
29
    .fa {
29
    .fa {
30
      font-size: 1rem;
30
      font-size: 1rem;
31
      color: gray;
31
      color: gray;
32
    }
32
    }
33
  }
33
  }
34
`;
34
`
Línea 35... Línea 35...
35
 
35
 
36
const ResponseMessageContainer = styled.div`
36
const ResponseMessageContainer = styled.div`
37
  display: flex;
37
  display: flex;
38
  flex-direction: column;
38
  flex-direction: column;
39
  text-align: center;
39
  text-align: center;
40
  gap: 10px;
40
  gap: 10px;
41
  align-items: ${props => props.isRight ? 'flex-end' : 'flex-start'};
41
  align-items: ${props => props.isRight ? 'flex-end' : 'flex-start'};
Línea 42... Línea 42...
42
`
42
`
43
 
43
 
44
function propsAreEqual(prevProp, nextProp) {
44
function propsAreEqual (prevProp, nextProp) {
Línea 45... Línea 45...
45
  return prevProp.time === nextProp.time
45
  return prevProp.time === nextProp.time
46
}
-
 
47
 
46
}
48
const MessageTemplate = ({ message, setResponseMessage, responseMessage, time }) => {
47
 
49
 
48
const MessageTemplate = ({ message, setResponseMessage, responseMessage, time }) => {
Línea 50... Línea 49...
50
  const [isShow, setIsShow] = useState(false);
49
  const [isShow, setIsShow] = useState(false)
51
  const [isLiked, setIsLiked] = useState(false);
50
  const [isLiked, setIsLiked] = useState(false)
52
  const dispatch = useDispatch()
51
  const dispatch = useDispatch()
53
 
52
 
54
  const senderName = (message) => {
53
  const senderName = (message) => {
Línea 55... Línea 54...
55
    if (message.type === "group") {
54
    if (message.type === 'group') {
56
      return message.u === 1 ? "" : message.user_name;
55
      return message.u === 1 ? '' : message.user_name
57
    }
56
    }
58
  };
57
  }
Línea 68... Línea 67...
68
  }
67
  }
Línea 69... Línea 68...
69
 
68
 
70
  const handleCopy = async () => {
69
  const handleCopy = async () => {
71
    await navigator.clipboard.writeText(`${message.m}`)
70
    await navigator.clipboard.writeText(`${message.m}`)
72
    dispatch(addNotification({
71
    dispatch(addNotification({
73
      style: "success",
72
      style: 'success',
74
      msg: 'Mensaje copiado en el portapapeles',
73
      msg: 'Mensaje copiado en el portapapeles'
75
    }))
74
    }))
76
    setIsShow(!isShow)
75
    setIsShow(!isShow)
Línea 77... Línea 76...
77
  }
76
  }
78
 
77
 
79
  switch (message.mtype) {
78
  switch (message.mtype) {
80
    case "text":
79
    case 'text':
81
      return (
80
      return (
82
        <li
81
        <li
83
          key={message.id}
82
          key={message.id}
84
          className={`clearfix ${message.u === 1 ? "odd" : ""} m-t-10 conversers${message.u}`}
83
          className={`clearfix ${message.u === 1 ? 'odd' : ''} m-t-10 conversers${message.u}`}
85
        >
84
        >
86
          <div className="conversation-text">
85
          <div className="conversation-text">
87
            <div className="conversation_container w-100">
86
            <div className="conversation_container w-100">
88
              {
-
 
89
                responseMessage
87
              {
90
                &&
88
                responseMessage &&
91
                <ResponseMessageContainer isRight={message.u === 1}>
89
                <ResponseMessageContainer isRight={message.u === 1}>
92
                  <span>{`Respondiendo a ${responseMessage.user_name}`}</span>
90
                  <span>{`Respondiendo a ${responseMessage.user_name}`}</span>
93
                  <div className="ctext-wrap">
91
                  <div className="ctext-wrap">
Línea 105... Línea 103...
105
                  <p className="">
103
                  <p className="">
106
                    {parse(emojione.shortnameToImage(message.m))}
104
                    {parse(emojione.shortnameToImage(message.m))}
107
                    <br />
105
                    <br />
108
                    <div className="d-inline-flex align-items-center">
106
                    <div className="d-inline-flex align-items-center">
109
                      {
107
                      {
110
                        !message.not_received
108
                        !message.not_received &&
111
                        &&
-
 
112
                        <i className={"fa fa-check text-right ellipsis "} style={message.seen ? { color: 'blue' } : { color: 'gray' }} />
109
                        <i className={'fa fa-check text-right ellipsis '} style={message.seen ? { color: 'blue' } : { color: 'gray' }} />
113
                      }
110
                      }
114
                      <label>{time}</label>
111
                      <label>{time}</label>
115
                    </div>
112
                    </div>
116
                  </p>
113
                  </p>
117
                  {
114
                  {
118
                    isLiked
115
                    isLiked &&
119
                    &&
-
 
120
                    <i
116
                    <i
121
                      className="fas fa-heart"
117
                      className="fas fa-heart"
122
                      style={{
118
                      style={{
123
                        color: '#0961bf',
119
                        color: '#0961bf',
124
                        position: 'absolute',
120
                        position: 'absolute',
Línea 132... Línea 128...
132
                  className="la la-ellipsis-v icon"
128
                  className="la la-ellipsis-v icon"
133
                  style={{ position: 'relative' }}
129
                  style={{ position: 'relative' }}
134
                  onClick={() => setIsShow(!isShow)}
130
                  onClick={() => setIsShow(!isShow)}
135
                />
131
                />
136
                {
132
                {
137
                  isShow
133
                  isShow &&
138
                  &&
-
 
139
                  <div className="display-reactions" >
134
                  <div className="display-reactions" >
140
                    <LikeButton onClick={handleLike} />
135
                    <LikeButton onClick={handleLike} />
141
                    <button type="button" onClick={() => handleResponse(message)}>
136
                    <button type="button" onClick={() => handleResponse(message)}>
142
                      <i className="fa fa-reply" />
137
                      <i className="fa fa-reply" />
143
                    </button>
138
                    </button>
Línea 148... Línea 143...
148
                }
143
                }
149
              </div>
144
              </div>
150
            </div>
145
            </div>
151
          </div>
146
          </div>
152
        </li>
147
        </li>
153
      );
148
      )
154
    case "image":
149
    case 'image':
155
      return (
150
      return (
156
        <li
151
        <li
157
          key={message.id}
152
          key={message.id}
158
          className={`clearfix ${message.u === 1 ? "odd" : ""} m-t-10 conversers${message.u}`}
153
          className={`clearfix ${message.u === 1 ? 'odd' : ''} m-t-10 conversers${message.u}`}
159
        >
154
        >
160
          <div
155
          <div
161
            className="conversation-text"
156
            className="conversation-text"
162
            data-toggle="tooltip"
157
            data-toggle="tooltip"
163
            data-placement="left"
158
            data-placement="left"
Línea 168... Línea 163...
168
              <StyledChatImgMessage>
163
              <StyledChatImgMessage>
169
                <div className="chat_image_container">
164
                <div className="chat_image_container">
170
                  <img src={message.m} alt="chat_image" />
165
                  <img src={message.m} alt="chat_image" />
171
                </div>
166
                </div>
172
                {
167
                {
173
                  message.u !== 1
168
                  message.u !== 1 &&
174
                  &&
-
 
175
                  <a
169
                  <a
176
                    href={message.m}
170
                    href={message.m}
177
                    download
171
                    download
178
                    className="chat_image__download_button"
172
                    className="chat_image__download_button"
179
                  >
173
                  >
Línea 182... Línea 176...
182
                }
176
                }
183
              </StyledChatImgMessage>
177
              </StyledChatImgMessage>
184
              <br />
178
              <br />
185
              <i className="text-right">{time}</i>
179
              <i className="text-right">{time}</i>
186
              {
180
              {
187
                isLiked
181
                isLiked &&
188
                &&
-
 
189
                <i
182
                <i
190
                  className="fas fa-heart"
183
                  className="fas fa-heart"
191
                  style={{
184
                  style={{
192
                    color: '#0961bf',
185
                    color: '#0961bf',
193
                    position: 'absolute',
186
                    position: 'absolute',
Línea 201... Línea 194...
201
              className="la la-ellipsis-v icon"
194
              className="la la-ellipsis-v icon"
202
              style={{ position: 'relative' }}
195
              style={{ position: 'relative' }}
203
              onClick={() => setIsShow(!isShow)}
196
              onClick={() => setIsShow(!isShow)}
204
            />
197
            />
205
            {
198
            {
206
              isShow
199
              isShow &&
207
              &&
-
 
208
              <div className="display-reactions">
200
              <div className="display-reactions">
209
                <LikeButton onClick={handleLike} />
201
                <LikeButton onClick={handleLike} />
210
                <button type="button" onClick={() => handleResponse(message)}>
202
                <button type="button" onClick={() => handleResponse(message)}>
211
                  <i className="fa fa-reply" />
203
                  <i className="fa fa-reply" />
212
                </button>
204
                </button>
213
              </div>
205
              </div>
214
            }
206
            }
215
          </div>
207
          </div>
216
        </li>
208
        </li>
217
      );
209
      )
218
    case "video":
210
    case 'video':
219
      return (
211
      return (
220
        <li
212
        <li
221
          key={message.id}
213
          key={message.id}
222
          className={`clearfix ${message.u === 1 ? "odd" : ""} m-t-10 conversers${message.u}`}
214
          className={`clearfix ${message.u === 1 ? 'odd' : ''} m-t-10 conversers${message.u}`}
223
        >
215
        >
224
          <div
216
          <div
225
            className="conversation-text"
217
            className="conversation-text"
226
            data-toggle="tooltip"
218
            data-toggle="tooltip"
227
            data-placement="left"
219
            data-placement="left"
Línea 237... Línea 229...
237
                >
229
                >
238
                  <div className="chat_image_container">
230
                  <div className="chat_image_container">
239
                    <video src={message.m} preload="none" controls></video>
231
                    <video src={message.m} preload="none" controls></video>
240
                  </div>
232
                  </div>
241
                </a>
233
                </a>
242
                {message.u !== 1
234
                {message.u !== 1 &&
243
                  &&
-
 
244
                  <a
235
                  <a
245
                    href={message.m}
236
                    href={message.m}
246
                    download
237
                    download
247
                    className="chat_image__download_button"
238
                    className="chat_image__download_button"
248
                  >
239
                  >
Línea 251... Línea 242...
251
                }
242
                }
252
              </StyledChatImgMessage>
243
              </StyledChatImgMessage>
253
              <br />
244
              <br />
254
              <i className="text-right">{time}</i>
245
              <i className="text-right">{time}</i>
255
              {
246
              {
256
                isLiked
247
                isLiked &&
257
                &&
-
 
258
                <i
248
                <i
259
                  className="fas fa-heart"
249
                  className="fas fa-heart"
260
                  style={{
250
                  style={{
261
                    color: '#0961bf',
251
                    color: '#0961bf',
262
                    position: 'absolute',
252
                    position: 'absolute',
Línea 270... Línea 260...
270
              className="la la-ellipsis-v icon"
260
              className="la la-ellipsis-v icon"
271
              style={{ position: 'relative' }}
261
              style={{ position: 'relative' }}
272
              onClick={() => setIsShow(!isShow)}
262
              onClick={() => setIsShow(!isShow)}
273
            />
263
            />
274
            {
264
            {
275
              isShow
265
              isShow &&
276
              &&
-
 
277
              <div className="display-reactions">
266
              <div className="display-reactions">
278
                <LikeButton onClick={handleLike} />
267
                <LikeButton onClick={handleLike} />
279
                <button type="button" onClick={() => handleResponse(message)}>
268
                <button type="button" onClick={() => handleResponse(message)}>
280
                  <i className="fa fa-reply" />
269
                  <i className="fa fa-reply" />
281
                </button>
270
                </button>
282
              </div>
271
              </div>
283
            }
272
            }
284
          </div>
273
          </div>
285
        </li>
274
        </li>
286
      );
275
      )
287
    case "document":
276
    case 'document':
288
      return (
277
      return (
289
        <li
278
        <li
290
          key={message.id}
279
          key={message.id}
291
          className={`clearfix ${message.u === 1 ? "odd" : ""} m-t-10 conversers${message.u}`}
280
          className={`clearfix ${message.u === 1 ? 'odd' : ''} m-t-10 conversers${message.u}`}
292
        >
281
        >
293
          <div
282
          <div
294
            className="conversation-text"
283
            className="conversation-text"
295
            data-toggle="tooltip"
284
            data-toggle="tooltip"
296
            data-placement="left"
285
            data-placement="left"
Línea 304... Línea 293...
304
                    className="pdf"
293
                    className="pdf"
305
                    src="/storage/type/default/filename/pdf.png"
294
                    src="/storage/type/default/filename/pdf.png"
306
                    alt="pdf"
295
                    alt="pdf"
307
                  />
296
                  />
308
                </div>
297
                </div>
309
                {message.u !== 1
298
                {message.u !== 1 &&
310
                  &&
-
 
311
                  <a
299
                  <a
312
                    href={message.m}
300
                    href={message.m}
313
                    target="_blank"
301
                    target="_blank"
314
                    className="chat_image__download_button" rel="noreferrer"
302
                    className="chat_image__download_button" rel="noreferrer"
315
                  >
303
                  >
Línea 318... Línea 306...
318
                }
306
                }
319
              </StyledChatImgMessage>
307
              </StyledChatImgMessage>
320
              <br />
308
              <br />
321
              <i className="text-right">{time}</i>
309
              <i className="text-right">{time}</i>
322
              {
310
              {
323
                isLiked
311
                isLiked &&
324
                &&
-
 
325
                <i
312
                <i
326
                  className="fas fa-heart"
313
                  className="fas fa-heart"
327
                  style={{
314
                  style={{
328
                    color: '#0961bf',
315
                    color: '#0961bf',
329
                    position: 'absolute',
316
                    position: 'absolute',
Línea 337... Línea 324...
337
              className="la la-ellipsis-v icon"
324
              className="la la-ellipsis-v icon"
338
              style={{ position: 'relative' }}
325
              style={{ position: 'relative' }}
339
              onClick={() => setIsShow(!isShow)}
326
              onClick={() => setIsShow(!isShow)}
340
            />
327
            />
341
            {
328
            {
342
              isShow
329
              isShow &&
343
              &&
-
 
344
              <div className="display-reactions">
330
              <div className="display-reactions">
345
                <LikeButton onClick={handleLike} />
331
                <LikeButton onClick={handleLike} />
346
                <button type="button" onClick={() => handleResponse(message)}>
332
                <button type="button" onClick={() => handleResponse(message)}>
347
                  <i className="fa fa-reply" />
333
                  <i className="fa fa-reply" />
348
                </button>
334
                </button>
349
              </div>
335
              </div>
350
            }
336
            }
351
          </div>
337
          </div>
352
        </li>
338
        </li>
353
      );
339
      )
354
    default:
340
    default:
355
      return (
341
      return (
356
        <li
342
        <li
357
          key={message.id}
343
          key={message.id}
358
          className={`clearfix ${message.u === 1 ? "odd" : ""} m-t-10 conversers${message.u}`}
344
          className={`clearfix ${message.u === 1 ? 'odd' : ''} m-t-10 conversers${message.u}`}
359
        >
345
        >
360
          <div
346
          <div
361
            className="conversation-text"
347
            className="conversation-text"
362
            data-toggle="tooltip"
348
            data-toggle="tooltip"
363
            data-placement="left"
349
            data-placement="left"
Línea 375... Línea 361...
375
              className="la la-ellipsis-v icon"
361
              className="la la-ellipsis-v icon"
376
              style={{ position: 'relative' }}
362
              style={{ position: 'relative' }}
377
              onClick={() => setIsShow(!isShow)}
363
              onClick={() => setIsShow(!isShow)}
378
            />
364
            />
379
            {
365
            {
380
              isShow
366
              isShow &&
381
              &&
-
 
382
              <div className="display-reactions">
367
              <div className="display-reactions">
383
                <LikeButton onClick={handleLike} />
368
                <LikeButton onClick={handleLike} />
384
                <button type="button" onClick={() => setResponseMessage(message)}>
369
                <button type="button" onClick={() => setResponseMessage(message)}>
385
                  <i className="fa fa-reply" />
370
                  <i className="fa fa-reply" />
386
                </button>
371
                </button>
387
              </div>
372
              </div>
388
            }
373
            }
389
          </div>
374
          </div>
390
        </li>
375
        </li>
391
      );
376
      )
392
  }
377
  }
393
};
378
}
Línea 394... Línea 379...
394
 
379