Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 13068 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
13068 stevensc 1
import React, { useEffect } 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 OptionModal = ({ show, closeModal, option, onSubmit, optionType }) => {
7
 
8
	const { register, setValue, watch } = useForm()
9
 
10
	useEffect(() => {
11
		register('text')
12
	}, [option])
13
 
14
	const submit = (e) => {
15
		e.preventDefault()
16
 
17
		onSubmit({ ...option, text: watch('text') })
18
		closeModal()
19
 
20
	}
21
 
22
	return (
23
		<Modal size="md" onHide={closeModal} show={show}>
24
			<Modal.Header closeButton>
13071 stevensc 25
				<Modal.Title>{`${optionType === 'add' ? 'Agregar' : 'Editar'} opciónF`}</Modal.Title>
13068 stevensc 26
			</Modal.Header>
27
			<form onSubmit={submit}>
28
				<Modal.Body>
29
					<div className='form-group'>
30
						<label className="form-label">Texto</label>
31
						<DescriptionInput
32
							defaultValue={option.text}
33
							name='text'
34
							onChange={setValue}
35
						/>
36
					</div>
37
				</Modal.Body>
38
				<Modal.Footer>
39
					<Button variant="primary" type='submit'>
40
						Enviar
41
					</Button>
42
					<Button variant="danger" onClick={closeModal}>
43
						Cancelar
44
					</Button>
45
				</Modal.Footer>
46
			</form>
47
		</Modal >
48
	)
49
}
50
 
51
export default OptionModal