Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 5 Rev 1229
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
2
import { axios } from '../../utils'
-
 
3
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
4
import { Button, Modal } from 'react-bootstrap'
-
 
5
import { addNotification } from '../../redux/notification/notification.actions'
-
 
6
import { connect, useSelector } from 'react-redux'
3
import { connect, useSelector } from 'react-redux'
Línea -... Línea 4...
-
 
4
 
-
 
5
import { axios } from '../../utils'
-
 
6
import { addNotification } from '../../redux/notification/notification.actions'
7
 
7
 
-
 
8
import FormErrorFeedback from '../UI/FormErrorFeedback'
Línea 8... Línea 9...
8
import FormErrorFeedback from '../UI/FormErrorFeedback'
9
import Modal from 'components/UI/Modal'
9
 
10
 
10
const AddProfileModal = ({
11
const AddProfileModal = ({
11
  show = '',
12
  show = '',
12
  onHide = () => null,
13
  onHide = () => null,
13
  getProfiles = () => null,
14
  getProfiles = () => null,
14
  addNotification, // redux action
15
  addNotification // redux action
15
}) => {
16
}) => {
Línea 16... Línea 17...
16
  const labels = useSelector(({ intl }) => intl.labels)
17
  const labels = useSelector(({ intl }) => intl.labels)
17
  const { register, handleSubmit, errors } = useForm()
18
  const { register, handleSubmit, errors } = useForm()
18
 
19
 
Línea 19... Línea 20...
19
  const onSubmitHandler = async (data) => {
20
  const onSubmitHandler = handleSubmit(async (data) => {
20
    const formData = new FormData()
21
    const formData = new FormData()
Línea 40... Línea 41...
40
      })
41
      })
41
      .catch((err) => {
42
      .catch((err) => {
42
        console.log(err)
43
        console.log(err)
43
        throw new Error(err)
44
        throw new Error(err)
44
      })
45
      })
45
  }
46
  })
Línea 46... Línea 47...
46
 
47
 
47
  return (
-
 
48
    <Modal show={show} onHide={onHide}>
48
  return (
49
      <Modal.Header closeButton>
-
 
50
        <Modal.Title id="contained-modal-title-vcenter">
49
    <Modal
51
          {labels.new_profile}
50
      title={labels.new_profile}
52
        </Modal.Title>
51
      show={show}
53
      </Modal.Header>
52
      onHide={onHide}
54
      <form onSubmit={handleSubmit(onSubmitHandler)}>
53
      onAccept={onSubmitHandler}
-
 
54
      onClose={onHide}
-
 
55
      onReject={onHide}
55
        <Modal.Body>
56
    >
56
          <input
57
      <input
57
            type="text"
58
        type='text'
58
            name="name"
59
        name='name'
59
            placeholder={labels.profile_name}
60
        placeholder={labels.profile_name}
60
            ref={register({ required: 'Este campo es requerido' })}
61
        ref={register({ required: 'Este campo es requerido' })}
61
          />
62
      />
62
          {errors.name && (
63
      {errors.name && (
63
            <FormErrorFeedback>{errors.name.message}</FormErrorFeedback>
64
        <FormErrorFeedback>{errors.name.message}</FormErrorFeedback>
64
          )}
-
 
65
        </Modal.Body>
-
 
66
        <Modal.Footer>
-
 
67
          <Button type="submit">{labels.create_profile}</Button>
-
 
68
          <Button onClick={onHide} variant="danger">
-
 
69
            {labels.cancel}
-
 
70
          </Button>
-
 
71
        </Modal.Footer>
-
 
72
      </form>
65
      )}
73
    </Modal>
66
    </Modal>
74
  )
67
  )
Línea 75... Línea 68...
75
}
68
}
76
 
69
 
77
const mapDispatchToProps = {
70
const mapDispatchToProps = {
Línea 78... Línea 71...
78
  addNotification: (notification) => addNotification(notification),
71
  addNotification: (notification) => addNotification(notification)