Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14276 Rev 14738
Línea 20... Línea 20...
20
 
20
 
21
	const history = useHistory()
21
	const history = useHistory()
22
	const { action } = useParams()
22
	const { action } = useParams()
Línea 23... Línea 23...
23
	const dispatch = useDispatch()
23
	const dispatch = useDispatch()
24
 
24
 
Línea 25... Línea 25...
25
	const locationRef = useRef();
25
	const locationRef = useRef()
26
	const { handleSubmit, register, setValue, errors, watch } = useForm()
26
	const { handleSubmit, register, setValue, errors, watch } = useForm()
27
 
27
 
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: 'error',
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: 'error',
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) {
79
			return setInputErrors(prev => ({ ...prev, year: 'Este campo es requerido' }))
79
			return setInputErrors(prev => ({ ...prev, year: 'Este campo es requerido' }))
80
		}
80
		}
Línea 84... Línea 84...
84
		})
84
		})
Línea 85... Línea 85...
85
 
85
 
86
		axios.post(actionLink, formData)
86
		axios.post(actionLink, formData)
87
			.then(({ data }) => {
87
			.then(({ data }) => {
-
 
88
				if (!data.success) {
-
 
89
					typeof data.data === 'string'
88
				if (!data.success) {
90
						?
89
					dispatch(addNotification({
91
						dispatch(addNotification({
90
						style: 'error',
92
							style: 'danger',
91
						msg: 'Ha ocurrido un error'
93
							msg: data.data
-
 
94
						}))
-
 
95
						: Object.entries(data.data).map(([key, value]) =>
-
 
96
							value.map(err =>
-
 
97
								dispatch(addNotification({
-
 
98
									style: 'danger',
-
 
99
									msg: `${key}: ${err}`
-
 
100
								}))
-
 
101
							)
92
					}))
102
						)
93
					return
103
					return
94
				}
104
				}
95
				history.goBack()
105
				history.goBack()
96
				dispatch(addNotification({
106
				dispatch(addNotification({
Línea 116... Línea 126...
116
 
126
 
117
						setLocationLabel(respData.formatted_address)
127
						setLocationLabel(respData.formatted_address)
118
						setLocation({
128
						setLocation({
119
							formatted_address: respData.formatted_address,
129
							formatted_address: respData.formatted_address,
120
							latitude: respData.latitude,
130
							latitude: respData.latitude,
121
							location_search:respData.location_search,
131
							location_search: respData.location_search,
122
							longitude:respData.longitude,
132
							longitude: respData.longitude,
123
							city1:respData.city1,
133
							city1: respData.city1,
124
							city2:respData.city2,
134
							city2: respData.city2,
125
							country:respData.country,
135
							country: respData.country,
126
							postal_code:respData.postal_code,
136
							postal_code: respData.postal_code,
127
							state:respData.state
137
							state: respData.state
128
						})
138
						})
129
						setYear(respData.last_date)
139
						setYear(respData.last_date)
Línea 130... Línea 140...
130
						respData.status === 'a' ? setIsActive(true) : setIsActive(false)
140
						respData.status === 'a' ? setIsActive(true) : setIsActive(false)