Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15057 | Rev 15241 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6848 stevensc 1
import React, { useEffect, useState } from 'react'
2
import { Link } from 'react-router-dom'
11131 stevensc 3
import { getData } from '../../helpers/fetchHelpers'
4
import EditItem from '../components/EditItem'
5
import CategoryModal from '../components/Modals/CategoryModal'
6
import DegreesModal from '../components/Modals/DegreesModal'
7
import EmploymentTypeModal from '../components/Modals/EmploymentTypeModal'
8
import ExperienceModal from '../components/Modals/ExperiencieModal'
9
import LanguageModal from '../components/Modals/LanguageModal'
10
import LastAplicationDayModal from '../components/Modals/LastAplicationDayModal'
11
import LocationModal from '../components/Modals/LocationModal'
12
import OverviewModal from '../components/Modals/OverviewModal'
13
import SalaryModal from '../components/Modals/SalaryModal'
14
import SkillsModal from '../components/Modals/SkillsModal'
15
import StatusModal from '../components/Modals/StatusModal'
16
import TitleModal from '../components/Modals/TitleModal'
6628 stevensc 17
 
15057 stevensc 18
const JobsEditView = ({ linkEdit, googleApi, labels }) => {
6848 stevensc 19
 
11131 stevensc 20
	const [modalToShow, setModalToShow] = useState(null)
21
	const [itemsData, setItemsData] = useState({
22
		title: '',
23
		status: '',
24
		description: '',
25
		location: '',
26
		employment_type: '',
27
		last_date_of_application: '',
28
		job_category: '',
29
		experience: '',
30
		salary: '',
31
		degrees: [],
32
		languages: [],
33
		skills: []
34
	})
35
	const [itemsRoutes, setItemsRoutes] = useState({
36
		route_degrees: '',
37
		route_employment_type: '',
38
		route_experience: '',
39
		route_extended: '',
40
		route_job_category: '',
41
		route_languages: '',
42
		route_last_date_of_application: '',
43
		route_location: '',
44
		route_salary: '',
45
		route_skills: '',
46
		route_status: '',
47
		route_title: ''
48
	})
6848 stevensc 49
 
11131 stevensc 50
	const closeModal = () => setModalToShow(null)
7066 stevensc 51
 
11131 stevensc 52
	useEffect(() => {
53
		getData(linkEdit)
54
			.then(results => {
55
				setItemsData({
56
					...itemsData,
57
					title: results.title,
58
					status: results.status,
59
					description: results.description,
60
					location: results.location,
61
					employment_type: results.employment_type,
62
					last_date_of_application: results.last_date_of_application,
63
					job_category: results.job_category,
64
					experience: results.experience,
65
					salary: results.salary,
66
					degrees: results.degrees,
67
					languages: results.languages,
68
					skills: results.skills
69
				})
70
				setItemsRoutes({
71
					route_degrees: results.route_degrees,
72
					route_employment_type: results.route_employment_type,
73
					route_experience: results.route_experience,
74
					route_extended: results.route_extended,
75
					route_job_category: results.route_job_category,
76
					route_languages: results.route_languages,
77
					route_last_date_of_application: results.route_last_date_of_application,
78
					route_location: results.route_location,
79
					route_salary: results.route_salary,
80
					route_skills: results.route_skills,
81
					route_status: results.route_status,
82
					route_title: results.route_title
83
				})
84
			})
85
	}, [modalToShow])
6848 stevensc 86
 
11131 stevensc 87
	const ModalOptions = {
15057 stevensc 88
		'Estatus': <StatusModal title={labels.STATUS} closeModal={closeModal} modalData={itemsData.status} dataLink={itemsRoutes.route_status} />,
15223 stevensc 89
		'Titulo': <TitleModal title={labels.TITLE} closeModal={closeModal} modalData={itemsData.title} dataLink={itemsRoutes.route_title} />,
15057 stevensc 90
		'Visión general': <OverviewModal title={labels.OVERVIEW} closeModal={closeModal} modalData={itemsData.description} dataLink={itemsRoutes.route_extended} />,
91
		'Último día de aplicación': <LastAplicationDayModal title={labels.LAST_DATE_OF_APPLICATION} closeModal={closeModal} modalData={itemsData.last_date_of_application} dataLink={itemsRoutes.route_last_date_of_application} />,
92
		'Tipo de empleo': <EmploymentTypeModal title={labels.EMPLOYMENT_TYPE} closeModal={closeModal} modalData={itemsData.employment_type} dataLink={itemsRoutes.route_employment_type} />,
93
		'Ubicación': <LocationModal title={labels.LOCATION} closeModal={closeModal} modalData={itemsData.location} dataLink={itemsRoutes.route_location} googleApiKey={googleApi} />,
94
		'Idiomas': <LanguageModal title={labels.LANGUAGES} closeModal={closeModal} dataLink={itemsRoutes.route_languages} />,
95
		'Habilidades': <SkillsModal title={labels.SKILLS} closeModal={closeModal} dataLink={itemsRoutes.route_skills} />,
96
		'Grados': <DegreesModal title={labels.DEGREES} closeModal={closeModal} dataLink={itemsRoutes.route_degrees} />,
97
		'Categoría': <CategoryModal title={labels.CATEGORIE} closeModal={closeModal} dataLink={itemsRoutes.route_job_category} />,
98
		'Experiencia': <ExperienceModal title={labels.EXPERIENCE} closeModal={closeModal} dataLink={itemsRoutes.route_experience} />,
99
		'Salario': <SalaryModal title={labels.SALARY} closeModal={closeModal} dataLink={itemsRoutes.route_salary} />,
11131 stevensc 100
	}
7066 stevensc 101
 
11131 stevensc 102
	return (
103
		<>
104
			<section className="content-header">
105
				<div className="container-fluid">
106
					<div className="row mb-2">
107
						<div className="col-sm-12">
108
							<Link to='/jobs' className='text-decoration-none text-body'>
109
								<h1>
110
									<i className='fa fa-angle-left fw-bold mr-2' />
15057 stevensc 111
									{labels.EDIT_JOB}
11131 stevensc 112
								</h1>
113
							</Link>
114
						</div>
115
					</div>
116
				</div>
117
			</section>
118
			<section className="content">
119
				<div className="container-fluid">
120
					<div className="row">
121
						<div className="col-lg-3">
122
						</div>
123
						<div className="col-lg-6">
124
							<div className="main-ws-sec">
15057 stevensc 125
								<EditItem title={labels.STATUS} data={itemsData.status} showModal={setModalToShow} />
126
								<EditItem title={labels.TITLE} data={itemsData.title} showModal={setModalToShow} />
127
								<EditItem title={labels.OVERVIEW} data={itemsData.description} showModal={setModalToShow} />
128
								<EditItem title={labels.LAST_DATE_OF_APPLICATION} data={itemsData.last_date_of_application} showModal={setModalToShow} />
129
								<EditItem title={labels.EMPLOYMENT_TYPE} data={itemsData.employment_type} showModal={setModalToShow} />
130
								<EditItem title={labels.LOCATION} data={itemsData.location} showModal={setModalToShow} />
131
								<EditItem title={labels.EXPERIENCE} data={itemsData.experience} showModal={setModalToShow} />
132
								<EditItem title={labels.SALARY} data={itemsData.salary} showModal={setModalToShow} />
133
								<EditItem title={labels.CATEGORIE} data={itemsData.job_category} showModal={setModalToShow} />
134
								<EditItem title={labels.SKILLS} data={itemsData.skills} showModal={setModalToShow} />
135
								<EditItem title={labels.LANGUAGES} data={itemsData.languages} showModal={setModalToShow} />
136
								<EditItem title={labels.DEGREES} data={itemsData.degrees} showModal={setModalToShow} />
11131 stevensc 137
							</div>
15223 stevensc 138
							{ModalOptions[modalToShow]}
11131 stevensc 139
						</div>
140
						<div className="col-lg-3">
141
						</div>
142
					</div>
143
				</div>
144
			</section>
145
		</>
146
	)
6628 stevensc 147
}
148
 
149
export default JobsEditView