Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1929 stevensc 1
import React from 'react'
1455 stevensc 2
import { connect } from 'react-redux'
3
import { useForm } from 'react-hook-form'
4
 
3084 stevensc 5
import { addNotification } from '@store/notification/notification.actions'
5 stevensc 6
 
3084 stevensc 7
import Modal from '@components/UI/modal/Modal'
8
import Select from '@components/UI/inputs/Select'
5 stevensc 9
 
10
const ApplyModal = ({
11
  show,
3085 stevensc 12
  profiles,
13
  onConfirm,
14
  onClose = function () {}
5 stevensc 15
}) => {
2802 stevensc 16
  const {
3084 stevensc 17
    control,
3085 stevensc 18
    formState: { errors, isSubmitting },
19
    handleSubmit
2802 stevensc 20
  } = useForm()
1979 stevensc 21
 
3085 stevensc 22
  const onSubmit = handleSubmit((data) => onConfirm(data))
1979 stevensc 23
 
5 stevensc 24
  return (
25
    <Modal
1455 stevensc 26
      title='Perfil de Applicación'
5 stevensc 27
      show={show}
3085 stevensc 28
      onClose={onClose}
1455 stevensc 29
      onAccept={onSubmit}
3085 stevensc 30
      loading={isSubmitting}
5 stevensc 31
    >
3084 stevensc 32
      <Select
33
        name='user_profile_id'
34
        control={control}
35
        rules={{ required: 'Por favor seleccione un perfil' }}
3085 stevensc 36
        error={errors?.user_profile_id?.message}
37
        options={Object.entries(profiles).map(([value, name]) => ({
3084 stevensc 38
          name,
39
          value
40
        }))}
41
      />
5 stevensc 42
    </Modal>
43
  )
44
}
45
 
46
const mapDispatchToProps = {
1437 stevensc 47
  addNotification: (notification) => addNotification(notification)
5 stevensc 48
}
49
 
50
export default connect(null, mapDispatchToProps)(ApplyModal)