Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 10845 Rev 10852
Línea 21... Línea 21...
21
		name: '',
21
		name: '',
22
		description: '',
22
		description: '',
23
		functions: '',
23
		functions: '',
24
		objectives: ''
24
		objectives: ''
25
	})
25
	})
-
 
26
	const [candidatesOptions, setCandidatesOptions] = useState([])
-
 
27
	const [competencies, setCompetencies] = useState([])
26
	const [pointsOptions, setPointsOptions] = useState([
28
	const [pointsOptions, setPointsOptions] = useState([
27
		{ label: 'Evaluación', value: null },
29
		{ label: 'Evaluación', value: null },
28
		{ label: 'Sugerir otro cargo', value: 0 },
30
		{ label: 'Sugerir otro cargo', value: 0 },
29
		{ label: '25%', value: 1 },
31
		{ label: '25%', value: 1 },
30
		{ label: '50%', value: 2 },
32
		{ label: '50%', value: 2 },
Línea 34... Línea 36...
34
	const [statusOptions, setStatusOptions] = useState([
36
	const [statusOptions, setStatusOptions] = useState([
35
		{ label: 'Estatus', value: '' },
37
		{ label: 'Estatus', value: '' },
36
		{ label: 'Aceptado', value: 'a' },
38
		{ label: 'Aceptado', value: 'a' },
37
		{ label: 'Rechazado', value: 'r' }
39
		{ label: 'Rechazado', value: 'r' }
38
	])
40
	])
39
	const [candidatesOptions, setCandidatesOptions] = useState([
-
 
40
		{ label: 'Estatus', value: '' },
-
 
41
		{ label: 'Aceptado', value: 'a' },
-
 
42
		{ label: 'Rechazado', value: 'r' }
-
 
43
	])
-
 
44
	const [competencies, setCompetencies] = useState([])
-
 
Línea 45... Línea 41...
45
 
41
 
46
	// Hooks
42
	// Hooks
47
	const { setValue, register, watch } = useForm()
43
	const { setValue, register, watch, handleSubmit } = useForm()
48
	const history = useHistory()
44
	const history = useHistory()
49
	const dispatch = useDispatch()
45
	const dispatch = useDispatch()
Línea -... Línea 46...
-
 
46
	const { action } = useParams()
-
 
47
 
-
 
48
	const onSubmit = () => {
-
 
49
 
-
 
50
		const content = competencies.behaviors.map(behavior => {
-
 
51
			return {
-
 
52
				competencyUuid: behavior.competency_uuid,
-
 
53
				behaviorUuid: behavior.uuid,
-
 
54
				comment: watch(`${behavior.competency_uuid}_${behavior.uuid}-comment`),
-
 
55
				evaluation: watch(`${behavior.competency_uuid}_${behavior.uuid}-points`)
-
 
56
			}
-
 
57
		})
-
 
58
 
-
 
59
		const submitData = new FormData()
-
 
60
		submitData.append('content', content)
-
 
61
		submitData.append('candidate_uuid', watch('candidate'))
-
 
62
		submitData.append('points', watch('points'))
-
 
63
		submitData.append('comment', watch('comment'))
-
 
64
		submitData.append('status', watch('status'))
-
 
65
 
-
 
66
		console.log(content)
-
 
67
		console.log(submitData)
-
 
68
		console.log(actionLink)
50
	const { action } = useParams()
69
	}
51
 
70
 
52
	useEffect(() => {
71
	useEffect(() => {
53
		if (action === 'edit') {
72
		if (action === 'edit') {
54
			axios.get(actionLink)
73
			axios.get(actionLink)
Línea 130... Línea 149...
130
	return (
149
	return (
131
		<section className="content">
150
		<section className="content">
132
			<div className="container-fluid">
151
			<div className="container-fluid">
133
				<div className="row">
152
				<div className="row">
134
					<div className="col-12">
153
					<div className="col-12">
-
 
154
						<form onSubmit={handleSubmit(onSubmit)}>
135
						<div className='card'>
155
							<div className='card'>
136
							<div className="card-header">
156
								<div className="card-header">
137
								<ul className="nav nav-tabs" id="myTab" role="tablist">
157
									<ul className="nav nav-tabs" id="myTab" role="tablist">
138
									<li className="nav-item" role="presentation">
158
										<li className="nav-item" role="presentation">
139
										<button className="nav-link active" id="home-tab" data-toggle="tab" data-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">General</button>
159
											<button className="nav-link active" id="home-tab" data-toggle="tab" data-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">General</button>
140
									</li>
160
										</li>
141
									<li className="nav-item" role="presentation">
161
										<li className="nav-item" role="presentation">
142
										<button className="nav-link" id="profile-tab" data-toggle="tab" data-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Competencias</button>
162
											<button className="nav-link" id="profile-tab" data-toggle="tab" data-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Competencias</button>
143
									</li>
163
										</li>
144
									<li className="nav-item" role="presentation">
164
										<li className="nav-item" role="presentation">
145
										<button className="nav-link" id="contact-tab" data-toggle="tab" data-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Conclusiones</button>
165
											<button className="nav-link" id="contact-tab" data-toggle="tab" data-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Conclusiones</button>
146
									</li>
166
										</li>
147
								</ul>
167
									</ul>
148
							</div>
168
								</div>
149
							<div className="card-body">
169
								<div className="card-body">
150
								<div className="tab-content" id="myTabContent">
170
									<div className="tab-content" id="myTabContent">
151
									<div className="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
171
										<div className="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
152
										<div className="row p-3 justify-content-between">
172
											<div className="row p-3 justify-content-between">
153
											<div className="col-6">
173
												<div className="col-6">
154
												<div className="form-group">
174
													<div className="form-group">
155
													<label>Vacantes</label>
175
														<label>Vacantes</label>
156
													<select className='form-control' name='points' ref={register} disabled={action === 'edit'} onChange={(e) => setVacancyUrl(vacancy_link.replace('UUID_PLACEHOLDER', e.target.value))}>
176
														<select className='form-control' name='vacancy' ref={register} disabled={action === 'edit'} onChange={(e) => setVacancyUrl(vacancy_link.replace('UUID_PLACEHOLDER', e.target.value))}>
157
														{
177
															{
158
															vacancyOptions.map(({ name, uuid }) => (
178
																vacancyOptions.map(({ name, uuid }) => (
159
																<option selected={generalOptions.name === name} key={uuid} value={uuid}>{name}</option>
179
																	<option selected={generalOptions.name === name} key={uuid} value={uuid}>{name}</option>
160
															))
180
																))
161
														}
181
															}
162
													</select>
182
														</select>
-
 
183
													</div>
163
												</div>
184
												</div>
164
											</div>
-
 
165
											<div className="col-6">
185
												<div className="col-6">
166
												<div className="form-group">
186
													<div className="form-group">
167
													<label>Candidatos</label>
187
														<label>Candidatos</label>
168
													<select className='form-control' name='points' ref={register} disabled={action === 'edit'} onChange={(e) => setTypeOptions(prev => ({ ...prev, url: type_link.replace('UUID_PLACEHOLDER', e.target.value) }))}>
188
														<select className='form-control' name='candidate' ref={register} disabled={action === 'edit'} onChange={(e) => setTypeOptions(prev => ({ ...prev, url: type_link.replace('UUID_PLACEHOLDER', e.target.value) }))}>
169
														{
189
															{
170
															candidatesOptions.map(({ first_name, last_name, uuid }) => (
190
																candidatesOptions.map(({ first_name, last_name, uuid }) => (
171
																<option selected={watch('candidate') === uuid} key={uuid} value={uuid}>{`${first_name} ${last_name}`}</option>
191
																	<option selected={watch('candidate') === uuid} key={uuid} value={uuid}>{`${first_name} ${last_name}`}</option>
172
															))
192
																))
173
														}
193
															}
174
													</select>
194
														</select>
-
 
195
													</div>
175
												</div>
196
												</div>
176
											</div>
197
											</div>
177
										</div>
198
											<h5>{typeOptions.value}</h5>
178
										<div className="card">
199
											<div className="card">
179
											<h5>{typeOptions.value === 'r' ? 'Recursos Humanos' : 'Potencial superior'}</h5>
-
 
180
											<div className="card-body">
200
												<div className="card-body">
181
												<h5>{generalOptions.name}</h5>
201
													<h5>{generalOptions.name}</h5>
182
												<p>{generalOptions.description}</p>
202
													<p>{generalOptions.description}</p>
183
												<h6>Funciones</h6>
203
													<h6>Funciones</h6>
184
												<p>{generalOptions.functions}</p>
204
													<p>{generalOptions.functions}</p>
185
												<h6>Objetivos</h6>
205
													<h6>Objetivos</h6>
186
												<p>{generalOptions.objectives}</p>
206
													<p>{generalOptions.objectives}</p>
-
 
207
												</div>
187
											</div>
208
											</div>
188
										</div>
209
										</div>
189
									</div>
-
 
190
									<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
210
										<div className="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
191
										{
211
											{
192
											competencies.map((competency) => (
212
												competencies.map((competency) => (
193
												<div className="card" key={competency.competency_uuid}>
213
													<div className="card" key={competency.competency_uuid}>
194
													<div className="card-header">
214
														<div className="card-header">
195
														<h5>{competency.competency_name} - {competency.competency_type_name}</h5>
215
															<h5>{competency.competency_name} - {competency.competency_type_name}</h5>
-
 
216
														</div>
-
 
217
														<div className="card-body">
-
 
218
															{
-
 
219
																competency.behaviors
-
 
220
																&&
-
 
221
																competency.behaviors.map((behavior) => (
-
 
222
																	<table key={behavior.uuid} className="table table-hover">
-
 
223
																		<thead>
-
 
224
																			<tr>
-
 
225
																				<th style={{ width: '20%' }}>Conducta Observable</th>
-
 
226
																				<th style={{ width: '60%' }}>Comentario</th>
-
 
227
																				<th style={{ width: '20%' }}>Evaluación</th>
-
 
228
																			</tr>
-
 
229
																		</thead>
-
 
230
																		<tbody>
-
 
231
																			<tr>
-
 
232
																				<td style={{ width: '20%' }}>{behavior.description}</td>
-
 
233
																				<td style={{ width: '60%' }}>
-
 
234
																					<textarea
-
 
235
																						name={`${behavior.competency_uuid}_${behavior.uuid}-comment`}
-
 
236
																						cols="30"
-
 
237
																						rows="3"
-
 
238
																						ref={register}
-
 
239
																						className='form-control w100'
-
 
240
																					/>
-
 
241
																				</td>
-
 
242
																				<td style={{ width: '20%' }}>
-
 
243
																					<select className='form-control' name={`${behavior.competency_uuid}_${behavior.uuid}-points`} ref={register}>
-
 
244
																						{
-
 
245
																							pointsOptions.map(({ label, value }) => (
-
 
246
																								<option selected={behavior.points === value} key={value} value={value}>{label}</option>
-
 
247
																							))
-
 
248
																						}
-
 
249
																					</select>
-
 
250
																				</td>
-
 
251
																			</tr>
-
 
252
																		</tbody>
-
 
253
																	</table>
-
 
254
																))
-
 
255
															}
-
 
256
														</div>
196
													</div>
257
													</div>
197
													<div className="card-body">
-
 
198
														{
-
 
199
															competency.behaviors
-
 
200
															&&
-
 
201
															competency.behaviors.map((behavior) => (
-
 
202
																<table key={behavior.uuid} className="table table-hover">
-
 
203
																	<thead>
-
 
204
																		<tr>
-
 
205
																			<th style={{ width: '20%' }}>Conducta Observable</th>
-
 
206
																			<th style={{ width: '60%' }}>Comentario</th>
-
 
207
																			<th style={{ width: '20%' }}>Evaluación</th>
-
 
208
																		</tr>
-
 
209
																	</thead>
-
 
210
																	<tbody>
-
 
211
																		<tr>
-
 
212
																			<td style={{ width: '20%' }}>{behavior.description}</td>
-
 
213
																			<td style={{ width: '60%' }}>
-
 
214
																				<textarea
-
 
215
																					name={`${behavior.competency_uuid}_${behavior.uuid}-name`}
-
 
216
																					cols="30"
-
 
217
																					rows="3"
-
 
218
																					ref={register}
-
 
219
																					className='form-control w100'
-
 
220
																				/>
-
 
221
																			</td>
-
 
222
																			<td style={{ width: '20%' }}>
-
 
223
																				<select className='form-control' name={`${behavior.competency_uuid}_${behavior.uuid}-points`} ref={register}>
-
 
224
																					{
-
 
225
																						pointsOptions.map(({ label, value }) => (
-
 
226
																							<option selected={behavior.points === value} key={value} value={value}>{label}</option>
-
 
227
																						))
-
 
228
																					}
-
 
229
																				</select>
-
 
230
																			</td>
-
 
231
																		</tr>
-
 
232
																	</tbody>
-
 
233
																</table>
-
 
234
															))
-
 
235
														}
-
 
236
													</div>
-
 
237
												</div>
-
 
238
											))
258
												))
239
										}
259
											}
240
									</div>
-
 
241
									<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
-
 
242
										<div className="form-group">
-
 
243
											<label>Comentario</label>
-
 
244
											<input type="text" name="comment" className="form-control" ref={register} />
-
 
245
										</div>
260
										</div>
-
 
261
										<div className="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
246
										<div className="form-group">
262
											<div className="form-group">
-
 
263
												<label>Comentario</label>
-
 
264
												<input type="text" name="comment" className="form-control" ref={register} />
-
 
265
											</div>
-
 
266
											<div className="form-group">
247
											<label>Evaluación</label>
267
												<label>Evaluación</label>
248
											<select className='form-control' name='points' ref={register} defaultValue={pointsOptions[0].value}>
268
												<select className='form-control' name='points' ref={register} defaultValue={pointsOptions[0].value}>
249
												{
269
													{
250
													pointsOptions.map(({ label, value }) => (
270
														pointsOptions.map(({ label, value }) => (
251
														<option selected={watch('points') === value} key={value} value={value}>{label}</option>
271
															<option selected={watch('points') === value} key={value} value={value}>{label}</option>
252
													))
272
														))
253
												}
273
													}
254
											</select>
274
												</select>
255
										</div>
275
											</div>
256
										<div className="form-group">
276
											<div className="form-group">
257
											<label>Estatus</label>
277
												<label>Estatus</label>
258
											<select className='form-control' name='status' ref={register} defaultValue={statusOptions[0].value}>
278
												<select className='form-control' name='status' ref={register} defaultValue={statusOptions[0].value}>
259
												{
279
													{
260
													statusOptions.map(({ label, value }) => (
280
														statusOptions.map(({ label, value }) => (
261
														<option selected={watch('status') === value} key={value} value={value}>{label}</option>
281
															<option selected={watch('status') === value} key={value} value={value}>{label}</option>
262
													))
282
														))
263
												}
283
													}
264
											</select>
284
												</select>
-
 
285
											</div>
265
										</div>
286
										</div>
266
									</div>
287
									</div>
267
								</div>
-
 
268
								<div className="form-group">
288
									<div className="form-group">
269
									<button type="submit" className="btn btn-primary btn-form-save-close mr-2">
289
										<button type="submit" className="btn btn-primary btn-form-save-close mr-2">
270
										Guardar
290
											Guardar
271
									</button>
291
										</button>
272
									<button
292
										<button
273
										type="button"
293
											type="button"
274
										className="btn btn-secondary btn-edit-cancel"
294
											className="btn btn-secondary btn-edit-cancel"
275
										onClick={() => history.goBack()}
295
											onClick={() => history.goBack()}
276
									>
296
										>
277
										Cancelar
297
											Cancelar
278
									</button>
298
										</button>
-
 
299
									</div>
279
								</div>
300
								</div>
280
							</div>
301
							</div>
281
						</div>
302
						</form>
282
					</div>
303
					</div>
283
				</div>
304
				</div>
284
			</div>
305
			</div>
285
		</section >
306
		</section >
286
	)
307
	)