Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 14389 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 14389 Rev 14843
Línea 80... Línea 80...
80
		section: sectionSelected.slug_section,
80
		section: sectionSelected.slug_section,
81
		question: questionSelected.slug_question,
81
		question: questionSelected.slug_question,
82
		option: optionSelected.slug_option
82
		option: optionSelected.slug_option
83
	}
83
	}
Línea 84... Línea 84...
84
 
84
 
85
	const [text,setText] = useState((action != 'edit')? ' ' :'')
85
	const [text, setText] = useState((action != 'edit') ? ' ' : '')
Línea 86... Línea 86...
86
	const [description,setDescription] = useState((action != 'edit')? ' ' :'')
86
	const [description, setDescription] = useState((action != 'edit') ? ' ' : '')
87
 
87
 
88
	// Section methods
88
	// Section methods
89
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
89
	const showSectionModal = (section = INITIAL_SECTION, type = 'add') => {
Línea 330... Línea 330...
330
				style: 'danger',
330
				style: 'danger',
331
				msg: `La sección ${sectionError.name} no tiene preguntas`
331
				msg: `La sección ${sectionError.name} no tiene preguntas`
332
			}))
332
			}))
Línea 333... Línea 333...
333
 
333
 
334
			return false
334
			return false
335
		}else{
335
		} else {
336
			return true
336
			return true
337
		}
337
		}
Línea 338... Línea 338...
338
	}
338
	}
Línea 350... Línea 350...
350
			submitData.append('content', JSON.stringify(content))
350
			submitData.append('content', JSON.stringify(content))
Línea 351... Línea 351...
351
 
351
 
352
			axios.post(actionLink, submitData)
352
			axios.post(actionLink, submitData)
353
				.then(({ data }) => {
353
				.then(({ data }) => {
-
 
354
					if (!data.success) {
-
 
355
						typeof data.data === 'string'
354
					if (!data.success) {
356
							?
355
						return dispatch(addNotification({
357
							dispatch(addNotification({
356
							style: 'danger',
358
								style: 'danger',
-
 
359
								msg: data.data
-
 
360
							}))
357
							msg: typeof data.data === 'string'
361
							: Object.entries(data.data).map(([key, value]) =>
-
 
362
								value.map(err =>
-
 
363
									dispatch(addNotification({
358
								? data.data
364
										style: 'danger',
-
 
365
										msg: `${key}: ${err}`
359
								: 'Ha ocurrido un error'
366
									}))
-
 
367
								)
-
 
368
							)
360
						}))
369
						return
Línea 361... Línea 370...
361
					}
370
					}
362
 
371
 
363
					dispatch(addNotification({
372
					dispatch(addNotification({
Línea 375... Línea 384...
375
	}
384
	}
Línea 376... Línea 385...
376
 
385
 
377
	useEffect(() => {
386
	useEffect(() => {
378
		register('text')
387
		register('text')
379
		register('description')
388
		register('description')
380
		
389
 
Línea 381... Línea 390...
381
	}, [])
390
	}, [])
382
 
391
 
383
	useEffect(() => {
392
	useEffect(() => {
Línea 416... Línea 425...
416
							<label>Nombre</label>
425
							<label>Nombre</label>
417
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
426
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
418
						</div>
427
						</div>
419
						<div className="form-group">
428
						<div className="form-group">
420
							<label htmlFor="form-description">Descripción</label>
429
							<label htmlFor="form-description">Descripción</label>
421
							{(description) && 
430
							{(description) &&
422
							<DescriptionInput
431
								<DescriptionInput
423
								defaultValue={description}
432
									defaultValue={description}
424
								name="description"
433
									name="description"
425
								onChange={setValue}
434
									onChange={setValue}
426
							/>}
435
								/>}
427
							
436
 
428
						</div>
437
						</div>
429
						<div className="form-group">
438
						<div className="form-group">
430
							<label htmlFor="form-description">Texto</label>
439
							<label htmlFor="form-description">Texto</label>
431
							{(text) && 
440
							{(text) &&
432
							<DescriptionInput
441
								<DescriptionInput
433
								defaultValue={text}
442
									defaultValue={text}
434
								name="text"
443
									name="text"
435
								onChange={setValue}
444
									onChange={setValue}
436
							/>}
445
								/>}
437
						</div>
446
						</div>
438
						<div className="form-group">
447
						<div className="form-group">
439
							<label htmlFor="form-status">Estatus</label>
448
							<label htmlFor="form-status">Estatus</label>
440
							<select name="form-status" className="form-control" onChange={(e) => setStatus(e.target.value)} value={status}>
449
							<select name="form-status" className="form-control" onChange={(e) => setStatus(e.target.value)} value={status}>
441
								<option value="A">Activo</option>
450
								<option value="A">Activo</option>
Línea 600... Línea 609...
600
									</div>
609
									</div>
601
								</div>
610
								</div>
602
							</div>
611
							</div>
603
						</div>
612
						</div>
604
						<div className="d-flex" style={{ gap: '5px' }}>
613
						<div className="d-flex" style={{ gap: '5px' }}>
605
							{(action === 'edit')? <button type="button" className="btn btn-info" onClick={onSubmit}>Guardar & Continuar</button>:<></> }
614
							{(action === 'edit') ? <button type="button" className="btn btn-info" onClick={onSubmit}>Guardar & Continuar</button> : <></>}
606
							<button type="button" className="btn btn-primary" onClick={submitAndClose}>Guardar & Cerrar</button>
615
							<button type="button" className="btn btn-primary" onClick={submitAndClose}>Guardar & Cerrar</button>
607
							<button type="button" className="btn btn-secondary" onClick={() => history.goBack()}>Cancelar</button>
616
							<button type="button" className="btn btn-secondary" onClick={() => history.goBack()}>Cancelar</button>
608
						</div>
617
						</div>
609
					</div>
618
					</div>
610
				</div >
619
				</div >