| 12709 |
stevensc |
1 |
import React from 'react'
|
|
|
2 |
import parse from 'html-react-parser'
|
|
|
3 |
import { Button, Modal } from 'react-bootstrap'
|
|
|
4 |
import { useForm } from 'react-hook-form'
|
|
|
5 |
import DescriptionInput from '../../../shared/DescriptionInput'
|
|
|
6 |
|
|
|
7 |
const SectionModal = ({ show, closeModal, section, onSubmit }) => {
|
|
|
8 |
|
|
|
9 |
const { handleSubmit, watch, errors, register, setValue } = useForm()
|
|
|
10 |
|
|
|
11 |
return (
|
|
|
12 |
<Modal size="md" onHide={closeModal} show={show}>
|
|
|
13 |
<Modal.Header closeButton>
|
|
|
14 |
<Modal.Title>Nuevo candidato</Modal.Title>
|
|
|
15 |
</Modal.Header>
|
|
|
16 |
<form onSubmit={handleSubmit(onSubmit({ ...section, name: watch('name'), text: watch('text') }))}>
|
|
|
17 |
<Modal.Body>
|
|
|
18 |
<div className='form-group'>
|
|
|
19 |
<label className="form-label">Nombre</label>
|
|
|
20 |
<input type="text" name='name' className='form-control' ref={register({ required: true })} />
|
|
|
21 |
{errors.name && <p>{errors.name.message}</p>}
|
|
|
22 |
</div>
|
|
|
23 |
<div className='form-group'>
|
|
|
24 |
<label className="form-label">Texto</label>
|
|
|
25 |
<DescriptionInput
|
|
|
26 |
defaultValue={parse(watch('description'))}
|
|
|
27 |
name='text'
|
|
|
28 |
onChange={setValue}
|
|
|
29 |
/>
|
|
|
30 |
</div>
|
|
|
31 |
</Modal.Body>
|
|
|
32 |
<Modal.Footer>
|
|
|
33 |
<Button
|
|
|
34 |
variant="primary"
|
|
|
35 |
type='submit'
|
|
|
36 |
>
|
|
|
37 |
Enviar
|
|
|
38 |
</Button>
|
|
|
39 |
<Button variant="danger" onClick={closeModal}>
|
|
|
40 |
Cancelar
|
|
|
41 |
</Button>
|
|
|
42 |
</Modal.Footer>
|
|
|
43 |
</form>
|
|
|
44 |
</Modal >
|
|
|
45 |
)
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
export default SectionModal
|