Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11056 Rev 11061
Línea 4... Línea 4...
4
import { useState } from 'react'
4
import { useState } from 'react'
5
import { useForm } from 'react-hook-form'
5
import { useForm } from 'react-hook-form'
6
import { useDispatch } from 'react-redux'
6
import { useDispatch } from 'react-redux'
7
import { addNotification } from '../../../redux/notification/notification.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import DescriptionInput from '../../../shared/DescriptionInput'
8
import DescriptionInput from '../../../shared/DescriptionInput'
-
 
9
import { useEffect } from 'react'
Línea 9... Línea 10...
9
 
10
 
Línea 10... Línea 11...
10
const EditModal = ({ closeModal, email_link, isOpen, edit_link }) => {
11
const EditModal = ({ closeModal, email_link, isOpen, edit_link }) => {
11
 
12
 
Línea 46... Línea 47...
46
 
47
 
47
				clearErrors()
48
				clearErrors()
48
				closeModal()
49
				closeModal()
49
				dispatch(addNotification({
50
				dispatch(addNotification({
50
					style: 'success',
51
					style: 'success',
51
					msg: 'Usuario registrado'
52
					msg: 'Registro actualizado'
52
				}))
53
				}))
53
			})
54
			})
Línea 54... Línea -...
54
	}
-
 
55
 
-
 
56
	const checkEmail = () => {
-
 
57
		axios.get(email_link, { params: { email: watch('email') } })
-
 
58
			.then(({ data }) => {
-
 
59
				if (!data.success) {
-
 
60
					dispatch(addNotification({
-
 
61
						style: 'danger',
-
 
62
						msg: 'Ha ocurrido un error'
-
 
63
					}))
-
 
64
				}
-
 
65
 
-
 
66
				setValue('user_id', data.data.user_id)
-
 
67
				setValue('first_name', data.data.first_name)
-
 
68
				setValue('last_name', data.data.last_name)
-
 
69
				clearErrors()
-
 
70
			})
-
 
71
	}
55
	}
72
 
56
 
73
	const getData = () => {
57
	const getData = () => {
74
		axios.get(edit_link)
58
		axios.get(edit_link)
75
			.then(({ data }) => {
59
			.then(({ data }) => {
76
				if (!data.success) {
60
				if (!data.success) {
77
					dispatch(addNotification({
61
					dispatch(addNotification({
78
						style: 'danger',
62
						style: 'danger',
79
						msg: 'Ha ocurrido un error'
63
						msg: 'Ha ocurrido un error'
Línea 80... Línea -...
80
					}))
-
 
81
				}
64
					}))
82
 
65
				}
83
				setValue('user_id', data.data.user_id)
66
 
84
				setValue('first_name', data.data.first_name)
67
				Object.keys(data.data).map((key) => register(key))
85
				setValue('last_name', data.data.last_name)
68
				Object.entries(data.data).map(([key, value]) => setValue(key, value))
Línea -... Línea 69...
-
 
69
				clearErrors()
-
 
70
			})
86
				clearErrors()
71
	}
87
			})
72
 
88
	}
73
	useEffect(() => getData(), [])
89
 
74
 
90
	return (
75
	return (
91
		<Modal size="md" onHide={closeModal} show={isOpen}>
76
		<Modal size="md" onHide={closeModal} show={isOpen}>
92
			<Modal.Header closeButton>
77
			<Modal.Header closeButton>
93
				<Modal.Title>Nuevo candidato</Modal.Title>
78
				<Modal.Title>Nuevo candidato</Modal.Title>
-
 
79
			</Modal.Header>
-
 
80
			<form onSubmit={handleSubmit(onSubmit)}>
-
 
81
				<Modal.Body>
-
 
82
					<div className='form-group'>
-
 
83
						<label className="form-label">Nombre</label>
-
 
84
						<input type="text" name='first_name' className='form-control' ref={register({ required: true })} />
-
 
85
						{errors.first_name && <p>{errors.first_name.message}</p>}
-
 
86
					</div>
-
 
87
					<div className='form-group'>
-
 
88
						<label className="form-label">Apellido</label>
-
 
89
						<input type="text" name='last_name' className='form-control' ref={register({ required: true })} />
-
 
90
						{errors.last_name && <p>{errors.last_name.message}</p>}
-
 
91
					</div>
-
 
92
					<div className='form-group'>
-
 
93
						<label className="form-label">Correo electrónico</label>
94
			</Modal.Header>
94
						<input type="email" name='email' className='form-control' ref={register({ required: true })} />
95
			<form onSubmit={handleSubmit(onSubmit)}>
95
						{errors.email && <p>{errors.email.message}</p>}
96
				<Modal.Body>
96
					</div>
97
					<div className='form-group'>
97
					<div className='form-group'>
98
						<label className="form-label">Comentario</label>
98
						<label className="form-label">Comentario</label>
Línea 105... Línea 105...
105
					<div className='form-group'>
105
					<div className='form-group'>
106
						<label className="form-label">Evaluación</label>
106
						<label className="form-label">Evaluación</label>
107
						<select className='form-control' name='evaluation' ref={register}>
107
						<select className='form-control' name='evaluation' ref={register}>
108
							{
108
							{
109
								pointsOptions.map(({ label, value }) => {
109
								pointsOptions.map(({ label, value }) => {
110
									return <option key={value} value={value}>{label}</option>
110
									return <option selected={watch('evaluation')} key={value} value={value}>{label}</option>
111
								})
111
								})
112
							}
112
							}
113
						</select>
113
						</select>
114
					</div>
114
					</div>
115
					<div className='form-group'>
115
					<div className='form-group'>
Línea 121... Línea 121...
121
							accept='pdf/docx'
121
							accept='pdf/docx'
122
							ref={register}
122
							ref={register}
123
							style={{ height: '2rem' }}
123
							style={{ height: '2rem' }}
124
						/>
124
						/>
125
					</div>
125
					</div>
-
 
126
					<a href={watch('file')} type="button" className="btn btn-primary">
-
 
127
                        Verificar Email
-
 
128
					</a>
126
					<div className='form-group'>
129
					<div className='form-group'>
127
						<label className="form-label">Estatus</label>
130
						<label className="form-label">Estatus</label>
128
						<select className='form-control' name='evaluation' ref={register}>
131
						<select className='form-control' name='status' ref={register}>
129
							{
132
							{
130
								statusOptions.map(({ label, value }) => {
133
								statusOptions.map(({ label, value }) => {
131
									return <option key={value} value={value}>{label}</option>
134
									return <option selected={watch('status')} key={value} value={value}>{label}</option>
132
								})
135
								})
133
							}
136
							}
134
						</select>
137
						</select>
135
					</div>
138
					</div>
136
					<div className='form-group'>
-
 
137
						<label className="form-label">Correo electrónico</label>
-
 
138
						<input type="email" name='email' className='form-control' ref={register({ required: true })} />
-
 
139
						{errors.email && <p>{errors.email.message}</p>}
-
 
140
					</div>
-
 
141
					<button
-
 
142
						type="button"
-
 
143
						className="btn btn-primary"
-
 
144
						onClick={checkEmail}
-
 
145
					>
139
 
146
                        Verificar Email
-
 
147
					</button>
-
 
148
					<div className='form-group'>
-
 
149
						<label className="form-label">Nombre</label>
-
 
150
						<input type="text" name='first_name' className='form-control' ref={register({ required: true })} />
-
 
151
						{errors.first_name && <p>{errors.first_name.message}</p>}
-
 
152
					</div>
-
 
153
					<div className='form-group'>
-
 
154
						<label className="form-label">Apellido</label>
-
 
155
						<input type="text" name='last_name' className='form-control' ref={register({ required: true })} />
-
 
156
						{errors.last_name && <p>{errors.last_name.message}</p>}
-
 
157
					</div>
-
 
158
				</Modal.Body>
140
				</Modal.Body>
159
				<Modal.Footer>
141
				<Modal.Footer>
160
					<Button variant="danger" onClick={closeModal}>
142
					<Button variant="danger" onClick={closeModal}>
161
                        Cancelar
143
                        Cancelar
162
					</Button>
144
					</Button>