Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15090 Rev 15103
Línea 1... Línea 1...
1
import React, { useState, useEffect, useRef } from 'react'
1
import React, { useState, useEffect, useRef } from 'react'
2
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
3
import Datetime from 'react-datetime'
3
import Datetime from 'react-datetime'
4
import axios from 'axios'
4
import axios from 'axios'
5
import SearchLocationInput from '../../../shared/SearchLocationInput'
5
import SearchLocationInput from '../../../shared/SearchLocationInput'
6
import DescriptionInput from '../../../shared/DescriptionInput'
-
 
7
import { useHistory, useParams } from 'react-router-dom'
-
 
8
import 'react-datetime/css/react-datetime.css'
6
import 'react-datetime/css/react-datetime.css'
9
import { addNotification } from '../../../redux/notification/notification.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
10
import { useDispatch } from 'react-redux'
8
import { useDispatch } from 'react-redux'
11
import parse from 'html-react-parser'
9
import { CKEditor } from 'ckeditor4-react'
-
 
10
import { config } from '../../../shared/helpers/ckeditor_config'
Línea 12... Línea 11...
12
 
11
 
13
const FormView = ({
12
const FormView = ({
14
	actionLink,
13
	actionLink,
15
	googleApiKey,
14
	googleApiKey,
16
	jobCategories: jsonCategories,
15
	jobCategories: jsonCategories,
17
	industries: jsonIndustries,
16
	industries: jsonIndustries,
-
 
17
	jobDescritions: jsonDescriptions,
-
 
18
	action,
18
	jobDescritions: jsonDescriptions
19
	setAction
Línea 19... Línea -...
19
}) => {
-
 
20
 
-
 
21
	const history = useHistory()
20
}) => {
22
	const { action } = useParams()
-
 
23
	const dispatch = useDispatch()
21
 
24
 
22
	const dispatch = useDispatch()
25
	const locationRef = useRef()
-
 
26
	const { handleSubmit, register, setValue, errors, watch } = useForm()
23
	const locationRef = useRef()
27
 
24
	const { handleSubmit, register, setValue, errors, getValues } = useForm()
28
	const [inputErrors, setInputErrors] = useState({})
25
	const [inputErrors, setInputErrors] = useState({})
29
	const [location, setLocation] = useState({})
26
	const [location, setLocation] = useState({})
30
	const [isActive, setIsActive] = useState(false)
27
	const [isActive, setIsActive] = useState(false)
Línea 85... Línea 82...
85
								}))
82
								}))
86
							)
83
							)
87
						)
84
						)
88
					return
85
					return
89
				}
86
				}
90
				history.goBack()
87
				setAction('')
91
				dispatch(addNotification({
88
				dispatch(addNotification({
92
					style: 'success',
89
					style: 'success',
93
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'guardado'}`
90
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'guardado'}`
94
				}))
91
				}))
95
			})
92
			})
Línea 136... Línea 133...
136
							setJobsDescriptions(prev => [...prev, { value: value, label: label }])
133
							setJobsDescriptions(prev => [...prev, { value: value, label: label }])
137
						})
134
						})
Línea 138... Línea 135...
138
 
135
 
139
						setValue('name', respData.name)
136
						setValue('name', respData.name)
140
						setValue('description', respData.description)
137
						setValue('description', respData.description)
141
						
138
 
142
						setValue('job_description_id', respData.job_description.current_description.description_id);
139
						setValue('job_description_id', respData.job_description.current_description.description_id)
143
						setValue('job_category_id', respData.job_category.current_category.job_category_id);
140
						setValue('job_category_id', respData.job_category.current_category.job_category_id)
Línea 144... Línea 141...
144
						setValue('industry_id', respData.industry.current_industry.industry_id);
141
						setValue('industry_id', respData.industry.current_industry.industry_id)
145
 
142
 
Línea 218... Línea 215...
218
							<label>Último día de aplicación</label>
215
							<label>Último día de aplicación</label>
219
							<Datetime
216
							<Datetime
220
								dateFormat="DD-MM-YYYY"
217
								dateFormat="DD-MM-YYYY"
221
								timeFormat={false}
218
								timeFormat={false}
222
								onChange={(e) => {
219
								onChange={(e) => {
223
									if (Date.now() > new Date(e.toDate()).getTime()) {
220
									if (new Date > new Date(e.toDate())) {
224
										setYear(new Date(new Intl.DateTimeFormat('en-EN', year).format()))
221
										setYear(new Date(new Intl.DateTimeFormat('en-EN', year).format()))
225
										return dispatch(addNotification({
222
										return dispatch(addNotification({
226
											style: 'danger',
223
											style: 'danger',
227
											msg: 'La fecha no puede ser igual o anterior a la actual'
224
											msg: 'La fecha no puede ser anterior a la fecha actual'
228
										}))
225
										}))
229
									}
226
									}
230
									setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
227
									setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
231
								}}
228
								}}
232
								inputProps={{ className: 'form-control' }}
229
								inputProps={{ className: 'form-control' }}
Línea 237... Línea 234...
237
							/>
234
							/>
238
							{inputErrors.year && <p>{inputErrors.year}</p>}
235
							{inputErrors.year && <p>{inputErrors.year}</p>}
239
						</div>
236
						</div>
240
						<div className="form-group">
237
						<div className="form-group">
241
							<label>Descripción</label>
238
							<label>Descripción</label>
242
							<DescriptionInput
239
							<CKEditor
-
 
240
								onChange={(e) => setValue('description', e.editor.getData())}
243
								onChange={setValue}
241
								onInstanceReady={(e) =>
244
								name="description"
242
									getValues('description')
245
								defaultValue={watch('description') ? parse(watch('description')) : ''}
243
										? e.editor.setData(getValues('description'))
-
 
244
										: e.editor.setData('')
-
 
245
								}
-
 
246
								config={config}
246
							/>
247
							/>
247
						</div>
248
						</div>
248
						<div className="form-group">
249
						<div className="form-group">
249
							<label>Estatus</label>
250
							<label>Estatus</label>
250
							<div
251
							<div
Línea 273... Línea 274...
273
								Guardar
274
								Guardar
274
							</button>
275
							</button>
275
							<button
276
							<button
276
								type="button"
277
								type="button"
277
								className="btn btn-secondary btn-edit-cancel"
278
								className="btn btn-secondary btn-edit-cancel"
278
								onClick={() => history.goBack()}
279
								onClick={() => setAction('')}
279
							>
280
							>
280
								Cancelar
281
								Cancelar
281
							</button>
282
							</button>
282
						</div>
283
						</div>
283
					</form>
284
					</form>