| Línea 22... |
Línea 22... |
| 22 |
const selectInput2 = useRef(null)
|
22 |
const selectInput2 = useRef(null)
|
| 23 |
const { action } = useParams()
|
23 |
const { action } = useParams()
|
| 24 |
const {
|
24 |
const {
|
| 25 |
setValue,
|
25 |
setValue,
|
| 26 |
register,
|
26 |
register,
|
| 27 |
watch,
|
- |
|
| 28 |
handleSubmit
|
27 |
handleSubmit
|
| 29 |
} = useForm()
|
28 |
} = useForm()
|
| Línea 30... |
Línea 29... |
| 30 |
|
29 |
|
| 31 |
//States
|
30 |
//States
|
| Línea 36... |
Línea 35... |
| 36 |
const [competenciesSelected, setCompetenciesSelected] = useState([])
|
35 |
const [competenciesSelected, setCompetenciesSelected] = useState([])
|
| 37 |
const [competencyTypeOptions, setCompetencyTypeOptions] = useState([])
|
36 |
const [competencyTypeOptions, setCompetencyTypeOptions] = useState([])
|
| 38 |
const [jobsDescription, setJobsDescription] = useState([])
|
37 |
const [jobsDescription, setJobsDescription] = useState([])
|
| 39 |
const [subordinatesSelected, setSubordinatesSelected] = useState([])
|
38 |
const [subordinatesSelected, setSubordinatesSelected] = useState([])
|
| Línea 40... |
Línea 39... |
| 40 |
|
39 |
|
| Línea 41... |
Línea 40... |
| 41 |
const onSubmit = () => {
|
40 |
const onSubmit = (data) => {
|
| 42 |
|
- |
|
| 43 |
const submitData = new FormData()
|
41 |
|
| 44 |
/* const content = []
|
- |
|
| 45 |
jobDescription.competencies.forEach(competency => competency.behaviors.forEach(behavior => {
|
42 |
const submitData = new FormData()
|
| 46 |
content.push({
|
43 |
submitData.append('subordinates_selected', subordinatesSelected)
|
| 47 |
competencyUuid: behavior.competency_uuid,
|
- |
|
| 48 |
behaviorUuid: behavior.uuid,
|
44 |
submitData.append('competencies_selected', competenciesSelected)
|
| 49 |
comment: watch(`${behavior.competency_uuid}-${behavior.uuid}-comment`),
|
- |
|
| 50 |
evaluation: watch(`select-${behavior.competency_uuid}-${behavior.uuid}`)
|
- |
|
| 51 |
})
|
- |
|
| 52 |
}))
|
45 |
submitData.append('name', data.name)
|
| 53 |
|
46 |
submitData.append('job_description_id_boss', data.job_description_id_boss)
|
| 54 |
submitData.append('content', JSON.stringify(content))
|
47 |
submitData.append('status', data.status ? 'a' : 'i')
|
| Línea 55... |
Línea 48... |
| 55 |
submitData.append('points', watch('points')) */
|
48 |
submitData.append('objectives', data.objectives)
|
| 56 |
//.append('comment', watch('comment'))
|
49 |
submitData.append('functions', data.functions)
|
| 57 |
|
50 |
|
| 58 |
axios.post(actionLink, submitData)
|
51 |
axios.post(actionLink, submitData)
|
| Línea 87... |
Línea 80... |
| 87 |
console.log(filterSubordinate)
|
80 |
console.log(filterSubordinate)
|
| 88 |
setSubordinatesSelected([...filterSubordinate])
|
81 |
setSubordinatesSelected([...filterSubordinate])
|
| 89 |
}
|
82 |
}
|
| Línea 90... |
Línea 83... |
| 90 |
|
83 |
|
| 91 |
const deleteCompetency = (id) => {
|
84 |
const deleteCompetency = (id) => {
|
| 92 |
setCompetenciesSelected(competenciesSelected.filter(competency => competency.competency_id !== id))
|
85 |
setCompetenciesSelected(prev => prev.filter(competency => competency.competency_id !== id))
|
| Línea 93... |
Línea 86... |
| 93 |
}
|
86 |
}
|
| 94 |
|
87 |
|
| 95 |
const deleteSubordinate = (id) => {
|
88 |
const deleteSubordinate = (id) => {
|
| Línea 96... |
Línea 89... |
| 96 |
setSubordinatesSelected(subordinatesSelected.filter(subordinate => subordinate.job_description_id !== id))
|
89 |
setSubordinatesSelected(prev => prev.filter(subordinate => subordinate.job_description_id !== id))
|
| 97 |
}
|
90 |
}
|
| 98 |
|
91 |
|
| Línea 218... |
Línea 211... |
| 218 |
</div>
|
211 |
</div>
|
| 219 |
<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
|
212 |
<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
|
| 220 |
<div className="card p-2">
|
213 |
<div className="card p-2">
|
| 221 |
<div className="d-flex justify-content-around">
|
214 |
<div className="d-flex justify-content-around">
|
| 222 |
<div className="col-9">
|
215 |
<div className="col-9">
|
| 223 |
<select className='form-control' name="job_description_id_boss" ref={selectInput}>
|
216 |
<select className='form-control' ref={selectInput}>
|
| 224 |
<option value="">Seleccione</option>
|
217 |
<option value="">Seleccione</option>
|
| 225 |
{
|
218 |
{
|
| 226 |
competencyOptions.map((competency) => {
|
219 |
competencyOptions.map((competency) => {
|
| 227 |
const competency_type = competencyTypeOptions.find(type => type.competency_type_id === competency.competency_type_id)
|
220 |
const competency_type = competencyTypeOptions.find(type => type.competency_type_id === competency.competency_type_id)
|
| Línea 314... |
Línea 307... |
| 314 |
</div>
|
307 |
</div>
|
| 315 |
<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
|
308 |
<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
|
| 316 |
<div className="card p-2">
|
309 |
<div className="card p-2">
|
| 317 |
<div className="d-flex justify-content-around">
|
310 |
<div className="d-flex justify-content-around">
|
| 318 |
<div className="col-9">
|
311 |
<div className="col-9">
|
| 319 |
<select className='form-control' name="job_description_id_boss" ref={selectInput2}>
|
312 |
<select className='form-control' ref={selectInput2}>
|
| 320 |
<option value="">Seleccione</option>
|
313 |
<option value="">Seleccione</option>
|
| 321 |
{
|
314 |
{
|
| 322 |
jobsDescription.map((subordinate) =>
|
315 |
jobsDescription.map((subordinate) =>
|
| 323 |
<option
|
316 |
<option
|
| 324 |
key={subordinate.job_description_id}
|
317 |
key={subordinate.job_description_id}
|