Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12800 Rev 12836
Línea 1... Línea 1...
1
import React, { useEffect } from 'react'
1
import React, { useEffect } from 'react'
2
import { Button, Modal } from 'react-bootstrap'
2
import { Button, Modal } from 'react-bootstrap'
3
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
4
import DescriptionInput from '../../../shared/DescriptionInput'
4
import DescriptionInput from '../../../shared/DescriptionInput'
Línea 5... Línea 5...
5
 
5
 
Línea 6... Línea 6...
6
const SectionModal = ({ show, closeModal, section, onSubmit }) => {
6
const SectionModal = ({ show, closeModal, section, onSubmit, type }) => {
7
 
-
 
Línea 8... Línea 7...
8
	const { handleSubmit, errors, register, setValue } = useForm()
7
 
-
 
8
	const { handleSubmit, errors, register, setValue } = useForm()
9
	const uuid = Math.random() * (9999999999999 - 1000000000000) + 1
9
 
-
 
10
	useEffect(() => {
10
 
11
		register('text')
Línea 11... Línea 12...
11
	useEffect(() => {
12
		setValue('name', section.name)
12
		setValue('name', section.name)
-
 
13
	}, [section])
-
 
14
 
13
		setValue('text', section.text)
15
	const submit = (data) => {
-
 
16
		onSubmit({
14
	}, [section])
17
			...section,
-
 
18
			name: data.name,
15
 
19
			text: data.text,
16
	const submit = (data) => {
Línea 20... Línea 17...
20
			slug_section: section.slug_section ? section.slug_section : `section${parseInt(uuid)}`
17
		type === 'add' && onSubmit({ name: data.name, text: data.text })
21
		})
18
		type === 'edit' && onSubmit({ name: data.name, text: data.text, slug: section.slug_section })
22
		closeModal()
19
		closeModal()
23
	}
20
	}
24
 
21
 
25
	return (
22
	return (
26
		<Modal size="md" onHide={closeModal} show={show}>
23
		<Modal size="md" onHide={closeModal} show={show}>
27
			<Modal.Header closeButton>
24
			<Modal.Header closeButton>
28
				<Modal.Title>Nuevo candidato</Modal.Title>
25
				<Modal.Title></Modal.Title>