12040 |
stevensc |
1 |
import axios from 'axios'
|
|
|
2 |
import React, { useEffect, useState } from 'react'
|
|
|
3 |
import { useForm } from 'react-hook-form'
|
|
|
4 |
import { useDispatch } from 'react-redux'
|
|
|
5 |
import { addNotification } from '../../../redux/notification/notification.actions'
|
|
|
6 |
import DescriptionInput from '../../../shared/DescriptionInput'
|
12012 |
stevensc |
7 |
|
12040 |
stevensc |
8 |
const EditView = ({ actionLink }) => {
|
|
|
9 |
|
|
|
10 |
const { register, handleSubmit, setValue, watch } = useForm()
|
12047 |
stevensc |
11 |
const [currentJobDescription, setCurretJobDescription] = useState('')
|
|
|
12 |
const [jobDescriptionOptions, setJobDescriptionOptions] = useState([])
|
|
|
13 |
const [status, setStatus] = useState('a')
|
12040 |
stevensc |
14 |
const dispatch = useDispatch()
|
|
|
15 |
|
|
|
16 |
useEffect(() => {
|
|
|
17 |
register('description')
|
|
|
18 |
}, [])
|
|
|
19 |
|
|
|
20 |
useEffect(() => {
|
|
|
21 |
axios.get(actionLink)
|
|
|
22 |
.then(({ data }) => {
|
|
|
23 |
if (!data.success) {
|
|
|
24 |
return dispatch(addNotification({
|
|
|
25 |
style: 'danger',
|
|
|
26 |
msg: 'Ha ocurrido un error'
|
|
|
27 |
}))
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
setValue('name', data.data.name)
|
|
|
31 |
setValue('description', data.data.description)
|
|
|
32 |
setCurretJobDescription(data.data.job_description_id)
|
|
|
33 |
setStatus(data.data.status)
|
|
|
34 |
})
|
|
|
35 |
}, [actionLink])
|
|
|
36 |
|
|
|
37 |
useEffect(() => {
|
|
|
38 |
axios.get(`/settings/jobs-description/edit/${currentJobDescription}`)
|
|
|
39 |
.then(({ data }) => {
|
|
|
40 |
if (!data.success) {
|
|
|
41 |
return dispatch(addNotification({
|
|
|
42 |
style: 'danger',
|
|
|
43 |
msg: 'Ha ocurrido un error'
|
|
|
44 |
}))
|
|
|
45 |
}
|
|
|
46 |
|
12047 |
stevensc |
47 |
setJobDescriptionOptions([...data.data.jobs_description, { job_description_id: data.data.uuid, name: data.data.name }])
|
12040 |
stevensc |
48 |
})
|
|
|
49 |
}, [currentJobDescription])
|
|
|
50 |
|
12012 |
stevensc |
51 |
return (
|
12040 |
stevensc |
52 |
<section className="content">
|
|
|
53 |
<div className="row" style={{ padding: 16 }}>
|
|
|
54 |
<div className="col-xs-12 col-md-12">
|
|
|
55 |
<form onSubmit={handleSubmit}>
|
|
|
56 |
<div className="form-group">
|
|
|
57 |
<label htmlFor="form-name">Nombre</label>
|
|
|
58 |
<input type="text" name="name" ref={register({ required: true, maxLength: 50 })} />
|
|
|
59 |
</div>
|
|
|
60 |
<div className="form-group">
|
|
|
61 |
<label>Cargo a evaluar</label>
|
|
|
62 |
<select name="job_description_id" ref={register({ required: true })} className="form-control select2-hidden-accessible">
|
|
|
63 |
{
|
|
|
64 |
jobDescriptionOptions.map(({ name, job_description_id }) => (
|
|
|
65 |
<option selected={job_description_id === currentJobDescription} key={job_description_id} value={job_description_id}>{name}</option>
|
|
|
66 |
))
|
|
|
67 |
}
|
|
|
68 |
</select>
|
|
|
69 |
</div>
|
|
|
70 |
<div className="form-group">
|
|
|
71 |
<label htmlFor="form-description">Descripción</label>
|
|
|
72 |
<DescriptionInput
|
|
|
73 |
defaultValue={watch('description')}
|
|
|
74 |
name='description'
|
|
|
75 |
onChange={setValue}
|
|
|
76 |
/>
|
|
|
77 |
</div>
|
|
|
78 |
<div className="form-group">
|
|
|
79 |
<label htmlFor="form-status">Estatus</label>
|
|
|
80 |
<select name="form-status" className="form-control">
|
|
|
81 |
<option selected={status === 'i'} value="i">Inactivo</option>
|
|
|
82 |
<option selected={status === 'a'} value="a">Activo</option>
|
|
|
83 |
</select>
|
|
|
84 |
</div>
|
|
|
85 |
<br />
|
|
|
86 |
<div className="row">
|
|
|
87 |
<div className="col-xs-12 col-md-12">
|
|
|
88 |
<div className="panel-group" id="rows" />
|
|
|
89 |
</div>
|
|
|
90 |
</div>
|
|
|
91 |
<div className="form-group" id="competencies-to-job" style={{}}>
|
|
|
92 |
<div className="row">
|
|
|
93 |
<div className="col-xs-12 col-md-12">
|
|
|
94 |
<hr />
|
|
|
95 |
<h4 style={{ fontSize: 18, fontWeight: 'bold' }}>Competencias asociadas al cargo:</h4>
|
|
|
96 |
<br />
|
|
|
97 |
<div className="panel-group" id="rows-job-competencies">
|
|
|
98 |
<div className="panel panel-default" id="panel-46d0f805-03ad-4c06-93c2-2a4ec87f6b97">
|
|
|
99 |
<div className="panel-heading">
|
|
|
100 |
<h4 className="panel-title" style={{ fontSize: 18 }}>
|
|
|
101 |
<a className="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-46d0f805-03ad-4c06-93c2-2a4ec87f6b97" href="#collapse-46d0f805-03ad-4c06-93c2-2a4ec87f6b97">
|
|
|
102 |
<span className="competency-name46d0f805-03ad-4c06-93c2-2a4ec87f6b97">
|
|
|
103 |
Competencias Transversales - Servicio
|
|
|
104 |
</span>
|
|
|
105 |
</a>
|
|
|
106 |
</h4>
|
|
|
107 |
</div>
|
|
|
108 |
<div id="collapse-46d0f805-03ad-4c06-93c2-2a4ec87f6b97" className="panel-collapse in collapse show">
|
|
|
109 |
<div className="panel-body">
|
|
|
110 |
<div className="table-responsive">
|
|
|
111 |
<table className="table table-bordered">
|
|
|
112 |
<thead>
|
|
|
113 |
<tr>
|
|
|
114 |
<th style={{ width: '80%' }}>Conducta Observable</th>
|
|
|
115 |
<th style={{ width: '20%' }}>Nivel</th>
|
|
|
116 |
</tr>
|
|
|
117 |
</thead>
|
|
|
118 |
<tbody>
|
|
|
119 |
<tr>
|
|
|
120 |
<td className="text-left">
|
|
|
121 |
Enfocar sus acciones al logro de los resultados planteados.
|
|
|
122 |
</td>
|
|
|
123 |
<td>
|
|
|
124 |
Uno
|
|
|
125 |
</td>
|
|
|
126 |
</tr>
|
|
|
127 |
</tbody>
|
|
|
128 |
</table>
|
|
|
129 |
</div>
|
|
|
130 |
</div>
|
|
|
131 |
</div>
|
|
|
132 |
</div>
|
|
|
133 |
</div>
|
|
|
134 |
</div>
|
|
|
135 |
</div>
|
|
|
136 |
</div>
|
|
|
137 |
<div className="form-group">
|
|
|
138 |
<button type="button" form="form-main" className="btn btn-info">Guardar & Continuar</button>
|
|
|
139 |
<button type="button" className="btn btn-primary">Guardar & Cerrar</button>
|
|
|
140 |
<button type="button" className="btn btn-secondary">Cancelar</button>
|
|
|
141 |
</div>
|
|
|
142 |
</form>
|
|
|
143 |
</div>
|
|
|
144 |
</div>
|
|
|
145 |
</section>
|
|
|
146 |
|
12012 |
stevensc |
147 |
)
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
export default EditView
|