Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1979 Rev 2092
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
2
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
3
import { connect, useSelector } from 'react-redux'
3
import { connect, useSelector } from 'react-redux'
Línea 4... Línea 4...
4
 
4
 
5
import { axios } from '../../utils'
5
import { axios } from '@app/utils'
Línea 6... Línea 6...
6
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from '@app/redux/notification/notification.actions'
7
 
7
 
Línea 8... Línea 8...
8
import FormErrorFeedback from '../UI/form/FormErrorFeedback'
8
import Modal from '../UI/modal/Modal'
9
import Modal from 'components/UI/modal/Modal'
9
import Input from '../UI/inputs/Input'
10
 
10
 
11
const AddProfileModal = ({
11
const AddProfileModal = ({
12
  show = '',
12
  show = '',
13
  onHide = () => null,
13
  onHide = () => null,
14
  getProfiles = () => null,
14
  getProfiles = () => null,
-
 
15
  addNotification // redux action
15
  addNotification // redux action
16
}) => {
Línea 16... Línea 17...
16
}) => {
17
  const labels = useSelector(({ intl }) => intl.labels)
17
  const labels = useSelector(({ intl }) => intl.labels)
18
 
18
  const { register, handleSubmit, errors } = useForm()
19
  const { register, handleSubmit, errors } = useForm()
Línea 38... Línea 39...
38
        getProfiles()
39
        getProfiles()
39
        addNotification({ style: 'success', msg: data })
40
        addNotification({ style: 'success', msg: data })
40
        onHide()
41
        onHide()
41
      })
42
      })
42
      .catch((err) => {
43
      .catch((err) => {
43
        console.log(err)
-
 
44
        throw new Error(err)
44
        addNotification({ style: 'danger', msg: err.message })
45
      })
45
      })
46
  })
46
  })
Línea 47... Línea 47...
47
 
47
 
48
  return (
48
  return (
49
    <Modal
49
    <Modal
50
      title={labels.new_profile}
50
      title={labels.new_profile}
51
      show={show}
51
      show={show}
52
      onHide={onHide}
52
      onHide={onHide}
53
      onAccept={onSubmitHandler}
53
      onAccept={onSubmitHandler}
54
      onClose={onHide}
-
 
55
      onReject={onHide}
54
      onClose={onHide}
56
    >
55
    >
57
      <input
-
 
58
        type='text'
56
      <Input
59
        name='name'
57
        name='name'
60
        placeholder={labels.profile_name}
58
        placeholder={labels.profile_name}
-
 
59
        inputRef={register({ required: 'Este campo es requerido' })}
61
        ref={register({ required: 'Este campo es requerido' })}
60
        error={errors.name?.message}
62
      />
-
 
63
      {errors.name && (
-
 
64
        <FormErrorFeedback>{errors.name.message}</FormErrorFeedback>
-
 
65
      )}
61
      />
66
    </Modal>
62
    </Modal>
67
  )
63
  )
Línea 68... Línea 64...
68
}
64
}