Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 655 Rev 1217
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
2
import { axios } from '../../utils'
-
 
3
import { Modal } from 'react-bootstrap'
-
 
4
import { useForm } from 'react-hook-form'
-
 
5
import { useDispatch } from 'react-redux'
2
import { useDispatch } from 'react-redux'
-
 
3
import { useForm } from 'react-hook-form'
-
 
4
 
-
 
5
import { axios } from '../../utils'
6
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from '../../redux/notification/notification.actions'
Línea -... Línea 7...
-
 
7
 
7
 
8
import Modal from 'components/UI/Modal'
Línea 8... Línea 9...
8
import FormErrorFeedback from '../UI/FormErrorFeedback'
9
import FormErrorFeedback from 'components/UI/FormErrorFeedback'
9
 
10
 
10
const CreateGroupModal = ({ isOpen, onClose }) => {
11
const CreateGroupModal = ({ isOpen, onClose }) => {
Línea 11... Línea 12...
11
  const { register, handleSubmit, errors } = useForm()
12
  const { register, handleSubmit, errors } = useForm()
12
  const dispatch = useDispatch()
13
  const dispatch = useDispatch()
13
 
14
 
14
  const onSubmitHandler = async (data) => {
15
  const onSubmitHandler = handleSubmit(async (data) => {
15
    const formData = new FormData()
16
    const formData = new FormData()
16
    Object.entries(data).map(([key, value]) => formData.append(key, value))
17
    Object.entries(data).map(([key, value]) => formData.append(key, value))
Línea 32... Línea 33...
32
        onClose()
33
        onClose()
33
      })
34
      })
34
      .catch((err) => {
35
      .catch((err) => {
35
        dispatch(addNotification({ style: 'danger', message: err.message }))
36
        dispatch(addNotification({ style: 'danger', message: err.message }))
36
      })
37
      })
37
  }
38
  })
Línea 38... Línea 39...
38
 
39
 
39
  return (
40
  return (
40
    <Modal show={isOpen} onHide={onClose}>
41
    <Modal
41
      <Modal.Header closeButton>
42
      title='Crear grupo'
42
        <Modal.Title>Crear grupo</Modal.Title>
43
      show={isOpen}
43
      </Modal.Header>
44
      onClose={onClose}
44
      <Modal.Body>
45
      onReject={onClose}
-
 
46
      onAccept={onSubmitHandler}
45
        <form onSubmit={handleSubmit(onSubmitHandler)}>
47
    >
46
          <label className='mb-1' htmlFor='name'>
48
      <label className='mb-1' htmlFor='name'>
47
            Nombre del grupo
49
        Nombre del grupo
48
          </label>
50
      </label>
49
          <input
51
      <input
50
            type='text'
52
        type='text'
51
            name='name'
53
        name='name'
52
            id='name'
54
        id='name'
53
            ref={register({ required: 'Este campo es requerido' })}
55
        ref={register({ required: 'Este campo es requerido' })}
54
          />
56
      />
55
          {errors.name && (
57
      {errors.name && (
56
            <FormErrorFeedback>{errors.name.message}</FormErrorFeedback>
58
        <FormErrorFeedback>{errors.name.message}</FormErrorFeedback>
57
          )}
-
 
58
          <div className='mt-3 d-flex gap-3'>
-
 
59
            <button className='btn btn-primary' type='submit'>
-
 
60
              Enviar
-
 
61
            </button>
-
 
62
            <button className='btn btn-secondary' onClick={onClose}>
-
 
63
              Cancelar
-
 
64
            </button>
-
 
65
          </div>
-
 
66
        </form>
-
 
67
      </Modal.Body>
59
      )}
68
    </Modal>
60
    </Modal>
69
  )
61
  )
Línea 70... Línea 62...
70
}
62
}