Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14616 Rev 15066
Línea 1... Línea 1...
1
import axios from 'axios'
1
import axios from 'axios'
2
import React, { useEffect, useState } from 'react'
2
import React, { useEffect, useState } from 'react'
3
import parse from 'html-react-parser'
3
import parse from 'html-react-parser'
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
5
import { useDispatch } from 'react-redux'
5
import { useDispatch } from 'react-redux'
6
import { useHistory } from 'react-router-dom'
6
import { useHistory, useParams } from 'react-router-dom'
7
import { addNotification } from '../../../redux/notification/notification.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import DescriptionInput from '../../../shared/DescriptionInput'
8
import DescriptionInput from '../../../shared/DescriptionInput'
Línea 9... Línea 9...
9
 
9
 
10
const levelOptions = {
10
const levelOptions = {
Línea 14... Línea 14...
14
	'3': 'Tres',
14
	'3': 'Tres',
15
	'4': 'Cuatro',
15
	'4': 'Cuatro',
16
	'5': 'Cinco'
16
	'5': 'Cinco'
17
}
17
}
Línea 18... Línea 18...
18
 
18
 
Línea 19... Línea 19...
19
const EditView = ({ actionLink }) => {
19
const EditView = ({ actionLink, jobsDescription }) => {
20
 
20
 
21
	// Hooks
21
	// Hooks
22
	const history = useHistory()
22
	const history = useHistory()
-
 
23
	const { register, setValue, watch, reset } = useForm()
Línea 23... Línea 24...
23
	const { register, setValue, watch, reset } = useForm()
24
	const dispatch = useDispatch()
24
	const dispatch = useDispatch()
25
	const { action } = useParams()
25
 
26
 
26
	// State
27
	// State
27
	const [currentJobDescription, setCurretJobDescription] = useState('')
28
	const [currentJobDescription, setCurretJobDescription] = useState('')
28
	const [jobDescriptionOptions, setJobDescriptionOptions] = useState([])
29
	const [jobDescriptionOptions, setJobDescriptionOptions] = useState(jobsDescription)
Línea 29... Línea 30...
29
	const [competencyTypes, setCompetencyTypes] = useState([])
30
	const [competencyTypes, setCompetencyTypes] = useState([])
30
	const [competenciesSelected, setCompetenciesSelected] = useState([])
-
 
31
	const [status, setStatus] = useState('a')
31
	const [competenciesSelected, setCompetenciesSelected] = useState([])
32
 
32
	const [status, setStatus] = useState('a')
33
	const onSubmit = () => {
33
 
34
 
34
	const onSubmit = () => {
35
		const submitData = new FormData()
35
		const submitData = new FormData()
Línea 75... Línea 75...
75
	useEffect(() => {
75
	useEffect(() => {
76
		register('description')
76
		register('description')
77
	}, [])
77
	}, [])
Línea 78... Línea 78...
78
 
78
 
-
 
79
	useEffect(() => {
79
	useEffect(() => {
80
		if (action === 'edit') {
80
		axios.get(actionLink)
81
			axios.get(actionLink)
81
			.then(({ data }) => {
82
				.then(({ data }) => {
82
				if (!data.success) {
83
					if (!data.success) {
83
					return dispatch(addNotification({
84
						return dispatch(addNotification({
84
						style: 'danger',
85
							style: 'danger',
85
						msg: 'Ha ocurrido un error'
86
							msg: 'Ha ocurrido un error'
86
					}))
87
						}))
Línea 87... Línea 88...
87
				}
88
					}
88
 
89
 
89
				setValue('name', data.data.name)
90
					setValue('name', data.data.name)
90
				setValue('description', data.data.description)
91
					setValue('description', data.data.description)
91
				setCurretJobDescription(data.data.job_description_id)
92
					setCurretJobDescription(data.data.job_description_id)
-
 
93
					setStatus(data.data.status)
92
				setStatus(data.data.status)
94
				})
Línea 93... Línea 95...
93
			})
95
		}
94
	}, [actionLink])
96
	}, [actionLink])
95
 
97
 
Línea 118... Línea 120...
118
						<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
120
						<input type="text" name="name" className='form-control' ref={register({ required: true, maxLength: 50 })} />
119
					</div>
121
					</div>
120
					<div className="form-group">
122
					<div className="form-group">
121
						<label>Cargo a evaluar</label>
123
						<label>Cargo a evaluar</label>
122
						<select name="job_description_id" className="form-control" onChange={(e) => setCurretJobDescription(e.target.value)}>
124
						<select name="job_description_id" className="form-control" onChange={(e) => setCurretJobDescription(e.target.value)}>
-
 
125
							<option value=''>Seleccione</option>
123
							{
126
							{
124
								jobDescriptionOptions.map(({ name, job_description_id }) => (
127
								jobDescriptionOptions.map(({ name, job_description_id }) => (
125
									<option selected={job_description_id === currentJobDescription} key={job_description_id} value={job_description_id}>{name}</option>
128
									<option key={job_description_id} value={job_description_id}>{name}</option>
126
								))
129
								))
127
							}
130
							}
128
						</select>
131
						</select>
129
					</div>
132
					</div>
130
					<div className="form-group">
133
					<div className="form-group">