Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 12718 | Rev 12729 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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