Proyectos de Subversion LeadersLinked - Backend

Rev

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