Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14197 Rev 14205
Línea 24... Línea 24...
24
	const history = useHistory()
24
	const history = useHistory()
25
	const { action } = useParams()
25
	const { action } = useParams()
26
	const { setValue, register, watch, handleSubmit } = useForm()
26
	const { setValue, register, watch, handleSubmit } = useForm()
Línea 27... Línea 27...
27
 
27
 
-
 
28
	//States
28
	//States
29
	const [data, setData] = useState({})
Línea 29... Línea 30...
29
	const [jobDescription, setJobDescription] = useState({})
30
	const [supervisers, setSupervisers] = useState([])
Línea -... Línea 31...
-
 
31
 
30
 
32
	const onSubmit = () => {
31
	const onSubmit = () => {
33
 
32
 
34
		const submitData = new FormData() 
33
		const content = []
35
		/* 		const content = []
34
		jobDescription.competencies.forEach(competency => competency.behaviors.forEach(behavior => {
36
		jobDescription.competencies.forEach(competency => competency.behaviors.forEach(behavior => {
35
			content.push({
37
			content.push({
36
				competencyUuid: behavior.competency_uuid,
38
				competencyUuid: behavior.competency_uuid,
37
				behaviorUuid: behavior.uuid,
39
				behaviorUuid: behavior.uuid,
38
				comment: watch(`${behavior.competency_uuid}-${behavior.uuid}-comment`),
40
				comment: watch(`${behavior.competency_uuid}-${behavior.uuid}-comment`),
Línea 39... Línea -...
39
				evaluation: watch(`select-${behavior.competency_uuid}-${behavior.uuid}`)
-
 
40
			})
41
				evaluation: watch(`select-${behavior.competency_uuid}-${behavior.uuid}`)
41
		}))
42
			})
42
 
43
		}))
Línea 43... Línea 44...
43
		const submitData = new FormData()
44
 
44
		submitData.append('content', JSON.stringify(content))
45
		submitData.append('content', JSON.stringify(content))
45
		submitData.append('points', watch('points'))
46
		submitData.append('points', watch('points')) */
46
		submitData.append('comment', watch('comment'))
47
		//.append('comment', watch('comment'))
Línea 66... Línea 67...
66
	}
67
	}
Línea 67... Línea 68...
67
 
68
 
68
	useEffect(() => {
69
	useEffect(() => {
69
		axios.get(actionLink)
70
		axios.get(actionLink)
70
			.then(({ data }) => {
-
 
71
				const resData = data.data
-
 
72
 
71
			.then(({ data }) => {
73
				if (!data.success) {
72
				if (!data.success) {
74
					return dispatch(addNotification({
73
					return dispatch(addNotification({
75
						style: 'danger',
74
						style: 'danger',
76
						msg: 'Ha ocurrido un error'
75
						msg: 'Ha ocurrido un error'
77
					}))
76
					}))
Línea 78... Línea 77...
78
				}
77
				}
79
 
-
 
80
				setJobDescription(resData.job_description)
-
 
81
 
78
 
82
				if (action === 'both') {
-
 
83
					setValue('comment', resData.both.comment)
-
 
84
					setValue('points', resData.both.points)
-
 
85
				}
-
 
86
 
-
 
87
				if (action === 'self') {
79
				setSupervisers(data.data['supervisers'].map(option => ({ [option.uuid]: option.name })))
88
					setValue('comment', resData.self.comment)
-
 
Línea 89... Línea -...
89
					setValue('points', resData.self.points)
-
 
90
				}
-
 
91
 
-
 
92
				if (action === 'superviser') {
-
 
93
					setValue('comment', resData.superviser.comment)
-
 
94
					setValue('points', resData.superviser.points)
-
 
95
				}
-
 
96
 
-
 
97
				resData.jobDescription.competencies.behaviors.forEach((obj) => {
-
 
98
					setValue(`select-${obj.competency_uuid}-${obj.uuid}`, obj.evaluation)
80
				setValue('name', data.data['name'])
99
					setValue(`${obj.competency_uuid}-${obj.uuid}-comment`, obj.comment)
81
				setValue('job_description_id_boss', data.data['job_description_id_boss'])
Línea 100... Línea 82...
100
				})
82
 
101
			})
83
			})
Línea 123... Línea 105...
123
								</div>
105
								</div>
124
								<div className="card-body">
106
								<div className="card-body">
125
									<div className="tab-content" id="myTabContent">
107
									<div className="tab-content" id="myTabContent">
126
										<div className="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
108
										<div className="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
127
											<div className="card">
109
											<div className="card">
128
												<div className="card-body">
110
												<div className="row">
129
													<h5>{jobDescription.name}</h5>
-
 
130
													<h6>Funciones</h6>
111
													<div className="col-4">
131
													<p>{jobDescription.functions}</p>
112
														<div className="form-group">
132
													<h6>Objetivos</h6>
113
															<label>Nombre</label>
133
													<p>{jobDescription.objectives}</p>
-
 
134
												</div>
-
 
135
											</div>
-
 
136
										</div>
-
 
137
										<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
-
 
138
											{
-
 
139
												jobDescription.competencies?.length > 0
-
 
140
												&&
-
 
141
												jobDescription.competencies.map((competency) => (
-
 
142
													<div className="card" key={competency.competency_uuid}>
-
 
143
														<div className="card-header">
114
															<input type="text" name='name' ref={register} />
144
															<h5>{competency.competency_name} - {competency.competency_type_name}</h5>
-
 
145
														</div>
115
														</div>
-
 
116
													</div>
146
														<div className="card-body">
117
													<div className="col-4">
147
															<div className="table-responsive">
118
														<div className="form-group">
-
 
119
															<label>Nombre</label>
-
 
120
															<select name="job_description_id_boss" ref={register}>
-
 
121
																<option value="">No aplica</option>
148
																{
122
																{
149
																	competency.behaviors
-
 
150
																	&&
-
 
151
																	competency.behaviors.map((behavior) => (
123
																	supervisers.map(({ key, value }) =>
152
																		<table key={behavior.uuid} className="table table-hover">
124
																		<option key={value} value={value}>{key}</option>
153
																			<thead>
-
 
154
																				<tr>
-
 
155
																					<th style={{ width: '20%' }}>Conducta Observable</th>
-
 
156
																					<th style={{ width: '60%' }}>Comentario</th>
-
 
157
																					<th style={{ width: '20%' }}>Evaluación</th>
-
 
158
																				</tr>
-
 
159
																			</thead>
-
 
160
																			<tbody>
-
 
161
																				<tr>
-
 
162
																					<td style={{ width: '20%' }}>{behavior.description}</td>
-
 
163
																					<td style={{ width: '60%' }}>
-
 
164
																						<textarea
-
 
165
																							name={`${behavior.competency_uuid}-${behavior.uuid}-comment`}
-
 
166
																							cols="30"
-
 
167
																							rows="3"
-
 
168
																							ref={register}
-
 
169
																							className='form-control w100'
-
 
170
																						/>
-
 
171
																					</td>
-
 
172
																					<td style={{ width: '20%' }}>
-
 
173
																						<select className='form-control' name={`select-${behavior.competency_uuid}-${behavior.uuid}`} ref={register}>
-
 
174
																							{
-
 
175
																								pointsOptions.map(({ label, value }) => {
-
 
176
																									return <option selected={watch(`select-${behavior.competency_uuid}-${behavior.uuid}`) === value} key={value} value={value}>{label}</option>
-
 
177
																								})
-
 
178
																							}
-
 
179
																						</select>
-
 
180
																					</td>
-
 
181
																				</tr>
-
 
182
																			</tbody>
-
 
183
																		</table>
-
 
184
																	))
125
																	)
185
																}
126
																}
186
															</div>
127
															</select>
187
														</div>
128
														</div>
188
													</div>
129
													</div>
189
												))
130
												</div>
190
											}
131
											</div>
-
 
132
										</div>
-
 
133
										<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
-
 
134
											
191
										</div>
135
										</div>
192
										<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
136
										<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
193
											<div className="form-group">
-
 
194
												<label>Comentario</label>
-
 
195
												<input type="text" name="comment" className="form-control" ref={register} />
-
 
196
											</div>
-
 
197
											<div className="form-group">
-
 
198
												<label>Evaluación</label>
-
 
199
												<select className='form-control' name='points' ref={register}>
-
 
200
													{
137
											
201
														pointsOptions.map(({ label, value }) => (
-
 
202
															<option selected={watch('points') === value} key={value} value={value}>{label}</option>
-
 
203
														))
-
 
204
													}
-
 
205
												</select>
-
 
206
											</div>
-
 
207
										</div>
138
										</div>
208
									</div>
139
									</div>
209
									<div className="form-group">
140
									<div className="form-group">
210
										<button type="submit" className="btn btn-primary btn-form-save-close mr-2">
141
										<button type="submit" className="btn btn-primary btn-form-save-close mr-2">
211
											Guardar & Cerrar
142
											Guardar & Cerrar