Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12995 Rev 12996
Línea 7... Línea 7...
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'
11
import DeleteModal from '../../../shared/DeleteModal'
-
 
12
import QuestionModal from '../components/QuestionModal'
Línea 12... Línea 13...
12
 
13
 
13
const sectionTypeOptions = {
14
const sectionTypeOptions = {
14
	open: 'Abierto',
15
	open: 'Abierto',
15
	simple: 'Simple'
16
	simple: 'Simple'
Línea 124... Línea 125...
124
		setIsShowQuestionModal(false)
125
		setIsShowQuestionModal(false)
125
		setQuestionSelected(INITIAL_QUESTION)
126
		setQuestionSelected(INITIAL_QUESTION)
126
	}
127
	}
Línea 127... Línea 128...
127
 
128
 
-
 
129
	const addQuestion = (question) => {
-
 
130
		const uuid = new Date().getTime()
-
 
131
 
-
 
132
		setContent(prev => prev.map(prevSection => {
128
	const addQuestion = (question) => {
133
			if (prevSection.slug_section === sectionSelected.slug_section) {
-
 
134
				return prevSection.questions.push({ ...question, slug_question: `question${uuid}` })
-
 
135
			}
129
		setContent(prev => prev.map(prevSection => prevSection.slug_section === question.slug_section && prev.questions.push(question)))
136
		}))
Línea 130... Línea 137...
130
	}
137
	}
131
 
138
 
132
	const editQuestion = (question) => {
139
	const editQuestion = (question) => {
Línea 283... Línea 290...
283
																									setSectionSelected(section)
290
																									setSectionSelected(section)
284
																								}}>
291
																								}}>
285
																									<i className="fa fa-ban" />
292
																									<i className="fa fa-ban" />
286
																									Borrar Sección
293
																									Borrar Sección
287
																								</button>
294
																								</button>
288
																								<button className="btn btn-default btn-add-question" >
295
																								<button className="btn btn-default btn-add-question" onClick={() => showQuestionModal()}>
289
																									<i className="fa fa-plus" />
296
																									<i className="fa fa-plus" />
290
																									Agregar  Pregunta
297
																									Agregar  Pregunta
291
																								</button>
298
																								</button>
292
																							</td>
299
																							</td>
293
																						</tr>
300
																						</tr>
Línea 300... Línea 307...
300
																									</td>
307
																									</td>
301
																									<td className="text-capitalize">
308
																									<td className="text-capitalize">
302
																										{sectionTypeOptions[question.type]}
309
																										{sectionTypeOptions[question.type]}
303
																									</td>
310
																									</td>
304
																									<td>
311
																									<td>
305
																										<button className="btn btn-default btn-edit-question">
312
																										<button className="btn btn-default btn-edit-question" onClick={() => showQuestionModal(question, 'edit')}>
306
																											<i className="fa fa-edit" /> Editar Pregunta
313
																											<i className="fa fa-edit" /> Editar Pregunta
307
																										</button>
314
																										</button>
308
																										<button className="btn btn-default btn-delete-question">
315
																										<button className="btn btn-default btn-delete-question" onClick={() => {
-
 
316
																											setShowDeleteModal(true)
-
 
317
																											setDeleteType('question')
-
 
318
																											setQuestionSelected(question)
-
 
319
																											setSectionSelected(section)
-
 
320
																										}}>
309
																											<i className="fa fa-ban" /> Borrar Pregunta
321
																											<i className="fa fa-ban" /> Borrar Pregunta
310
																										</button>
322
																										</button>
-
 
323
																										{
-
 
324
																											question.type !== 'open'
-
 
325
																											&&
-
 
326
																											<button className="btn btn-default btn-delete-question">
-
 
327
																												<i className="fa fa-plus" /> Agregar opción
-
 
328
																											</button>
-
 
329
																										}
311
																									</td>
330
																									</td>
312
																								</tr>
331
																								</tr>
313
																							))
332
																							))
314
																						}
333
																						}
315
																					</tbody>
334
																					</tbody>
Línea 341... Línea 360...
341
				sectionType={sectionType}
360
				sectionType={sectionType}
342
				section={sectionSelected}
361
				section={sectionSelected}
343
				closeModal={closeSectionModal}
362
				closeModal={closeSectionModal}
344
				onSubmit={sectionType === 'add' ? addSection : editSection}
363
				onSubmit={sectionType === 'add' ? addSection : editSection}
345
			/>
364
			/>
-
 
365
			<QuestionModal
-
 
366
				show={isShowQuestion}
-
 
367
				questionType={questionType}
-
 
368
				question={questionSelected}
-
 
369
				closeModal={closeQuestionModal}
-
 
370
				onSubmit={questionType === 'add' ? addQuestion : editQuestion}
-
 
371
			/>
346
			<DeleteModal
372
			<DeleteModal
347
				isOpen={showDeleteModal}
373
				isOpen={showDeleteModal}
348
				closeModal={() => setShowDeleteModal(false)}
374
				closeModal={() => setShowDeleteModal(false)}
349
				onComplete={() => deleteHandler(deleteType, sectionSelected.slug_section)}
375
				onComplete={() => deleteHandler(deleteType, sectionSelected.slug_section)}
350
				message="Registro eliminado"
376
				message="Registro eliminado"