Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14738 Rev 14838
Línea 26... Línea 26...
26
	const { handleSubmit, register, setValue, errors, watch } = useForm()
26
	const { handleSubmit, register, setValue, errors, watch } = useForm()
Línea 27... Línea 27...
27
 
27
 
28
	const [inputErrors, setInputErrors] = useState({})
28
	const [inputErrors, setInputErrors] = useState({})
29
	const [location, setLocation] = useState({})
29
	const [location, setLocation] = useState({})
30
	const [isActive, setIsActive] = useState(false)
30
	const [isActive, setIsActive] = useState(false)
31
	const [year, setYear] = useState(new Intl.DateTimeFormat('es-ES').format(new Date()))
31
	const [year, setYear] = useState(Date.now())
32
	const [locationLabel, setLocationLabel] = useState('')
32
	const [locationLabel, setLocationLabel] = useState('')
33
	const [jobsDescriptions, setJobsDescriptions] = useState([
33
	const [jobsDescriptions, setJobsDescriptions] = useState([
34
		{
34
		{
35
			value: '8ff86a9a-651c-4dd0-86c1-b9c0716d09e0',
35
			value: '8ff86a9a-651c-4dd0-86c1-b9c0716d09e0',
Línea 60... Línea 60...
60
			status: isActive ? 'a' : 'i'
60
			status: isActive ? 'a' : 'i'
61
		}
61
		}
62
		if (!location.formatted_address) {
62
		if (!location.formatted_address) {
63
			// locationRef.current.focus();
63
			// locationRef.current.focus();
64
			dispatch(addNotification({
64
			dispatch(addNotification({
65
				style: 'error',
65
				style: 'danger',
66
				msg: 'Es requerida una ubicación'
66
				msg: 'Es requerida una ubicación'
67
			}))
67
			}))
68
			return setInputErrors(prev => ({ ...prev, location: 'Es requerida una ubicación' }))
68
			return setInputErrors(prev => ({ ...prev, location: 'Es requerida una ubicación' }))
69
		}
69
		}
70
		if (!submitData.description) {
70
		if (!submitData.description) {
71
			// locationRef.current.focus();
71
			// locationRef.current.focus();
72
			dispatch(addNotification({
72
			dispatch(addNotification({
73
				style: 'error',
73
				style: 'danger',
74
				msg: 'Es requerida una descripcion'
74
				msg: 'Es requerida una descripcion'
75
			}))
75
			}))
76
			return
76
			return
77
		}
77
		}
78
		if (!year) {
78
		if (!year) {
Línea 107... Línea 107...
107
					style: 'success',
107
					style: 'success',
108
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'guardado'}`
108
					msg: `Registro ${action === 'edit' ? 'actualizado' : 'guardado'}`
109
				}))
109
				}))
110
			})
110
			})
111
			.catch(() => dispatch(addNotification({
111
			.catch(() => dispatch(addNotification({
112
				style: 'error',
112
				style: 'danger',
113
				msg: 'Ha ocurrido un error'
113
				msg: 'Ha ocurrido un error'
114
			})))
114
			})))
Línea 115... Línea 115...
115
 
115
 
Línea 226... Línea 226...
226
						<div className="form-group">
226
						<div className="form-group">
227
							<label>Último día de aplicación</label>
227
							<label>Último día de aplicación</label>
228
							<Datetime
228
							<Datetime
229
								dateFormat="DD-MM-YYYY"
229
								dateFormat="DD-MM-YYYY"
230
								timeFormat={false}
230
								timeFormat={false}
-
 
231
								onChange={(e) => {
-
 
232
									if (Date.now() > new Date(e.toDate()).getTime()) {
231
								initialValue={action === 'edit' ? Date.UTC(year) : Date.now()}
233
										setYear(new Date(new Intl.DateTimeFormat('en-EN', year).format()))
-
 
234
										return dispatch(addNotification({
232
								onChange={(e) =>
235
											style: 'danger',
-
 
236
											msg: 'La fecha no puede ser igual o anterior a la actual'
-
 
237
										}))
-
 
238
									}
233
									setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
239
									setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
234
								}
240
								}}
235
								inputProps={{ className: 'form-control' }}
241
								inputProps={{ className: 'form-control' }}
-
 
242
								initialValue={
-
 
243
									new Date(new Intl.DateTimeFormat('en-EN', action === 'edit' ? Date.parse(year) : year).format())
-
 
244
								}
236
								closeOnSelect
245
								closeOnSelect
237
							/>
246
							/>
238
							{inputErrors.year && <p>{inputErrors.year}</p>}
247
							{inputErrors.year && <p>{inputErrors.year}</p>}
239
						</div>
248
						</div>
240
						<div className="form-group">
249
						<div className="form-group">