Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15114 Rev 15377
Línea 18... Línea 18...
18
	jobsDescription,
18
	jobsDescription,
19
	action,
19
	action,
20
	setAction }) => {
20
	setAction }) => {
Línea 21... Línea 21...
21
 
21
 
22
	// Hooks
22
	// Hooks
23
	const { register, setValue, watch, reset } = useForm()
23
	const { register, setValue, watch, reset, handleSubmit, errors } = useForm()
Línea 24... Línea 24...
24
	const dispatch = useDispatch()
24
	const dispatch = useDispatch()
25
 
25
 
26
	// State
26
	// State
27
	const [currentJobDescription, setCurretJobDescription] = useState('')
27
	const [currentJobDescription, setCurretJobDescription] = useState('')
28
	const [jobDescriptionOptions, setJobDescriptionOptions] = useState(jobsDescription)
28
	const [jobDescriptionOptions, setJobDescriptionOptions] = useState(jobsDescription)
29
	const [competencyTypes, setCompetencyTypes] = useState([])
-
 
Línea 30... Línea 29...
30
	const [competenciesSelected, setCompetenciesSelected] = useState([])
29
	const [competencyTypes, setCompetencyTypes] = useState([])
31
	const [status, setStatus] = useState('a')
30
	const [competenciesSelected, setCompetenciesSelected] = useState([])
32
 
-
 
-
 
31
 
33
 
32
 
34
	const onSubmit = () => {
-
 
35
		const submitData = new FormData()
33
	const onSubmit = handleSubmit((data) => {
36
		submitData.append('name', watch('name'))
34
		const submitData = new FormData()
Línea 37... Línea 35...
37
		submitData.append('description', watch('description'))
35
 
38
		submitData.append('status', status)
36
		Object.entries(data).forEach(([key, value]) => submitData.append(key, value))
Línea 62... Línea 60...
62
				dispatch(addNotification({
60
				dispatch(addNotification({
63
					style: 'success',
61
					style: 'success',
64
					msg: data.data
62
					msg: data.data
65
				}))
63
				}))
66
			})
64
			})
67
	}
65
	})
Línea 68... Línea 66...
68
 
66
 
69
	const submitAndClose = () => {
67
	const submitAndClose = () => {
70
		onSubmit()
68
		onSubmit()
71
		reset()
69
		reset()
Línea 83... Línea 81...
83
						}))
81
						}))
84
					}
82
					}
Línea 85... Línea 83...
85
 
83
 
86
					setValue('name', data.data.name)
84
					setValue('name', data.data.name)
87
					setValue('description', data.data.description)
85
					setValue('description', data.data.description)
88
					setStatus(data.data.status)
86
					setValue('status', data.data.status)
89
					setCurretJobDescription(data.data.job_description_id)
87
					setCurretJobDescription(data.data.job_description_id)
90
					setValue('jobs_description', data.data.job_description_id)
88
					setValue('jobs_description', data.data.job_description_id)
91
				})
89
				})
92
		}
90
		}
Línea 119... Línea 117...
119
						<label>Nombre</label>
117
						<label>Nombre</label>
120
						<input
118
						<input
121
							type="text"
119
							type="text"
122
							name="name"
120
							name="name"
123
							className='form-control'
121
							className='form-control'
124
							ref={register({ required: true, maxLength: 50 })} />
122
							ref={register({ required: true, maxLength: 50 })}
-
 
123
						/>
-
 
124
						{errors.name && <p>{errors.name.message}</p>}
125
					</div>
125
					</div>
126
					<div className="form-group">
126
					<div className="form-group">
127
						<label>Cargo a evaluar</label>
127
						<label>Cargo a evaluar</label>
128
						<select
128
						<select
129
							name="job_description_id"
129
							name="job_description_id"
130
							className="form-control"
130
							className="form-control"
131
							onChange={(e) => setCurretJobDescription(e.target.value)}>
131
							onChange={(e) => setCurretJobDescription(e.target.value)}
-
 
132
						>
132
							<option value=''>Seleccione</option>
133
							<option value=''>Seleccione</option>
133
							{jobDescriptionOptions.map(({ name, uuid }) => (
134
							{jobDescriptionOptions.map(({ name, uuid }) =>
134
								<option selected={uuid === currentJobDescription} key={uuid} value={uuid}>{name}</option>
135
								<option selected={uuid === currentJobDescription} key={uuid} value={uuid}>{name}</option>
135
							))
136
							)}
136
							}
-
 
137
						</select>
137
						</select>
138
					</div>
138
					</div>
139
					<div className="form-group">
139
					<div className="form-group">
140
						<label htmlFor="form-description">Descripción</label>
140
						<label htmlFor="form-description">Descripción</label>
141
						<textarea
141
						<textarea
142
							type="text"
142
							type="text"
143
							name="description"
143
							name="description"
144
							rows="5"
144
							rows="5"
145
							cols="50"
145
							cols="50"
146
							className='form-control'
146
							className='form-control'
147
							ref={register({ required: true })} />
147
							ref={register({ required: 'Este campo es requerido' })}
-
 
148
						/>
-
 
149
						{errors.description && <p>{errors.description.message}</p>}
148
					</div>
150
					</div>
149
					<div className="form-group">
151
					<div className="form-group">
150
						<label htmlFor="form-status">Estatus</label>
152
						<label htmlFor="status">Estatus</label>
-
 
153
						<select
-
 
154
							className="form-control"
-
 
155
							name="status"
151
						<select name="form-status" className="form-control" onChange={(e) => setStatus(e.target.value)} value={status}>
156
							ref={register({ required: 'Este campo es requerido' })}
-
 
157
						>
152
							<option selected={status === 'i'} value="i">Inactivo</option>
158
							<option selected={status === 'i'} value="i">Inactivo</option>
153
							<option selected={status === 'a'} value="a">Activo</option>
159
							<option selected={status === 'a'} value="a">Activo</option>
154
						</select>
160
						</select>
-
 
161
						{errors.status && <p>{errors.status.message}</p>}
155
					</div>
162
					</div>
156
					<br />
163
					<br />
157
					<div className="row">
164
					<div className="row">
158
						<div className="col-xs-12 col-md-12">
165
						<div className="col-xs-12 col-md-12">
159
							<div className="panel-group" id="rows" >
166
							<div className="panel-group">
160
								<div className="form-group" id="competencies-to-job" style={{}}>
167
								<div className="form-group">
161
									<div className="row">
168
									<div className="row">
162
										<div className="col-xs-12 col-md-12">
169
										<div className="col-xs-12 col-md-12">
163
											<hr />
170
											<hr />
164
											<h4 style={{ fontSize: 18, fontWeight: 'bold' }}>Competencias asociadas al cargo:</h4>
171
											<h4 style={{ fontSize: 18, fontWeight: 'bold' }}>Competencias asociadas al cargo:</h4>
165
											<br />
172
											<br />
Línea 167... Línea 174...
167
												{!!competencyTypes.length &&
174
												{!!competencyTypes.length &&
168
													competenciesSelected.map((competency) => {
175
													competenciesSelected.map((competency) => {
169
														const type = competencyTypes.find((type) => type.competency_type_id === competency.competency_type_id)
176
														const type = competencyTypes.find((type) => type.competency_type_id === competency.competency_type_id)
Línea 170... Línea 177...
170
 
177
 
-
 
178
														return (
-
 
179
															<div
171
														return (
180
																className="panel panel-default"
-
 
181
																id={`panel-${competency.competency_id}`}
-
 
182
																key={competency.competency_id}
172
															<div key={competency.competency_id} className="panel panel-default" id={`panel-${competency.competency_id}`}>
183
															>
173
																<div className="panel-heading">
184
																<div className="panel-heading">
-
 
185
																	<h4 className="panel-title" style={{ fontSize: 18 }}>
-
 
186
																		<a
-
 
187
																			aria-expanded="true"
174
																	<h4 className="panel-title" style={{ fontSize: 18 }}>
188
																			className="accordion-toggle"
-
 
189
																			data-parent={`#panel-${competency.competency_id}`}
-
 
190
																			data-toggle="collapse"
-
 
191
																			href={`#collapse-${competency.competency_id}`}
175
																		<a className="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent={`#panel-${competency.competency_id}`} href={`#collapse-${competency.competency_id}`}>
192
																		>
176
																			<span className={`competency-name${competency.competency_id}`}>
193
																			<span className={`competency-name${competency.competency_id}`}>
177
																				{`${type.name} - ${competency.name}`}
194
																				{`${type.name} - ${competency.name}`}
178
																			</span>
195
																			</span>
179
																		</a>
196
																		</a>
180
																	</h4>
197
																	</h4>
-
 
198
																</div>
-
 
199
																<div
181
																</div>
200
																	className="panel-collapse in collapse show"
-
 
201
																	id={`collapse-${competency.competency_id}`}
182
																<div id={`collapse-${competency.competency_id}`} className="panel-collapse in collapse show">
202
																>
183
																	<div className="panel-body">
203
																	<div className="panel-body">
184
																		<div className="table-responsive">
204
																		<div className="table-responsive">
185
																			<table className="table table-bordered">
205
																			<table className="table table-bordered">
186
																				<thead>
206
																				<thead>
187
																					<tr>
207
																					<tr>
188
																						<th style={{ width: '80%' }}>Conducta Observable</th>
208
																						<th style={{ width: '80%' }}>Conducta Observable</th>
189
																						<th style={{ width: '20%' }}>Nivel</th>
209
																						<th style={{ width: '20%' }}>Nivel</th>
190
																					</tr>
210
																					</tr>
191
																				</thead>
211
																				</thead>
192
																				<tbody>
212
																				<tbody>
193
																					{competency.behaviors?.map(({ behavior_id, description, level }) => (
213
																					{competency.behaviors?.map(({ behavior_id, description, level }) =>
194
																						<tr key={behavior_id}>
214
																						<tr key={behavior_id}>
195
																							<td className="text-left">
215
																							<td className="text-left">
196
																								{description}
216
																								{description}
197
																							</td>
217
																							</td>
198
																							<td>
218
																							<td>
199
																								{levelOptions[level]}
219
																								{levelOptions[level]}
200
																							</td>
220
																							</td>
201
																						</tr>
221
																						</tr>
202
																					))
-
 
203
																					}
222
																					)}
204
																				</tbody>
223
																				</tbody>
205
																			</table>
224
																			</table>
206
																		</div>
225
																		</div>
207
																	</div>
226
																	</div>