Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 13070 Rev 13071
Línea 317... Línea 317...
317
		if (type === 'option') {
317
		if (type === 'option') {
318
			return deleteOption(slug)
318
			return deleteOption(slug)
319
		}
319
		}
320
	}
320
	}
Línea 321... Línea 321...
321
 
321
 
322
	const onSubmit = () => {
-
 
323
		const submitData = new FormData()
-
 
324
		submitData.append('name', watch('name'))
-
 
325
		submitData.append('description', watch('description'))
-
 
326
		submitData.append('text', watch('text'))
-
 
327
		submitData.append('status', status)
-
 
328
		submitData.append('content', JSON.stringify(content))
-
 
329
 
-
 
330
		axios.post(actionLink, submitData)
322
	const validate = () => {
331
			.then(({ data }) => {
323
		content.map(section => {
332
				if (!data.success) {
-
 
333
					return dispatch(addNotification({
-
 
334
						style: 'danger',
-
 
335
						msg: typeof data.data === 'string'
-
 
336
							? data.data
-
 
337
							: 'Ha ocurrido un error'
-
 
338
					}))
-
 
339
				}
-
 
340
 
324
			if (!section.questions.length) {
341
				dispatch(addNotification({
325
				dispatch(addNotification({
342
					style: 'success',
326
					style: 'success',
343
					msg: data.data
327
					msg: `La sección ${section.name} no tiene preguntas`
-
 
328
				}))
-
 
329
 
-
 
330
				return false
-
 
331
			}
-
 
332
 
-
 
333
			section.questions.forEach(question => {
-
 
334
				if (question.type !== 'open' && question.options.length === 0) {
-
 
335
					dispatch(addNotification({
-
 
336
						style: 'success',
-
 
337
						msg: `La pregunta ${question.name} no tiene preguntas`
-
 
338
					}))
-
 
339
					return false
344
				}))
340
				}
-
 
341
			})
-
 
342
 
-
 
343
			return true
-
 
344
		})
-
 
345
	}
-
 
346
 
-
 
347
	const onSubmit = async () => {
-
 
348
 
-
 
349
		const isValid = await validate()
-
 
350
 
345
			})
351
		console.log(isValid)
Línea 346... Línea 352...
346
	}
352
	}
347
 
353
 
348
	const submitAndClose = () => {
354
	const submitAndClose = () => {
Línea 378... Línea 384...
378
					setValue('text', data.data.description)
384
					setValue('text', data.data.description)
379
				})
385
				})
380
		}
386
		}
381
	}, [actionLink])
387
	}, [actionLink])
Línea 382... Línea -...
382
 
-
 
383
 
388
 
384
	return (
389
	return (
385
		<>
390
		<>
386
			<section className="content">
391
			<section className="content">
387
				<div className="row" style={{ padding: 16 }}>
392
				<div className="row" style={{ padding: 16 }}>
Línea 391... Línea 396...
391
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
396
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
392
						</div>
397
						</div>
393
						<div className="form-group">
398
						<div className="form-group">
394
							<label htmlFor="form-description">Descripción</label>
399
							<label htmlFor="form-description">Descripción</label>
395
							<DescriptionInput
400
							<DescriptionInput
396
								defaultValue={watch('description') ? parse(watch('description')) : ''}
401
								defaultValue={watch('description') && parse(watch('description', ''))}
397
								name='description'
402
								name='description'
398
								onChange={setValue}
403
								onChange={setValue}
399
							/>
404
							/>
400
						</div>
405
						</div>
401
						<div className="form-group">
406
						<div className="form-group">
402
							<label htmlFor="form-description">Texto</label>
407
							<label htmlFor="form-description">Texto</label>
403
							<DescriptionInput
408
							<DescriptionInput
404
								defaultValue={watch('text') ? parse(watch('text')) : ''}
409
								defaultValue={watch('text') && parse(watch('text', ''))}
405
								name='text'
410
								name='text'
406
								onChange={setValue}
411
								onChange={setValue}
407
							/>
412
							/>
408
						</div>
413
						</div>
409
						<div className="form-group">
414
						<div className="form-group">
Línea 443... Línea 448...
443
																					{section.name}
448
																					{section.name}
444
																				</span>
449
																				</span>
445
																			</a>
450
																			</a>
446
																		</h4>
451
																		</h4>
447
																	</div>
452
																	</div>
448
																	<div id="collapse-section1661528423935" className="panel-collapse in collapse show">
453
																	<div id={`collapse-section${section.slug_section}`} className="panel-collapse in collapse show">
449
																		<div className="panel-body">
454
																		<div className="panel-body">
450
																			<div className="table-responsive">
455
																			<div className="table-responsive">
451
																				<table className="table table-bordered">
456
																				<table className="table table-bordered">
452
																					<thead>
457
																					<thead>
453
																						<tr>
458
																						<tr>