Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2109 Rev 2801
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 { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
Línea 4... Línea 4...
4
 
4
 
-
 
5
import { block_options, reasons } from '@app/constants/report'
5
import { block_options, reasons } from '@app/constants/report'
6
import { sendReport } from '@app/services/reports'
6
import { addNotification } from '@app/redux/notification/notification.actions'
7
import { addNotification } from '@app/redux/notification/notification.actions'
7
import { closeReportModal } from '@app/redux/report/report.actions'
-
 
Línea 8... Línea 8...
8
import { sendReport } from '@app/services/reports'
8
import { closeReportModal } from '@app/redux/report/report.actions'
9
 
9
 
10
import Modal from '../UI/modal/Modal'
10
import Modal from '@components/UI/modal/Modal'
Línea 11... Línea 11...
11
import Input from '../UI/inputs/Input'
11
import Input from '@components/UI/inputs/Input'
12
import Select from '../UI/inputs/Select'
12
import Select from '@components/UI/inputs/Select'
13
 
13
 
14
export default function ReportModal() {
14
export default function ReportModal() {
15
  const { showModal, type, reportUrl, onComplete } = useSelector(
15
  const { showModal, type, reportUrl, onComplete } = useSelector(
Línea -... Línea 16...
-
 
16
    (state) => state.report
-
 
17
  )
-
 
18
  const dispatch = useDispatch()
-
 
19
 
16
    (state) => state.report
20
  const {
-
 
21
    control,
17
  )
22
    getValues,
18
  const dispatch = useDispatch()
23
    handleSubmit,
19
 
24
    formState: { isSubmitting, errors }
20
  const { register, errors, control, getValues, handleSubmit } = useForm({
25
  } = useForm({
21
    defaultValues: {
26
    defaultValues: {
Línea 51... Línea 56...
51
    <Modal
56
    <Modal
52
      show={showModal}
57
      show={showModal}
53
      onClose={closeModal}
58
      onClose={closeModal}
54
      title={`Reportar ${type.toLowerCase()}`}
59
      title={`Reportar ${type.toLowerCase()}`}
55
      onAccept={onSubmit}
60
      onAccept={onSubmit}
-
 
61
      loading={isSubmitting}
56
    >
62
    >
57
      <Select
63
      <Select
58
        name='reason'
-
 
59
        label='Motivo'
64
        label='Motivo'
60
        options={reasons}
65
        name='reason'
61
        placeholder='Seleccione un motivo'
66
        placeholder='Seleccione un motivo'
-
 
67
        options={reasons}
62
        control={control}
68
        control={control}
63
        rules={{ required: 'Este campo es requerido' }}
69
        rules={{ required: 'Este campo es requerido' }}
64
        error={errors.reason?.message}
70
        error={errors.reason?.message}
65
        defaultValue={reasons[0].value}
71
        defaultValue={reasons[0].value}
66
      />
72
      />
Línea 78... Línea 84...
78
 
84
 
79
      <Input
85
      <Input
80
        name='comment'
86
        name='comment'
81
        label='Comentario'
87
        label='Comentario'
82
        placeholder='(Opcional)'
88
        placeholder='(Opcional)'
83
        inputRef={register}
89
        control={control}
84
        error={errors.comment?.message}
90
        error={errors.comment?.message}
85
      />
91
      />
86
    </Modal>
92
    </Modal>
87
  )
93
  )