Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 10513 Rev 10516
Línea 4... Línea 4...
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
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
 
-
 
9
const pointsOptions = [
-
 
10
	{ label: 'Evaluación', value: 0 },
-
 
11
	{ label: 'Sugerir otro cargo', value: 0 },
-
 
12
	{ label: '25%', value: 1 },
-
 
13
	{ label: '50%', value: 2 },
-
 
14
	{ label: '75%', value: 3 },
-
 
15
	{ label: '100%', value: 4 }
-
 
16
]
-
 
17
 
-
 
18
const statusOptions = [
-
 
19
	{ label: 'Estatus', value: '' },
-
 
20
	{ label: 'Aceptado', value: 'a' },
-
 
21
	{ label: 'Rechazado', value: 'r' }
-
 
Línea 22... Línea 8...
22
]
8
 
Línea -... Línea 9...
-
 
9
 
-
 
10
const FormView = ({ actionLink }) => {
-
 
11
 
-
 
12
	// States
-
 
13
	const pointsOptions = [
-
 
14
		{ label: 'Evaluación', value: 0 },
-
 
15
		{ label: 'Sugerir otro cargo', value: 0 },
-
 
16
		{ label: '25%', value: 1 },
-
 
17
		{ label: '50%', value: 2 },
-
 
18
		{ label: '75%', value: 3 },
-
 
19
		{ label: '100%', value: 4 }
-
 
20
	]
-
 
21
	const statusOptions = [
-
 
22
		{ label: 'Estatus', value: '' },
-
 
23
		{ label: 'Aceptado', value: 'a' },
-
 
24
		{ label: 'Rechazado', value: 'r' }
23
 
25
	]
24
const FormView = ({ actionLink }) => {
26
 
25
 
27
	// Hooks
26
	const { register, setValue } = useForm()
28
	const { register, setValue } = useForm()
Línea 27... Línea 29...
27
	const history = useHistory()
29
	const history = useHistory()
-
 
30
	const dispatch = useDispatch()
-
 
31
	const { action } = useParams()
-
 
32
 
28
	const dispatch = useDispatch()
33
	useEffect(() => {
29
	const { action } = useParams()
34
 
30
 
35
		// Get current item data
31
	useEffect(() => {
36
		if (action === 'edit') {
32
		axios.get(actionLink)
37
			axios.get(actionLink)
33
			.then(({ data }) => {
38
				.then(({ data }) => {
34
				const resData = data.data
39
					const resData = data.data
35
 
40
 
36
				if (!data.success) {
41
					if (!data.success) {
37
					dispatch(addNotification({
42
						dispatch(addNotification({
38
						style: 'error',
43
							style: 'error',
-
 
44
							msg: 'Ha ocurrido un error'
39
						msg: 'Ha ocurrido un error'
45
						}))
40
					}))
46
					}
41
				}
47
 
42
 
48
					console.log(resData)
-
 
49
					setValue('status', resData.interview.status)
43
				setValue('status', resData.interview.status)
50
					setValue('points', resData.interview.points)
Línea 44... Línea 51...
44
				setValue('points', resData.interview.points)
51
					setValue('comment', resData.interview.comment)
45
				setValue('comment', resData.interview.comment)
52
				})
46
			})
53
		}
47
	}, [])
54
	}, [action])