Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 10516 Rev 10518
Línea 1... Línea 1...
1
import axios from 'axios'
1
import axios from 'axios'
2
import React from 'react'
-
 
3
import { useEffect } from 'react'
2
import React, { useState, useEffect } from 'react'
4
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
5
import { useDispatch } from 'react-redux'
4
import { useDispatch } from 'react-redux'
6
import { useHistory, useParams } from 'react-router-dom'
5
import { useHistory, useParams } from 'react-router-dom'
7
import { addNotification } from '../../../redux/notification/notification.actions'
6
import { addNotification } from '../../../redux/notification/notification.actions'
Línea 8... Línea 7...
8
 
7
 
Línea 9... Línea 8...
9
 
8
 
10
const FormView = ({ actionLink }) => {
9
const FormView = ({ actionLink }) => {
11
 
10
 
12
	// States
11
	// States
13
	const pointsOptions = [
12
	const [pointsOptions, setPointsOptions] = useState([
14
		{ label: 'Evaluación', value: 0 },
13
		{ label: 'Evaluación', value: 0 },
15
		{ label: 'Sugerir otro cargo', value: 0 },
14
		{ label: 'Sugerir otro cargo', value: 0 },
16
		{ label: '25%', value: 1 },
15
		{ label: '25%', value: 1 },
17
		{ label: '50%', value: 2 },
16
		{ label: '50%', value: 2 },
18
		{ label: '75%', value: 3 },
17
		{ label: '75%', value: 3 },
19
		{ label: '100%', value: 4 }
18
		{ label: '100%', value: 4 }
20
	]
19
	])
21
	const statusOptions = [
20
	const [statusOptions, setStatusOptions] = useState([
22
		{ label: 'Estatus', value: '' },
21
		{ label: 'Estatus', value: '' },
-
 
22
		{ label: 'Aceptado', value: 'a' },
-
 
23
		{ label: 'Rechazado', value: 'r' }
Línea 23... Línea 24...
23
		{ label: 'Aceptado', value: 'a' },
24
	])
24
		{ label: 'Rechazado', value: 'r' }
25
	const [currentStatus, setCurrentStatus] = useState(statusOptions[0])
25
	]
26
	const [currentPoints, setCurrentPoints] = useState(pointsOptions[0])
26
 
27
 
27
	// Hooks
28
	// Hooks
Línea 28... Línea 29...
28
	const { register, setValue } = useForm()
29
	const { setValue } = useForm()
Línea 43... Línea 44...
43
							style: 'error',
44
							style: 'error',
44
							msg: 'Ha ocurrido un error'
45
							msg: 'Ha ocurrido un error'
45
						}))
46
						}))
46
					}
47
					}
Línea 47... Línea -...
47
 
-
 
48
					console.log(resData)
-
 
49
					setValue('status', resData.interview.status)
-
 
50
					setValue('points', resData.interview.points)
48
 
-
 
49
					setValue('comment', resData.interview.comment)
-
 
50
					setCurrentStatus(statusOptions.find((status) => status.value === resData.interview.status))
51
					setValue('comment', resData.interview.comment)
51
					setCurrentPoints(pointsOptions.find((point) => point.value === resData.interview.points))
52
				})
52
				})
53
		}
53
		}
Línea 54... Línea 54...
54
	}, [action])
54
	}, [action])
Línea 147... Línea 147...
147
											<label>Comentario</label>
147
											<label>Comentario</label>
148
											<input type="text" name="comment" className="form-control" />
148
											<input type="text" name="comment" className="form-control" />
149
										</div>
149
										</div>
150
										<div className="form-group">
150
										<div className="form-group">
151
											<label>Evaluación</label>
151
											<label>Evaluación</label>
152
											<select name='points' ref={register}>
152
											<select name='points' onChange={(e) => setCurrentPoints({ ...currentPoints, value: e.target.value })} value={currentPoints}>
153
												{
153
												{
154
													pointsOptions.map(({ label, value }) => {
154
													pointsOptions.map(({ label, value }) => {
155
														<option key={value} value={value}>{label}</option>
155
														<option key={value} value={value}>{label}</option>
156
													})
156
													})
157
												}
157
												}
158
											</select>
158
											</select>
159
										</div>
159
										</div>
160
										<div className="form-group">
160
										<div className="form-group">
161
											<label>Estatus</label>
161
											<label>Estatus</label>
162
											<select name='status' ref={register}>
162
											<select name='status' onChange={(e) => setCurrentStatus({ ...currentStatus, value: e.target.value })} value={currentStatus}>
163
												{
163
												{
164
													statusOptions.map(({ label, value }) => {
164
													statusOptions.map(({ label, value }) => {
165
														<option key={value} value={value}>{label}</option>
165
														<option key={value} value={value}>{label}</option>
166
													})
166
													})
167
												}
167
												}