Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 15124 Rev 15125
Línea 19... Línea 19...
19
	setAction
19
	setAction
20
}) => {
20
}) => {
Línea 21... Línea 21...
21
 
21
 
22
	const dispatch = useDispatch()
22
	const dispatch = useDispatch()
23
	const locationRef = useRef()
23
	const locationRef = useRef()
24
	const { handleSubmit, register, setValue, errors, getValues } = useForm()
24
	const { handleSubmit, register, setValue, errors } = useForm()
25
	const [inputErrors, setInputErrors] = useState({})
25
	const [inputErrors, setInputErrors] = useState({})
26
	const [location, setLocation] = useState({})
26
	const [location, setLocation] = useState({})
27
	const [isActive, setIsActive] = useState(false)
27
	const [isActive, setIsActive] = useState(false)
28
	const [year, setYear] = useState(new Date())
28
	const [year, setYear] = useState(new Date())
29
	const [locationLabel, setLocationLabel] = useState('')
29
	const [locationLabel, setLocationLabel] = useState('')
30
	const [jobsDescriptions, setJobsDescriptions] = useState([])
30
	const [jobsDescriptions, setJobsDescriptions] = useState([])
31
	const [jobsCategory, setJobsCategory] = useState([])
31
	const [jobsCategory, setJobsCategory] = useState([])
32
	const [industry, setIndustry] = useState([])
-
 
Línea 33... Línea 32...
33
	const [description, setDescription] = useState('')
32
	const [industry, setIndustry] = useState([])
Línea 34... Línea 33...
34
 
33
 
Línea 98... Línea 97...
98
 
97
 
Línea 99... Línea 98...
99
	}
98
	}
Línea 100... Línea -...
100
 
-
 
101
	useEffect(() => register('description'), [])
99
 
102
 
100
	useEffect(() => register('description'), [])
103
	useEffect(() => {
101
 
104
		if (action === 'edit') {
102
	const getData = ({ editor }) => {
105
			axios.get(actionLink)
103
		axios.get(actionLink)
106
				.then(({ data }) => {
104
			.then(({ data }) => {
107
					const respData = data.data
105
				const respData = data.data
108
					if (data.success) {
106
				if (data.success) {
109
 
107
 
110
						setLocationLabel(respData.formatted_address)
108
					setLocationLabel(respData.formatted_address)
111
						setLocation({
109
					setLocation({
112
							formatted_address: respData.formatted_address,
110
						formatted_address: respData.formatted_address,
113
							latitude: respData.latitude,
111
						latitude: respData.latitude,
114
							location_search: respData.location_search,
112
						location_search: respData.location_search,
115
							longitude: respData.longitude,
113
						longitude: respData.longitude,
116
							city1: respData.city1,
114
						city1: respData.city1,
117
							city2: respData.city2,
115
						city2: respData.city2,
118
							country: respData.country,
116
						country: respData.country,
119
							postal_code: respData.postal_code,
117
						postal_code: respData.postal_code,
120
							state: respData.state
118
						state: respData.state
121
						})
119
					})
122
						setDescription(respData.description)
120
					editor.setData(respData.description)
123
						setYear(new Date(respData.last_date))
121
					setYear(new Date(respData.last_date))
124
 
122
 
125
						respData.status === 'a' ? setIsActive(true) : setIsActive(false)
123
					respData.status === 'a' ? setIsActive(true) : setIsActive(false)
126
 
124
 
127
						Object.entries(respData.job_category.category_options).map(([value, label]) => {
125
					Object.entries(respData.job_category.category_options).map(([value, label]) => {
128
							setJobsCategory(prev => [...prev, { value: value, label: label }])
126
						setJobsCategory(prev => [...prev, { value: value, label: label }])
129
						})
127
					})
130
 
128
 
131
						Object.entries(respData.industry.industry_options).map(([value, label]) => {
129
					Object.entries(respData.industry.industry_options).map(([value, label]) => {
132
							setIndustry(prev => [...prev, { value: value, label: label }])
130
						setIndustry(prev => [...prev, { value: value, label: label }])
133
						})
131
					})
134
 
132
 
135
						Object.entries(respData.job_description.description_options).map(([value, label]) => {
133
					Object.entries(respData.job_description.description_options).map(([value, label]) => {
136
							setJobsDescriptions(prev => [...prev, { value: value, label: label }])
134
						setJobsDescriptions(prev => [...prev, { value: value, label: label }])
137
						})
135
					})
138
 
136
 
139
						setValue('name', respData.name)
137
					setValue('name', respData.name)
140
 
138
 
141
						setValue('job_description_id', respData.job_description.current_description.description_id)
139
					setValue('job_description_id', respData.job_description.current_description.description_id)
142
						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)
143
						setValue('industry_id', respData.industry.current_industry.industry_id)
141
					setValue('industry_id', respData.industry.current_industry.industry_id)
144
					}
-
 
Línea 145... Línea 142...
145
				})
142
				}
146
		}
143
			})
147
	}, [action])
144
	}
148
 
145
 
Línea 221... Línea 218...
221
							/>
218
							/>
222
							{inputErrors.year && <p>{inputErrors.year}</p>}
219
							{inputErrors.year && <p>{inputErrors.year}</p>}
223
						</div>
220
						</div>
224
						<div className="form-group">
221
						<div className="form-group">
225
							<label>Descripción</label>
222
							<label>Descripción</label>
226
							{description
-
 
227
								? <CKEditor
223
							<CKEditor
228
									onChange={(e) => setValue('description', e.editor.getData())}
224
								onChange={(e) => setValue('description', e.editor.getData())}
229
									onInstanceReady={(e) => e.editor.setData(description)}
225
								onInstanceReady={action === 'edit' && getData}
230
									config={config} />
-
 
231
								: <CKEditor
-
 
232
									onChange={(e) => setValue('description', e.editor.getData())}
-
 
233
									config={config} />
226
								config={config} />
234
							}
-
 
235
						</div>
227
						</div>
236
						<div className="form-group">
228
						<div className="form-group">
237
							<label>Estatus</label>
229
							<label>Estatus</label>
238
							<div
230
							<div
239
								className={`toggle btn btn-block btn-primary ${!isActive && 'off'}`}
231
								className={`toggle btn btn-block btn-primary ${!isActive && 'off'}`}