Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12992 Rev 12993
Línea 6... Línea 6...
6
import { useDispatch } from 'react-redux'
6
import { useDispatch } from 'react-redux'
7
import { useHistory, useParams } from 'react-router-dom'
7
import { useHistory, useParams } from 'react-router-dom'
8
import { addNotification } from '../../../redux/notification/notification.actions'
8
import { addNotification } from '../../../redux/notification/notification.actions'
9
import DescriptionInput from '../../../shared/DescriptionInput'
9
import DescriptionInput from '../../../shared/DescriptionInput'
10
import SectionModal from '../components/SectionModal'
10
import SectionModal from '../components/SectionModal'
-
 
11
import DeleteModal from '../../../shared/DeleteModal'
Línea 11... Línea 12...
11
 
12
 
12
const sectionTypeOptions = {
13
const sectionTypeOptions = {
13
	open: 'Abierto',
14
	open: 'Abierto',
14
	simple: 'Simple'
15
	simple: 'Simple'
Línea 55... Línea 56...
55
	const [questionSelected, setQuestionSelected] = useState(INITIAL_QUESTION)
56
	const [questionSelected, setQuestionSelected] = useState(INITIAL_QUESTION)
56
	const [questionType, setQuestionType] = useState('add')
57
	const [questionType, setQuestionType] = useState('add')
Línea 57... Línea 58...
57
 
58
 
58
	const [content, setContent] = useState([])
59
	const [content, setContent] = useState([])
-
 
60
	const [status, setStatus] = useState('A')
-
 
61
	const [showDeleteModal, setShowDeleteModal] = useState(false)
Línea 59... Línea 62...
59
	const [status, setStatus] = useState('A')
62
	const [deleteType, setDeleteType] = useState('section')
60
 
63
 
61
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
64
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
62
		setIsShowSectionModal(true)
65
		setIsShowSectionModal(true)
Línea 83... Línea 86...
83
			questions: [],
86
			questions: [],
84
			status: 0
87
			status: 0
85
		}])
88
		}])
86
	}
89
	}
Línea -... Línea 90...
-
 
90
 
-
 
91
	const deleteSection = (slug) => {
-
 
92
		setContent(current =>
-
 
93
			current.filter(currentSection => {
-
 
94
				return currentSection.slug_section !== slug
-
 
95
			}),
-
 
96
		)
-
 
97
	}
-
 
98
 
-
 
99
	const deleteHandler = (type, slug) => {
-
 
100
		if (type === 'section') {
-
 
101
			return deleteSection(slug)
-
 
102
		}
-
 
103
	}
87
 
104
 
88
	const editSection = (name, text, slug) => {
105
	const editSection = (name, text, slug) => {
89
		setContent(current =>
106
		setContent(current =>
90
			current.map(currentSection => {
107
			current.map(currentSection => {
91
				if (currentSection.slug_section === slug) {
108
				if (currentSection.slug_section === slug) {
Línea 256... Línea 273...
256
																							<td>
273
																							<td>
257
																								<button className="btn btn-default" onClick={() => showSectionModal(section, 'edit')}>
274
																								<button className="btn btn-default" onClick={() => showSectionModal(section, 'edit')}>
258
																									<i className="fa fa-edit" />
275
																									<i className="fa fa-edit" />
259
																									Editar Sección
276
																									Editar Sección
260
																								</button>
277
																								</button>
261
																								<button className="btn btn-default" >
278
																								<button className="btn btn-default" onClick={()=> {
-
 
279
																									setShowDeleteModal(true)
-
 
280
																									setDeleteType('section')
-
 
281
																								}}>
262
																									<i className="fa fa-ban" />
282
																									<i className="fa fa-ban" />
263
																									Borrar Sección
283
																									Borrar Sección
264
																								</button>
284
																								</button>
265
																								<button className="btn btn-default btn-add-question" >
285
																								<button className="btn btn-default btn-add-question" >
266
																									<i className="fa fa-plus" />
286
																									<i className="fa fa-plus" />
Línea 318... Línea 338...
318
				sectionType={sectionType}
338
				sectionType={sectionType}
319
				section={sectionSelected}
339
				section={sectionSelected}
320
				closeModal={closeSectionModal}
340
				closeModal={closeSectionModal}
321
				onSubmit={sectionType === 'add' ? addSection : editSection}
341
				onSubmit={sectionType === 'add' ? addSection : editSection}
322
			/>
342
			/>
-
 
343
			<DeleteModal
-
 
344
				isOpen={showDeleteModal}
-
 
345
				closeModal={() => setShowDeleteModal(false)}
-
 
346
				onComplete={() => deleteHandler(deleteType, sectionSelected.slug_section)}
-
 
347
				message="Registro eliminado"
-
 
348
			/>
323
		</>
349
		</>
324
	)
350
	)
325
}
351
}
Línea 326... Línea 352...
326
 
352
 
327
export default FormView
353
export default FormView