Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5344 | Rev 6007 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5344 Rev 5807
Línea 62... Línea 62...
62
const OPTIONS = {
62
const OPTIONS = {
63
  GROUP: 'group',
63
  GROUP: 'group',
64
  CONFERENCE: 'conference',
64
  CONFERENCE: 'conference',
65
  ADD_CONTACTS: 'addContacts',
65
  ADD_CONTACTS: 'addContacts',
66
  LIST_CONTACTS: 'listContacts',
66
  LIST_CONTACTS: 'listContacts',
67
  INITIAL: null
67
  INITIAL: null,
68
}
68
}
Línea 69... Línea 69...
69
 
69
 
-
 
70
const PersonalChat = ({
-
 
71
  entity,
-
 
72
  onClose,
-
 
73
  onMinimize,
-
 
74
  onRead,
-
 
75
  not_seen_messages,
-
 
76
  minimized,
-
 
77
  timezones,
70
const PersonalChat = ({ entity, onClose, onMinimize, onRead, not_seen_messages, minimized, timezones }) => {
78
}) => {
71
  const {
79
  const {
72
    // id,
80
    // id,
73
    image,
81
    image,
74
    name,
82
    name,
Línea 81... Línea 89...
81
    url_leave,
89
    url_leave,
82
    url_delete,
90
    url_delete,
83
    url_add_user_to_group,
91
    url_add_user_to_group,
84
    url_get_contact_group_list,
92
    url_get_contact_group_list,
85
    url_get_contacts_availables_for_group,
93
    url_get_contacts_availables_for_group,
86
    url_zoom
94
    url_zoom,
87
  } = entity
95
  } = entity
Línea 88... Línea 96...
88
 
96
 
Línea 89... Línea 97...
89
  const [optionTab, setOptionTab] = useState(OPTIONS.INITIAL)
97
  const [optionTab, setOptionTab] = useState(OPTIONS.INITIAL)
Línea 101... Línea 109...
101
  const [currentPage, setCurrentPage] = useState(1)
109
  const [currentPage, setCurrentPage] = useState(1)
102
  const [lastPage, setLastPage] = useState(1)
110
  const [lastPage, setLastPage] = useState(1)
Línea 103... Línea 111...
103
 
111
 
Línea 104... Línea 112...
104
  const [loading, setLoading] = useState(false)
112
  const [loading, setLoading] = useState(false)
-
 
113
 
-
 
114
  const filtredGroupList = groupContactsList.filter((conversation) =>
Línea 105... Línea 115...
105
 
115
    conversation.name.toLowerCase().includes(search.toLowerCase())
106
  const filtredGroupList = groupContactsList.filter((conversation) => conversation.name.toLowerCase().includes(search.toLowerCase()))
116
  )
107
 
117
 
108
  // refs
118
  // refs
Línea 118... Línea 128...
118
  const handleGetMessages = async () => {
128
  const handleGetMessages = async () => {
119
    setLoading(true)
129
    setLoading(true)
120
    const response = await axios.get(url_get_all_messages)
130
    const response = await axios.get(url_get_all_messages)
121
    const resData = response.data
131
    const resData = response.data
122
    if (!resData.success) {
132
    if (!resData.success) {
123
      return ('ha ocurrido un error', resData)
133
      return 'ha ocurrido un error'
124
    }
134
    }
125
    const updatedMessages = [...resData.data.items].reverse()
135
    const updatedMessages = [...resData.data.items].reverse()
126
    const newMessages = updatedMessages.reduce((acum, updatedMessage) => {
136
    const newMessages = updatedMessages.reduce((acum, updatedMessage) => {
-
 
137
      if (
127
      if (messages.findIndex((message) => message.id === updatedMessage.id) === -1) {
138
        messages.findIndex((message) => message.id === updatedMessage.id) === -1
-
 
139
      ) {
128
        acum = [...acum, updatedMessage]
140
        acum = [...acum, updatedMessage]
129
      }
141
      }
130
      return acum
142
      return acum
131
    }, [])
143
    }, [])
Línea 134... Línea 146...
134
      setMessages([...messages, ...newMessages])
146
      setMessages([...messages, ...newMessages])
135
      setLoading(false)
147
      setLoading(false)
136
      setLastPage(resData.data.pages)
148
      setLastPage(resData.data.pages)
137
      scrollToBottom()
149
      scrollToBottom()
138
    } else {
150
    } else {
139
      setMessages([...updatedMessages])
-
 
140
      setLoading(false)
151
      setLoading(false)
141
    }
152
    }
142
  }
153
  }
Línea 143... Línea 154...
143
 
154
 
-
 
155
  const handleLoadMore = async () => {
144
  const handleLoadMore = async () => {
156
    await axios
145
    await axios.get(`${url_get_all_messages}?page=${currentPage}`)
157
      .get(`${url_get_all_messages}?page=${currentPage}`)
146
      .then((response) => {
158
      .then((response) => {
147
        const resData = response.data
159
        const resData = response.data
148
        if (resData.success) {
160
        if (resData.success) {
149
          if (resData.data.page > 1) {
161
          if (resData.data.page > 1) {
Línea 164... Línea 176...
164
      const resData = response.data
176
      const resData = response.data
165
      if (resData.success) {
177
      if (resData.success) {
166
        let newMessage = resData.data
178
        let newMessage = resData.data
Línea 167... Línea 179...
167
 
179
 
168
        online
180
        online
169
          ? newMessage = { ...newMessage, not_received: false }
181
          ? (newMessage = { ...newMessage, not_received: false })
Línea 170... Línea 182...
170
          : newMessage = { ...newMessage, not_received: true }
182
          : (newMessage = { ...newMessage, not_received: true })
171
 
183
 
172
        setMessages([...messages, newMessage])
184
        setMessages([...messages, newMessage])
173
      }
185
      }
Línea 228... Línea 240...
228
      : setResponseMessage({ ...element, m: 'Archivo adjunto' })
240
      : setResponseMessage({ ...element, m: 'Archivo adjunto' })
Línea 229... Línea 241...
229
 
241
 
230
    textAreaEl.current && textAreaEl.current.focus()
242
    textAreaEl.current && textAreaEl.current.focus()
Línea -... Línea 243...
-
 
243
  } */
231
  } */
244
 
Línea 232... Línea 245...
232
 
245
  const displayConferenceModal = () =>
233
  const displayConferenceModal = () => setShowConferenceModal(!showConferenceModal)
246
    setShowConferenceModal(!showConferenceModal)
234
 
247
 
235
  const loadPersonsAvailable = async () => {
248
  const loadPersonsAvailable = async () => {
Línea 258... Línea 271...
258
      }
271
      }
259
    })
272
    })
260
  }
273
  }
Línea 261... Línea 274...
261
 
274
 
262
  const tabsOptions = {
275
  const tabsOptions = {
263
    group:
276
    group: (
264
      <ul>
277
      <ul>
-
 
278
        {url_get_contact_group_list && (
-
 
279
          <li
265
        {url_get_contact_group_list &&
280
            className="optionsTab__option"
-
 
281
            onClick={() => showOptions(OPTIONS.LIST_CONTACTS)}
266
          <li className="optionsTab__option" onClick={() => showOptions(OPTIONS.LIST_CONTACTS)}>
282
          >
267
            <span className="optionsTab__option__icon">
283
            <span className="optionsTab__option__icon">
268
              <i className="fa fa-group" />
284
              <i className="fa fa-group" />
269
              Integrantes
285
              Integrantes
270
            </span>
286
            </span>
271
          </li>
287
          </li>
272
        }
288
        )}
-
 
289
        {url_add_user_to_group && (
-
 
290
          <li
273
        {url_add_user_to_group &&
291
            className="optionsTab__option"
-
 
292
            onClick={() => showOptions(OPTIONS.ADD_CONTACTS)}
274
          <li className="optionsTab__option" onClick={() => showOptions(OPTIONS.ADD_CONTACTS)}>
293
          >
275
            <span className="optionsTab__option__icon">
294
            <span className="optionsTab__option__icon">
276
              <i className="fa fa-user-plus"></i>
295
              <i className="fa fa-user-plus"></i>
277
            </span>
296
            </span>
278
            {CHAT_LABELS.ADD_CONTACTS}
297
            {CHAT_LABELS.ADD_CONTACTS}
279
          </li>
298
          </li>
280
        }
299
        )}
281
        {url_zoom &&
-
 
282
          <li
-
 
283
            className="optionsTab__option"
300
        {url_zoom && (
284
            onClick={displayConferenceModal}
-
 
285
          >
301
          <li className="optionsTab__option" onClick={displayConferenceModal}>
286
            <span className="optionsTab__option__icon">
302
            <span className="optionsTab__option__icon">
287
              <i className="fa fa-user-plus" />
303
              <i className="fa fa-user-plus" />
288
            </span>
304
            </span>
289
            {CHAT_LABELS.CREATE_CONFERENCE}
305
            {CHAT_LABELS.CREATE_CONFERENCE}
290
          </li>
306
          </li>
291
        }
307
        )}
292
        {url_delete &&
308
        {url_delete && (
293
          <li
309
          <li
294
            className="optionsTab__option"
310
            className="optionsTab__option"
295
            style={{ color: 'red' }}
311
            style={{ color: 'red' }}
296
            onClick={() => {
312
            onClick={() => {
Línea 301... Línea 317...
301
            <span className="optionsTab__option__icon">
317
            <span className="optionsTab__option__icon">
302
              <i className="fa fa-trash"></i>
318
              <i className="fa fa-trash"></i>
303
            </span>
319
            </span>
304
            Eliminar grupo
320
            Eliminar grupo
305
          </li>
321
          </li>
306
        }
322
        )}
307
        {!!url_leave &&
323
        {!!url_leave && (
308
          <li
324
          <li
309
            className="optionsTab__option"
325
            className="optionsTab__option"
310
            style={{ color: 'red' }}
326
            style={{ color: 'red' }}
311
            onClick={() => {
327
            onClick={() => {
312
              handleConfirmModalShow()
328
              handleConfirmModalShow()
Línea 316... Línea 332...
316
            <span className="optionsTab__option__icon">
332
            <span className="optionsTab__option__icon">
317
              <i className="fa fa-user-times"></i>
333
              <i className="fa fa-user-times"></i>
318
            </span>
334
            </span>
319
            Dejar grupo
335
            Dejar grupo
320
          </li>
336
          </li>
321
        }
337
        )}
322
      </ul>,
338
      </ul>
-
 
339
    ),
323
    conference:
340
    conference: (
324
      <ul>
341
      <ul>
325
        <li className="optionsTab__option" onClick={displayConferenceModal}>
342
        <li className="optionsTab__option" onClick={displayConferenceModal}>
326
          <span className="optionsTab__option__icon">
343
          <span className="optionsTab__option__icon">
327
            <i className="fa fa-user-plus" />
344
            <i className="fa fa-user-plus" />
328
          </span>
345
          </span>
329
          {CHAT_LABELS.CREATE_CONFERENCE}
346
          {CHAT_LABELS.CREATE_CONFERENCE}
330
        </li>
347
        </li>
331
      </ul>,
348
      </ul>
-
 
349
    ),
332
    addContacts:
350
    addContacts: (
333
      <>
351
      <>
334
        {availableContactsToAdd.length
352
        {availableContactsToAdd.length ? (
335
          ? <EmptySection message={CHAT_LABELS.NOT_CONTACTS} align='left' />
353
          <EmptySection message={CHAT_LABELS.NOT_CONTACTS} align="left" />
-
 
354
        ) : (
336
          : availableContactsToAdd.map(({ image, name, id }) =>
355
          availableContactsToAdd.map(({ image, name, id }) => (
337
            <div className="addPersonToGroupTab__person" key={id}>
356
            <div className="addPersonToGroupTab__person" key={id}>
338
              <div className="d-inline-flex" style={{ gap: '5px' }}>
357
              <div className="d-inline-flex" style={{ gap: '5px' }}>
339
                <img
358
                <img
340
                  className="chat-image img-circle pull-left"
359
                  className="chat-image img-circle pull-left"
341
                  height="36"
360
                  height="36"
Línea 343... Línea 362...
343
                  src={image}
362
                  src={image}
344
                  alt="image-image"
363
                  alt="image-image"
345
                />
364
                />
346
                <div className="name">{name}</div>
365
                <div className="name">{name}</div>
347
              </div>
366
              </div>
-
 
367
              <span
-
 
368
                className="cursor-pointer"
348
              <span className='cursor-pointer' onClick={() => handleAddPersonToGroup(id)}>
369
                onClick={() => handleAddPersonToGroup(id)}
-
 
370
              >
349
                <i className="fa fa-plus-circle" />
371
                <i className="fa fa-plus-circle" />
350
              </span>
372
              </span>
351
            </div>
373
            </div>
352
          )}
374
          ))
-
 
375
        )}
353
      </>,
376
      </>
-
 
377
    ),
354
    listContacts:
378
    listContacts: (
355
      <>
379
      <>
356
        <div className='group__search'>
380
        <div className="group__search">
357
          <SearchIcon />
381
          <SearchIcon />
358
          <input
382
          <input
359
            type='text'
383
            type="text"
360
            placeholder={CHAT_LABELS.SEARCH}
384
            placeholder={CHAT_LABELS.SEARCH}
361
            onChange={(e) => setSearch(e.target.value)}
385
            onChange={(e) => setSearch(e.target.value)}
362
          />
386
          />
363
        </div>
387
        </div>
364
        {filtredGroupList.length
388
        {filtredGroupList.length ? (
365
          ? filtredGroupList.map(({ image, name, url_remove_from_group, id }) => {
389
          filtredGroupList.map(({ image, name, url_remove_from_group, id }) => {
366
            return (
390
            return (
367
              <div className="addPersonToGroupTab__person" key={id}>
391
              <div className="addPersonToGroupTab__person" key={id}>
368
                <div style={{ display: 'flex', alignItems: 'center' }}>
392
                <div style={{ display: 'flex', alignItems: 'center' }}>
369
                  <img
393
                  <img
370
                    className="chat-image img-circle pull-left"
394
                    className="chat-image img-circle pull-left"
Línea 373... Línea 397...
373
                    src={image}
397
                    src={image}
374
                    alt="image-image"
398
                    alt="image-image"
375
                  />
399
                  />
376
                  <div className="name">{name}</div>
400
                  <div className="name">{name}</div>
377
                </div>
401
                </div>
378
                {url_remove_from_group &&
402
                {url_remove_from_group && (
-
 
403
                  <span
-
 
404
                    className="cursor-pointer"
-
 
405
                    onClick={() =>
379
                  <span className="cursor-pointer" onClick={() => handleDeletePersonFromGroup(url_remove_from_group)}>
406
                      handleDeletePersonFromGroup(url_remove_from_group)
-
 
407
                    }
-
 
408
                  >
380
                    <i className="fa fa-user-times" />
409
                    <i className="fa fa-user-times" />
381
                  </span>
410
                  </span>
382
                }
411
                )}
383
              </div>
412
              </div>
384
            )
413
            )
385
          })
414
          })
-
 
415
        ) : (
386
          : <div className="addPersonToGroupTab__person">{CHAT_LABELS.NOT_CONTACTS}</div>
416
          <div className="addPersonToGroupTab__person">
-
 
417
            {CHAT_LABELS.NOT_CONTACTS}
-
 
418
          </div>
387
        }
419
        )}
388
      </>
420
      </>
-
 
421
    ),
389
  }
422
  }
Línea 390... Línea 423...
390
 
423
 
391
  // getMessageOnMaximize and subscribe to infinite Loader
424
  // getMessageOnMaximize and subscribe to infinite Loader
392
  useEffect(async () => {
425
  useEffect(async () => {
393
    const options = {
426
    const options = {
394
      root: null,
427
      root: null,
395
      rootMargin: '20px',
428
      rootMargin: '20px',
396
      treshold: 1.0
429
      treshold: 1.0,
397
    }
430
    }
398
    const observer = new IntersectionObserver(handleObserver, options)
431
    const observer = new IntersectionObserver(handleObserver, options)
399
    if (!minimized) {
432
    if (!minimized) {
400
      await handleGetMessages()
433
      await handleGetMessages()
Línea 421... Línea 454...
421
 
454
 
422
  // getMessagesInterval
455
  // getMessagesInterval
423
  useEffect(() => {
456
  useEffect(() => {
424
    if (window.location.pathname === '/group/my-groups') {
457
    if (window.location.pathname === '/group/my-groups') {
-
 
458
      const items = document.getElementsByClassName('sc-jSgupP')
425
      const items = document.getElementsByClassName('sc-jSgupP')
459
      if (items && items.length > 0) {
-
 
460
        items[0].style.display = 'none'
426
      if (items && items.length > 0) { items[0].style.display = 'none' }
461
      }
427
    }
462
    }
Línea 428... Línea 463...
428
  }, [minimized])
463
  }, [minimized])
429
 
464
 
Línea 444... Línea 479...
444
  }, [optionTab])
479
  }, [optionTab])
Línea 445... Línea 480...
445
 
480
 
446
  return (
481
  return (
447
    <>
482
    <>
448
      <div className="personal-chat">
-
 
449
 
483
      <div className="personal-chat">
450
        <div className={`chat-header ${not_seen_messages ? 'notify' : ''}`}>
484
        <div className={`chat-header ${not_seen_messages ? 'notify' : ''}`}>
451
          <img src={image} alt="avatar-image" />
485
          <img src={image} alt="avatar-image" />
452
          <div className="info-content">
486
          <div className="info-content">
-
 
487
            <a href={profile} target="_blank" rel="noreferrer">
-
 
488
              {name}
-
 
489
            </a>
453
            <a href={profile} target="_blank" rel="noreferrer">{name}</a>
490
            {type === 'user' && (
-
 
491
              <small className={online ? 'online' : 'offline'}>
-
 
492
                {online ? 'En línea' : 'Desconectado'}
-
 
493
              </small>
454
            {type === 'user' && <small className={online ? 'online' : 'offline'} >{online ? 'En línea' : 'Desconectado'}</small>}
494
            )}
455
          </div>
495
          </div>
-
 
496
          <div className="options ml-auto">
456
          <div className="options ml-auto">
497
            <i
-
 
498
              className="cursor-pointer fa fa-gear"
-
 
499
              onClick={() =>
457
            <i className="cursor-pointer fa fa-gear"
500
                showOptions(
-
 
501
                  type === 'user' ? OPTIONS.CONFERENCE : OPTIONS.GROUP
-
 
502
                )
-
 
503
              }
-
 
504
            />
458
              onClick={() => showOptions(type === 'user' ? OPTIONS.CONFERENCE : OPTIONS.GROUP)} />
505
            <i
-
 
506
              className={'cursor-pointer fa fa-minus-circle'}
-
 
507
              onClick={handleActive}
-
 
508
            />
459
            <i className={'cursor-pointer fa fa-minus-circle'} onClick={handleActive} />
509
            <i
-
 
510
              className="cursor-pointer fa fa-times-circle"
-
 
511
              onClick={handleCloseChat}
460
            <i className="cursor-pointer fa fa-times-circle" onClick={handleCloseChat} />
512
            />
461
          </div>
513
          </div>
Línea -... Línea 514...
-
 
514
        </div>
-
 
515
 
462
        </div>
516
        <div
463
 
517
          className="panel-body"
464
        <div className="panel-body" style={{ display: !minimized ? 'block' : 'none' }}>
518
          style={{ display: !minimized ? 'block' : 'none' }}
465
 
519
        >
466
          {optionTab
520
          {optionTab ? (
467
            ? <StyledShowOptions>
521
            <StyledShowOptions>
468
              <span className="optionBack" onClick={() => showOptions()}>
522
              <span className="optionBack" onClick={() => showOptions()}>
469
                <i className="fa icon-arrow-left" />
523
                <i className="fa icon-arrow-left" />
470
              </span>
-
 
471
              <div className="optionsTab">
-
 
472
                {tabsOptions[optionTab]}
524
              </span>
-
 
525
              <div className="optionsTab">{tabsOptions[optionTab]}</div>
473
              </div>
526
            </StyledShowOptions>
474
            </StyledShowOptions>
527
          ) : (
475
            : <>
528
            <>
476
              <ChatList
529
              <ChatList
477
                messages={[...oldMessages, ...messages]}
530
                messages={[...oldMessages, ...messages]}
478
                currentPage={currentPage}
531
                currentPage={currentPage}
Línea 485... Línea 538...
485
                isNotSeen={not_seen_messages}
538
                isNotSeen={not_seen_messages}
486
                markRead={() => onRead(entity)}
539
                markRead={() => onRead(entity)}
487
                onSend={sendMessage}
540
                onSend={sendMessage}
488
              />
541
              />
489
            </>
542
            </>
490
          }
543
          )}
491
        </div>
544
        </div>
492
 
-
 
493
      </div>
545
      </div>
494
      <ConfirmModal
546
      <ConfirmModal
495
        show={confirmModalShow}
547
        show={confirmModalShow}
496
        onClose={handleConfirmModalShow}
548
        onClose={handleConfirmModalShow}
497
        onAccept={handleConfirmModalAccept}
549
        onAccept={handleConfirmModalAccept}
Línea 511... Línea 563...
511
 
563
 
512
const StyleModal = ({
564
const StyleModal = ({
513
  title = 'Crea una conferencia',
565
  title = 'Crea una conferencia',
514
  size = 'md',
566
  size = 'md',
515
  show = false,
567
  show = false,
516
  children
568
  children,
517
}) => {
569
}) => {
Línea 518... Línea 570...
518
  const [isShow, setIsShow] = useState(show)
570
  const [isShow, setIsShow] = useState(show)
519
 
571
 
520
  useEffect(() => {
572
  useEffect(() => {
Línea 521... Línea 573...
521
    setIsShow(show)
573
    setIsShow(show)
Línea 522... Línea 574...
522
  }, [show])
574
  }, [show])
523
 
-
 
524
  const closeModal = () => setIsShow(false)
-
 
525
 
-
 
526
  return (
575
 
527
    <Modal
-
 
528
      show={isShow}
576
  const closeModal = () => setIsShow(false)
529
      onHide={closeModal}
577
 
530
      style={{ overflowY: 'scroll' }}
578
  return (
531
    >
-
 
532
      <Modal.Header closeButton>
-
 
533
        <Modal.Title>{title}</Modal.Title>
579
    <Modal show={isShow} onHide={closeModal} style={{ overflowY: 'scroll' }}>
534
      </Modal.Header>
580
      <Modal.Header closeButton>
535
      <Modal.Body>
581
        <Modal.Title>{title}</Modal.Title>
536
        {children}
582
      </Modal.Header>
Línea 537... Línea 583...
537
      </Modal.Body>
583
      <Modal.Body>{children}</Modal.Body>
538
    </Modal>
584
    </Modal>
539
  )
585
  )
540
}
586
}
541
 
587
 
542
export const ConferenceModal = ({
588
export const ConferenceModal = ({
543
  show = false,
589
  show = false,
544
  timezones = {},
590
  timezones = {},
545
  zoomUrl = '',
591
  zoomUrl = '',
546
  onCreate = () => null
592
  onCreate = () => null,
547
}) => {
593
}) => {
548
  const dt = new Date()
594
  const dt = new Date()
549
  const { handleSubmit, register, errors, reset } = useForm({ mode: 'all' })
595
  const { handleSubmit, register, errors, reset } = useForm({ mode: 'all' })
550
  const [date, setDate] = useState({
596
  const [date, setDate] = useState({
-
 
597
    year: dt.toLocaleString('default', { year: 'numeric' }),
-
 
598
    month: dt.toLocaleString('default', { month: '2-digit' }),
-
 
599
    day: dt.toLocaleString('default', { day: '2-digit' }),
-
 
600
  })
-
 
601
  const [time, setTime] = useState(
-
 
602
    dt.toLocaleString('es', {
551
    year: dt.toLocaleString('default', { year: 'numeric' }),
603
      hour: 'numeric',
552
    month: dt.toLocaleString('default', { month: '2-digit' }),
604
      minute: '2-digit',
Línea 553... Línea 605...
553
    day: dt.toLocaleString('default', { day: '2-digit' })
605
      second: '2-digit',
Línea 554... Línea 606...
554
  })
606
    })
555
  const [time, setTime] = useState(dt.toLocaleString('es', { hour: 'numeric', minute: '2-digit', second: '2-digit' }))
607
  )
556
  const [coferenceType, setConferenceType] = useState(1)
608
  const [coferenceType, setConferenceType] = useState(1)
557
  const dispatch = useDispatch()
609
  const dispatch = useDispatch()
558
 
610
 
559
  const handleChange = (value) => setConferenceType(value)
611
  const handleChange = (value) => setConferenceType(value)
560
 
612
 
-
 
613
  const handleDateTime = (value) => {
561
  const handleDateTime = (value) => {
614
    setDate({
-
 
615
      ...date,
-
 
616
      year: new Intl.DateTimeFormat('es', { year: 'numeric' }).format(value),
-
 
617
      month: new Intl.DateTimeFormat('es', { month: '2-digit' }).format(value),
-
 
618
      day: new Intl.DateTimeFormat('es', { day: '2-digit' }).format(value),
-
 
619
    })
562
    setDate({
620
    setTime(
Línea 563... Línea 621...
563
      ...date,
621
      new Intl.DateTimeFormat('es', {
564
      year: new Intl.DateTimeFormat('es', { year: 'numeric' }).format(value),
622
        hour: 'numeric',
565
      month: new Intl.DateTimeFormat('es', { month: '2-digit' }).format(value),
623
        minute: '2-digit',
Línea 566... Línea 624...
566
      day: new Intl.DateTimeFormat('es', { day: '2-digit' }).format(value)
624
        second: 'numeric',
-
 
625
      }).format(value)
-
 
626
    )
567
    })
627
  }
568
    setTime(new Intl.DateTimeFormat('es', { hour: 'numeric', minute: '2-digit', second: 'numeric' }).format(value))
628
 
Línea 569... Línea 629...
569
  }
629
  const onSubmit = async (data) => {
Línea 582... Línea 642...
582
        dispatch(addNotification({ msg: response.data, style: 'danger' }))
642
        dispatch(addNotification({ msg: response.data, style: 'danger' }))
583
        return
643
        return
584
      }
644
      }
Línea 585... Línea 645...
585
 
645
 
586
      if (!response.success && typeof response.data === 'object') {
646
      if (!response.success && typeof response.data === 'object') {
587
        Object.entries(response.data)
647
        Object.entries(response.data).forEach(([key, value]) => {
588
          .forEach(([key, value]) => {
648
          dispatch(
589
            dispatch(addNotification({ msg: `${key}: ${value[0]}`, style: 'danger' }))
649
            addNotification({ msg: `${key}: ${value[0]}`, style: 'danger' })
-
 
650
          )
590
          })
651
        })
591
        return
652
        return
Línea 592... Línea 653...
592
      }
653
      }
593
 
654
 
594
      dispatch(addNotification({ msg: response.data, style: 'success' }))
655
      dispatch(addNotification({ msg: response.data, style: 'success' }))
595
      onCreate()
656
      onCreate()
596
      reset()
657
      reset()
-
 
658
    } catch (error) {
597
    } catch (error) {
659
      console.log(`Error: ${error.message}`)
-
 
660
      return dispatch(
598
      console.log(`Error: ${error.message}`)
661
        addNotification({ msg: 'Ha ocurrido un error', style: 'danger' })
599
      return dispatch(addNotification({ msg: 'Ha ocurrido un error', style: 'danger' }))
662
      )
Línea 600... Línea 663...
600
    }
663
    }
601
  }
664
  }
602
 
665
 
603
  return (
666
  return (
604
    <StyleModal title='Crea una conferencia' show={show}>
667
    <StyleModal title="Crea una conferencia" show={show}>
605
      <form onSubmit={handleSubmit(onSubmit)} autoComplete="new-password">
668
      <form onSubmit={handleSubmit(onSubmit)} autoComplete="new-password">
606
        <div className="form-group">
669
        <div className="form-group">
607
          <label htmlFor="first_name">Título</label>
670
          <label htmlFor="first_name">Título</label>
608
          <input
671
          <input
609
            type="text"
672
            type="text"
610
            name="title"
673
            name="title"
611
            className="form-control"
674
            className="form-control"
-
 
675
            maxLength={128}
612
            maxLength={128}
676
            ref={register({ required: 'Por favor ingrese un título' })}
-
 
677
          />
613
            ref={register({ required: 'Por favor ingrese un título' })}
678
          {errors.title && (
614
          />
679
            <FormErrorFeedback>{errors.title.message}</FormErrorFeedback>
615
          {errors.title && <FormErrorFeedback>{errors.title.message}</FormErrorFeedback>}
680
          )}
616
        </div>
681
        </div>
617
        <div className="form-group">
682
        <div className="form-group">
618
          <label htmlFor="first_name">Descripción</label>
683
          <label htmlFor="first_name">Descripción</label>
619
          <input
684
          <input
620
            type="text"
685
            type="text"
621
            name="description"
686
            name="description"
-
 
687
            className="form-control"
622
            className="form-control"
688
            ref={register({ required: 'Por favor ingrese una descripción' })}
-
 
689
          />
623
            ref={register({ required: 'Por favor ingrese una descripción' })}
690
          {errors.description && (
624
          />
691
            <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>
625
          {errors.description && <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>}
692
          )}
626
        </div>
693
        </div>
627
        <div className="form-group">
694
        <div className="form-group">
628
          <label htmlFor="timezone">Tipo de conferencia</label>
695
          <label htmlFor="timezone">Tipo de conferencia</label>
629
          <select
696
          <select
630
            name="type"
697
            name="type"
631
            className="form-control"
698
            className="form-control"
632
            onChange={({ target }) => handleChange(target.value)}
699
            onChange={({ target }) => handleChange(target.value)}
633
            ref={register}
-
 
634
          >
-
 
635
            <option value='i'>
700
            ref={register}
636
              Inmediata
-
 
637
            </option>
-
 
638
            <option value='s'>
701
          >
639
              Programada
702
            <option value="i">Inmediata</option>
640
            </option>
-
 
641
          </select>
703
            <option value="s">Programada</option>
642
        </div>
704
          </select>
643
        {
705
        </div>
644
          coferenceType === 's' &&
706
        {coferenceType === 's' && (
645
          <div className="form-group">
707
          <div className="form-group">
646
            <label htmlFor="timezone">Horario</label>
708
            <label htmlFor="timezone">Horario</label>
Línea 654... Línea 716...
654
              inputProps={{ className: 'form-control' }}
716
              inputProps={{ className: 'form-control' }}
655
              initialValue={Date.parse(new Date())}
717
              initialValue={Date.parse(new Date())}
656
              closeOnSelect
718
              closeOnSelect
657
            />
719
            />
658
          </div>
720
          </div>
659
        }
721
        )}
660
        <div className="form-group">
722
        <div className="form-group">
661
          <label htmlFor="timezone">Zona horaria</label>
723
          <label htmlFor="timezone">Zona horaria</label>
662
          <select
724
          <select
663
            className="form-control"
725
            className="form-control"
664
            name="timezone"
726
            name="timezone"
Línea 671... Línea 733...
671
              <option value={key} key={key}>
733
              <option value={key} key={key}>
672
                {value}
734
                {value}
673
              </option>
735
              </option>
674
            ))}
736
            ))}
675
          </select>
737
          </select>
-
 
738
          {errors.timezone && (
676
          {errors.timezone && <FormErrorFeedback>{errors.timezone.message}</FormErrorFeedback>}
739
            <FormErrorFeedback>{errors.timezone.message}</FormErrorFeedback>
-
 
740
          )}
677
        </div>
741
        </div>
678
        <div className="form-group">
742
        <div className="form-group">
679
          <label htmlFor="timezone">Duración</label>
743
          <label htmlFor="timezone">Duración</label>
680
          <select
-
 
681
            className="form-control"
744
          <select className="form-control" name="duration" ref={register}>
682
            name="duration"
-
 
683
            ref={register}
-
 
684
          >
-
 
685
            <option value={5}>5-min</option>
745
            <option value={5}>5-min</option>
686
            <option value={10}>10-min</option>
746
            <option value={10}>10-min</option>
687
            <option value={15}>15-min</option>
747
            <option value={15}>15-min</option>
688
            <option value={20}>20-min</option>
748
            <option value={20}>20-min</option>
689
            <option value={25}>25-min</option>
749
            <option value={25}>25-min</option>
Línea 699... Línea 759...
699
            type="password"
759
            type="password"
700
            name="password"
760
            name="password"
701
            className="form-control"
761
            className="form-control"
702
            ref={register({
762
            ref={register({
703
              required: 'Por favor ingrese una contraseña',
763
              required: 'Por favor ingrese una contraseña',
-
 
764
              maxLength: {
-
 
765
                value: 6,
704
              maxLength: { value: 6, message: 'La contraseña debe tener al menos 6 digitos' }
766
                message: 'La contraseña debe tener al menos 6 digitos',
-
 
767
              },
705
            })}
768
            })}
706
          />
769
          />
-
 
770
          {errors.password && (
707
          {errors.password && <FormErrorFeedback>{errors.password.message}</FormErrorFeedback>}
771
            <FormErrorFeedback>{errors.password.message}</FormErrorFeedback>
-
 
772
          )}
708
        </div>
773
        </div>
709
        <button className="btn btn-primary" type="submit">
774
        <button className="btn btn-primary" type="submit">
710
          Crear
775
          Crear
711
        </button>
776
        </button>
712
      </form>
777
      </form>