Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1437 Rev 1456
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { Button, Modal } from 'react-bootstrap'
2
import { useLocation } from 'react-router-dom'
-
 
3
import { useDispatch } from 'react-redux'
3
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
4
import { CKEditor } from 'ckeditor4-react'
5
import { CKEditor } from 'ckeditor4-react'
5
import { useDispatch } from 'react-redux'
-
 
6
import { addNotification } from '../../redux/notification/notification.actions'
-
 
-
 
6
 
7
import { axios, CKEDITOR_OPTIONS } from '../../utils'
7
import { axios, CKEDITOR_OPTIONS } from '../../utils'
-
 
8
import { addNotification } from '../../redux/notification/notification.actions'
Línea 8... Línea 9...
8
 
9
 
9
import Spinner from '../UI/Spinner'
10
import Spinner from 'components/UI/Spinner'
10
import FormErrorFeedback from '../UI/form/FormErrorFeedback'
11
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
Línea 11... Línea 12...
11
import { useLocation } from 'react-router-dom'
12
import Modal from 'components/UI/modal/Modal'
12
 
13
 
13
const OverviewModal = ({
14
const OverviewModal = ({
14
  isOpen = false,
15
  isOpen = false,
Línea 21... Línea 22...
21
  const { pathname } = useLocation()
22
  const { pathname } = useLocation()
22
  const dispatch = useDispatch()
23
  const dispatch = useDispatch()
Línea 23... Línea 24...
23
 
24
 
Línea 24... Línea -...
24
  const { register, errors, handleSubmit, setValue } = useForm()
-
 
25
 
-
 
26
  useEffect(() => {
-
 
27
    register('description', { required: 'Este campo es requerido' })
-
 
28
  }, [])
25
  const { register, errors, handleSubmit, setValue } = useForm()
29
 
26
 
30
  const onSubmitHandler = ({ description }) => {
27
  const onSubmit = handleSubmit(({ description }) => {
31
    const typesUrl = {
28
    const typesUrl = {
32
      profile: `/profile/my-profiles/extended/${id}`,
29
      profile: `/profile/my-profiles/extended/${id}`,
33
      group: `/group/my-groups/extended/${id}`
30
      group: `/group/my-groups/extended/${id}`
Línea 58... Línea 55...
58
      })
55
      })
59
      .catch((err) => {
56
      .catch((err) => {
60
        dispatch(addNotification({ style: 'danger', msg: err.message }))
57
        dispatch(addNotification({ style: 'danger', msg: err.message }))
61
      })
58
      })
62
      .finally(() => setLoading(false))
59
      .finally(() => setLoading(false))
63
  }
60
  })
Línea 64... Línea 61...
64
 
61
 
65
  const removeModalTabIndex = () => {
62
  const removeModalTabIndex = () => {
66
    const modal = document.querySelector('.fade.modal.show')
63
    const modal = document.querySelector('.fade.modal.show')
67
    modal.removeAttribute('tabindex')
64
    modal.removeAttribute('tabindex')
Línea -... Línea 65...
-
 
65
  }
-
 
66
 
-
 
67
  useEffect(() => {
-
 
68
    register('description', { required: 'Este campo es requerido' })
68
  }
69
  }, [])
69
 
-
 
70
  return (
70
 
71
    <Modal show={isOpen} onHide={closeModal}>
71
  return (
72
      <Modal.Header closeButton>
72
    <Modal
73
        <Modal.Title>Visión general</Modal.Title>
-
 
74
      </Modal.Header>
73
      title='Visión general'
75
      <form onSubmit={handleSubmit(onSubmitHandler)} autoComplete={false}>
74
      show={isOpen}
-
 
75
      onClose={closeModal}
76
        <Modal.Body>
76
      onAccept={onSubmit}
77
          {loading && <Spinner />}
77
    >
78
          <CKEditor
78
      <CKEditor
79
            onChange={(e) => setValue('description', e.editor.getData())}
79
        onChange={(e) => setValue('description', e.editor.getData())}
80
            onInstanceReady={(e) => e.editor.setData(overview)}
80
        onInstanceReady={(e) => e.editor.setData(overview)}
81
            config={CKEDITOR_OPTIONS}
81
        config={CKEDITOR_OPTIONS}
82
            onDialogShow={removeModalTabIndex}
82
        onDialogShow={removeModalTabIndex}
83
          />
83
      />
84
          {errors.description && (
84
      {errors.description && (
85
            <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>
-
 
86
          )}
-
 
87
        </Modal.Body>
-
 
88
        <Modal.Footer>
-
 
89
          <Button size='sm' type='submit'>
-
 
90
            Enviar
-
 
91
          </Button>
-
 
92
          <Button size='sm' variant='danger' onClick={closeModal}>
-
 
93
            Cancelar
85
        <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>
94
          </Button>
-
 
95
        </Modal.Footer>
86
      )}
96
      </form>
87
      {loading && <Spinner />}
97
    </Modal>
88
    </Modal>
Línea 98... Línea 89...
98
  )
89
  )