Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 10836 Rev 10840
Línea 5... Línea 5...
5
import { useDispatch } from 'react-redux'
5
import { useDispatch } from 'react-redux'
6
import { useHistory, useParams } from 'react-router-dom'
6
import { useHistory, useParams } from 'react-router-dom'
7
import { addNotification } from '../../../redux/notification/notification.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
Línea 8... Línea 8...
8
 
8
 
Línea 9... Línea 9...
9
 
9
 
-
 
10
const FormView = ({ actionLink, type_link }) => {
-
 
11
 
-
 
12
	// States
-
 
13
	const [typeOptions, setTypeOptions] = useState({
10
const FormView = ({ actionLink }) => {
14
		url: type_link,
11
 
15
		value: ''
12
	// States
16
	})
13
	const [generalOptions, setGeneralOptions] = useState({
17
	const [generalOptions, setGeneralOptions] = useState({
14
		uuid: '',
18
		uuid: '',
Línea 47... Línea 51...
47
	const history = useHistory()
51
	const history = useHistory()
48
	const dispatch = useDispatch()
52
	const dispatch = useDispatch()
49
	const { action } = useParams()
53
	const { action } = useParams()
Línea 50... Línea 54...
50
 
54
 
-
 
55
	useEffect(() => {
51
	useEffect(() => {
56
		if (action === 'edit') {
-
 
57
			axios.get(actionLink)
-
 
58
				.then(({ data }) => {
-
 
59
					const resData = data.data
-
 
60
 
-
 
61
					if (!data.success) {
-
 
62
						dispatch(addNotification({
-
 
63
							style: 'error',
-
 
64
							msg: 'Ha ocurrido un error'
-
 
65
						}))
-
 
66
					}
-
 
67
 
-
 
68
					setValue('comment', resData.interview.comment)
-
 
69
					setValue('points', resData.interview.points)
-
 
70
					setValue('status', resData.interview.status)
-
 
71
					setCompetencies(resData.job_description.competencies)
-
 
72
					setCandidatesOptions({ label: `${resData.candidate.first_name} ${resData.candidate.last_name}`, value: resData.candidate.uuid })
-
 
73
					setVacancyOptions({ label: resData.vacancy.name, value: resData.vacancy.uuid })
-
 
74
					setTypeOptions({ ...typeOptions, value: resData.interview.type })
-
 
75
					setGeneralOptions({
-
 
76
						...generalOptions,
-
 
77
						name: resData.vacancy.name,
-
 
78
						uuid: resData.vacancy.uuid,
-
 
79
						description: resData.vacancy.description,
-
 
80
						functions: resData.job_description.functions,
-
 
81
						objectives: resData.job_description.objectives
-
 
82
					})
-
 
83
				})
-
 
84
		}
-
 
85
	}, [action])
-
 
86
 
-
 
87
	useEffect(() => {
52
		axios.get(actionLink)
88
		axios.get(typeOptions.url)
53
			.then(({ data }) => {
-
 
Línea 54... Línea 89...
54
				const resData = data.data
89
			.then(({ data }) => {
55
 
90
 
56
				if (!data.success) {
91
				if (!data.success) {
57
					dispatch(addNotification({
92
					dispatch(addNotification({
58
						style: 'error',
93
						style: 'error',
59
						msg: 'Ha ocurrido un error'
94
						msg: 'Ha ocurrido un error'
Línea 60... Línea -...
60
					}))
-
 
61
				}
-
 
62
 
-
 
63
				setValue('comment', resData.interview.comment)
-
 
64
				setValue('points', resData.interview.points)
-
 
65
				setValue('status', resData.interview.status)
-
 
66
				setCompetencies(resData.job_description.competencies)
95
					}))
67
				setGeneralOptions({
-
 
68
					...generalOptions,
-
 
69
					name: resData.vacancy.name,
-
 
70
					uuid: resData.vacancy.uuid,
-
 
71
					description: resData.vacancy.description,
-
 
72
					functions: resData.job_description.functions,
96
				}
Línea 73... Línea 97...
73
					objectives: resData.job_description.objectives
97
 
Línea 74... Línea 98...
74
				})
98
				console.log(data.data)
75
			})
99
			})
76
 
100
 
77
	}, [action])
101
	}, [typeOptions.url])
Línea 112... Línea 136...
112
												</div>
136
												</div>
113
											</div>
137
											</div>
114
											<div className="col-6">
138
											<div className="col-6">
115
												<div className="form-group">
139
												<div className="form-group">
116
													<label>Candidatos</label>
140
													<label>Candidatos</label>
117
													<select className='form-control' name='points' ref={register} disabled={action === 'edit'}>
141
													<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) }))}>
118
														{
142
														{
119
															candidatesOptions.map(({ label, value }) => (
143
															candidatesOptions.map(({ label, value }) => (
120
																<option selected={watch('candidate') === value} key={value} value={value}>{label}</option>
144
																<option selected={watch('candidate') === value} key={value} value={value}>{label}</option>
121
															))
145
															))
122
														}
146
														}
123
													</select>
147
													</select>
124
												</div>
148
												</div>
125
											</div>
149
											</div>
126
										</div>
150
										</div>
127
										<div className="card">
151
										<div className="card">
-
 
152
											<h5>{typeOptions.value === 'r' ? 'Recursos Humanos' : 'Potencial superior'}</h5>
128
											<div className="card-body">
153
											<div className="card-body">
129
												<h5>{generalOptions.name}</h5>
154
												<h5>{generalOptions.name}</h5>
130
												<p>{generalOptions.description}</p>
155
												<p>{generalOptions.description}</p>
131
												<h6>Funciones</h6>
156
												<h6>Funciones</h6>
132
												<p>{generalOptions.functions}</p>
157
												<p>{generalOptions.functions}</p>