Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1460 Rev 1929
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React from 'react'
2
import { useDispatch } from 'react-redux'
2
import { useDispatch } from 'react-redux'
3
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
Línea 4... Línea 4...
4
 
4
 
5
import { axios } from '../../utils'
5
import { axios } from '../../utils'
6
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from '../../redux/notification/notification.actions'
Línea 7... Línea 7...
7
import useFetchHelper from '../../hooks/useFetchHelper'
7
import useFetchHelper from '../../hooks/useFetchHelper'
8
 
-
 
9
import Modal from 'components/UI/modal/Modal'
8
 
Línea 10... Línea 9...
10
import Spinner from 'components/UI/Spinner'
9
import Modal from 'components/UI/modal/Modal'
11
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
-
 
12
 
10
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
13
const AddGroupModal = ({ show, onHide, fetchGroups }) => {
11
 
14
  const [loading, setLoading] = useState(false)
12
const AddGroupModal = ({ show, onHide, fetchGroups }) => {
Línea 15... Línea 13...
15
  const { data: groupTypes } = useFetchHelper('group-types')
13
  const { data: groupTypes } = useFetchHelper('group-types')
Línea 16... Línea 14...
16
  const { data: industries } = useFetchHelper('industries')
14
  const { data: industries } = useFetchHelper('industries')
17
  const dispatch = useDispatch()
-
 
18
 
15
  const dispatch = useDispatch()
19
  const { register, handleSubmit, errors, setError } = useForm()
16
 
Línea 20... Línea 17...
20
 
17
  const { register, handleSubmit, errors, setError } = useForm()
21
  const onSubmit = handleSubmit((data) => {
18
 
Línea 49... Línea 46...
49
        onHide()
46
        onHide()
50
      })
47
      })
51
      .catch((err) => {
48
      .catch((err) => {
52
        dispatch(addNotification({ style: 'danger', msg: err.message }))
49
        dispatch(addNotification({ style: 'danger', msg: err.message }))
53
      })
50
      })
54
      .finally(() => setLoading(false))
-
 
55
  })
51
  })
Línea 56... Línea 52...
56
 
52
 
57
  return (
53
  return (
58
    <Modal title='Nuevo Grupo' show={show} onClose={onHide} onAccept={onSubmit}>
54
    <Modal title='Nuevo Grupo' show={show} onClose={onHide} onAccept={onSubmit}>
Línea 114... Línea 110...
114
        </select>
110
        </select>
115
        {errors.industry_id && (
111
        {errors.industry_id && (
116
          <FormErrorFeedback>{errors.industry_id.message}</FormErrorFeedback>
112
          <FormErrorFeedback>{errors.industry_id.message}</FormErrorFeedback>
117
        )}
113
        )}
118
      </div>
114
      </div>
119
 
-
 
120
      {loading && <Spinner />}
-
 
121
    </Modal>
115
    </Modal>
122
  )
116
  )
123
}
117
}
Línea 124... Línea 118...
124
 
118