Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12718 Rev 12726
Línea 1... Línea 1...
1
/* eslint-disable no-mixed-spaces-and-tabs */
1
/* eslint-disable no-mixed-spaces-and-tabs */
2
import React, { useState, useEffect } from 'react'
2
import React, { useState, useEffect } from 'react'
3
import axios from 'axios'
3
import axios from 'axios'
4
import parse from 'html-react-parser'
-
 
5
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
6
import { useDispatch } from 'react-redux'
5
import { useDispatch } from 'react-redux'
7
import { useHistory, useParams } from 'react-router-dom'
6
import { useHistory, useParams } from 'react-router-dom'
8
import { addNotification } from '../../../redux/notification/notification.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
9
import DescriptionInput from '../../../shared/DescriptionInput'
8
import DescriptionInput from '../../../shared/DescriptionInput'
Línea 138... Línea 137...
138
		register('description')
137
		register('description')
139
		register('text')
138
		register('text')
140
	}, [])
139
	}, [])
Línea 141... Línea 140...
141
 
140
 
-
 
141
	useEffect(() => {
142
	useEffect(() => {
142
		if (action === 'edit') {
143
		axios.get(actionLink)
143
			axios.get(actionLink)
144
			.then(({ data }) => {
144
				.then(({ data }) => {
145
				if (!data.success) {
145
					if (!data.success) {
146
					return dispatch(addNotification({
146
						return dispatch(addNotification({
147
						style: 'danger',
147
							style: 'danger',
148
						msg: 'Ha ocurrido un error'
148
							msg: 'Ha ocurrido un error'
149
					}))
149
						}))
150
				}
150
					}
151
 
151
 
152
				setValue('name', data.data.name)
152
					setValue('name', data.data.name)
153
				setValue('description', data.data.description)
153
					setValue('description', data.data.description)
154
				setValue('text', data.data.description)
154
					setValue('text', data.data.description)
155
				setContent(data.data.content)
155
					setContent(data.data.content)
156
				setStatus(data.data.status)
156
					setStatus(data.data.status)
-
 
157
				})
157
			})
158
		}
Línea 158... Línea 159...
158
	}, [actionLink])
159
	}, [actionLink])
159
 
160
 
160
	return (
161
	return (
Línea 167... Línea 168...
167
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
168
							<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
168
						</div>
169
						</div>
169
						<div className="form-group">
170
						<div className="form-group">
170
							<label htmlFor="form-description">Descripción</label>
171
							<label htmlFor="form-description">Descripción</label>
171
							<DescriptionInput
172
							<DescriptionInput
172
								defaultValue={action === 'edit' ? parse(watch('description', '')) : <p></p>}
-
 
173
								name='description'
173
								name='description'
174
								onChange={setValue}
174
								onChange={setValue}
175
							/>
175
							/>
176
						</div>
176
						</div>
177
						<div className="form-group">
177
						<div className="form-group">
178
							<label htmlFor="form-description">Texto</label>
178
							<label htmlFor="form-description">Texto</label>
179
							<DescriptionInput
179
							<DescriptionInput
180
								defaultValue={action === 'edit' ? parse(watch('text', '')) : <p></p>}
-
 
181
								name='text'
180
								name='text'
182
								onChange={setValue}
181
								onChange={setValue}
183
							/>
182
							/>
184
						</div>
183
						</div>
185
						<div className="form-group">
184
						<div className="form-group">