Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 13077 Rev 13078
Línea 320... Línea 320...
320
		}
320
		}
321
	}
321
	}
Línea 322... Línea 322...
322
 
322
 
323
	const validate = () => {
323
	const validate = () => {
324
		const sectionError = content.find(section => !section.questions.length)
-
 
Línea 325... Línea 324...
325
		let questionsToOptions = []
324
		const sectionError = content.find(section => !section.questions.length)
326
 
325
 
327
		if (sectionError) {
326
		if (sectionError) {
328
			dispatch(addNotification({
327
			dispatch(addNotification({
329
				style: 'danger',
328
				style: 'danger',
Línea 330... Línea 329...
330
				msg: `La sección ${sectionError.name} no tiene preguntas`
329
				msg: `La sección ${sectionError.name} no tiene preguntas`
331
			}))
330
			}))
332
 
-
 
333
			return false
-
 
334
		}
-
 
335
 
-
 
336
		content.forEach(section => section.questions.map(question => {
-
 
337
			if (question.type !== 'open') {
-
 
338
				questionsToOptions = [...questionsToOptions, question]
-
 
339
				console.log(questionsToOptions)
-
 
340
			}
-
 
341
		}))
331
 
Línea 342... Línea 332...
342
 
332
			return false
Línea 343... Línea 333...
343
 
333
		}
Línea 344... Línea 334...
344
	}
334
	}
-
 
335
 
-
 
336
	const onSubmit = () => {
-
 
337
 
-
 
338
		const isValid = validate()
-
 
339
 
-
 
340
		if (isValid) {
-
 
341
			const submitData = new FormData()
-
 
342
			submitData.append('name', watch('name'))
-
 
343
			submitData.append('description', watch('description'))
-
 
344
			submitData.append('text', watch('text'))
-
 
345
			submitData.append('status', status)
-
 
346
			submitData.append('content', JSON.stringify(content))
-
 
347
 
-
 
348
			axios.post(actionLink, submitData)
-
 
349
				.then(({ data }) => {
-
 
350
					if (!data.success) {
-
 
351
						return dispatch(addNotification({
-
 
352
							style: 'danger',
-
 
353
							msg: typeof data.data === 'string'
-
 
354
								? data.data
-
 
355
								: 'Ha ocurrido un error'
-
 
356
						}))
-
 
357
					}
-
 
358
 
345
 
359
					dispatch(addNotification({
Línea 346... Línea 360...
346
	const onSubmit = async () => {
360
						style: 'success',
347
 
361
						msg: data.data
348
		const isValid = await validate()
362
					}))