| 3082 |
stevensc |
1 |
import React, { useState } from 'react'
|
| 5 |
stevensc |
2 |
import { useParams } from 'react-router-dom'
|
|
|
3 |
import { useDispatch } from 'react-redux'
|
| 2806 |
stevensc |
4 |
import { Grid, Tab, Tabs } from '@mui/material'
|
| 5 |
stevensc |
5 |
|
| 3082 |
stevensc |
6 |
import { useFetch } from '@hooks'
|
|
|
7 |
import ApplyModal from '@components/job/ApplyModal'
|
|
|
8 |
import JobAttr from '@components/job/JobAttr'
|
|
|
9 |
import { axios, parse } from '@utils'
|
|
|
10 |
import Description from '@components/job/Description'
|
|
|
11 |
import { addNotification } from '@store/notification/notification.actions'
|
|
|
12 |
import ClientInfo from '@components/job/ClientInfo'
|
|
|
13 |
import Spinner from '@components/UI/Spinner'
|
| 5 |
stevensc |
14 |
|
|
|
15 |
const JobViewPage = () => {
|
|
|
16 |
const [showApplyModal, setShowApplyModal] = useState(false)
|
|
|
17 |
const [loading, setLoading] = useState(false)
|
|
|
18 |
const { uuid } = useParams()
|
|
|
19 |
const dispatch = useDispatch()
|
|
|
20 |
|
| 3082 |
stevensc |
21 |
const { data: job, isLoading } = useFetch(`/job/view/${uuid}`)
|
|
|
22 |
|
|
|
23 |
const isJobApplied = job?.job_apply_operation === 'remove-apply'
|
|
|
24 |
|
| 5 |
stevensc |
25 |
const handleShowApplyModal = () => {
|
|
|
26 |
setShowApplyModal(!showApplyModal)
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
const handleApply = () => {
|
| 3082 |
stevensc |
30 |
// setIsJobApplied(!isJobApplied)
|
| 5 |
stevensc |
31 |
}
|
|
|
32 |
|
|
|
33 |
const removeApply = async () => {
|
|
|
34 |
setLoading(true)
|
| 3082 |
stevensc |
35 |
try {
|
|
|
36 |
const response = await axios.post(`/job/remove-apply-job/${job}`)
|
|
|
37 |
const { data, success } = response.data
|
|
|
38 |
if (!success) throw new Error('Error al eliminar la aplicación')
|
|
|
39 |
dispatch(addNotification({ styled: 'success', msg: data }))
|
|
|
40 |
handleApply()
|
|
|
41 |
} catch (error) {
|
|
|
42 |
dispatch(addNotification({ styled: 'danger', msg: error.message }))
|
|
|
43 |
} finally {
|
|
|
44 |
setLoading(false)
|
|
|
45 |
}
|
|
|
46 |
}
|
| 5 |
stevensc |
47 |
|
| 3082 |
stevensc |
48 |
if (isLoading) {
|
|
|
49 |
return <Spinner />
|
| 5 |
stevensc |
50 |
}
|
|
|
51 |
|
|
|
52 |
return (
|
|
|
53 |
<>
|
| 2806 |
stevensc |
54 |
<Tabs>
|
|
|
55 |
<Tab label='Avance' value='user' disableRipple />
|
|
|
56 |
<Tab label='Información' value='group' disableRipple />
|
|
|
57 |
</Tabs>
|
| 5 |
stevensc |
58 |
|
| 2806 |
stevensc |
59 |
<Grid container spacing={2}>
|
| 3082 |
stevensc |
60 |
<Grid item xs md={8} spacing={3}>
|
| 2806 |
stevensc |
61 |
<Description
|
|
|
62 |
jobId={job?.job_uuid}
|
|
|
63 |
companyId={job?.company_uuid}
|
|
|
64 |
companyImage={job?.company_image}
|
|
|
65 |
jobTitle={job?.job_title}
|
|
|
66 |
companyName={job?.company_name}
|
|
|
67 |
timeElapsed={job?.timeElapsed}
|
|
|
68 |
location={job?.location}
|
|
|
69 |
jobSaved={job?.job_save_operation}
|
|
|
70 |
lastDateOfApplication={job?.last_date_of_application}
|
|
|
71 |
employmentType={job?.employment_type}
|
|
|
72 |
jobCategory={job?.job_category}
|
|
|
73 |
jobDescription={job?.job_description}
|
|
|
74 |
jobSkills={job?.job_skills}
|
|
|
75 |
totalApplications={job?.total_applications}
|
|
|
76 |
jobVisits={job?.job_visits}
|
|
|
77 |
/>
|
| 3082 |
stevensc |
78 |
<JobAttr title='Visión general' info={parse(job?.job_description)} />
|
| 2806 |
stevensc |
79 |
<JobAttr
|
|
|
80 |
title='Último día de aplicación'
|
|
|
81 |
info={job?.last_date_of_application}
|
|
|
82 |
/>
|
|
|
83 |
<JobAttr title='Tipo de empleo' info={job?.employment_type} />
|
|
|
84 |
<JobAttr title='Ubicación' info={job?.location} />
|
|
|
85 |
<JobAttr title='Experiencia' info={job?.experience} />
|
|
|
86 |
<JobAttr title='Salario' info={job?.salary} />
|
|
|
87 |
<JobAttr title='Categoría' info={job?.job_category} />
|
|
|
88 |
<JobAttr title='Habilidades' info={job?.job_skills} />
|
|
|
89 |
<JobAttr title='Idiomas' info={job?.job_languages} />
|
|
|
90 |
<JobAttr title='Grados' info={job?.job_degrees} />
|
| 3082 |
stevensc |
91 |
</Grid>
|
| 2806 |
stevensc |
92 |
|
| 3082 |
stevensc |
93 |
<Grid item xs md={4}>
|
| 2806 |
stevensc |
94 |
<button
|
|
|
95 |
type='button'
|
|
|
96 |
className={`btn ${isJobApplied ? 'btn-secondary' : 'btn-primary'}`}
|
|
|
97 |
onClick={isJobApplied ? removeApply : handleShowApplyModal}
|
|
|
98 |
disabled={loading}
|
|
|
99 |
>
|
| 3082 |
stevensc |
100 |
{job?.job_apply_operation === 'remove-apply'
|
|
|
101 |
? 'Quitar aplicación'
|
|
|
102 |
: 'Aplicar'}
|
| 2806 |
stevensc |
103 |
</button>
|
|
|
104 |
<ClientInfo
|
|
|
105 |
companySize={job?.company_size}
|
|
|
106 |
companyAddress={job?.company_address}
|
|
|
107 |
companyWebsite={job?.company_website}
|
|
|
108 |
companyIndustry={job?.company_industry}
|
|
|
109 |
companyFoundationYear={job?.company_foundation_year}
|
|
|
110 |
/>
|
| 3082 |
stevensc |
111 |
</Grid>
|
| 2806 |
stevensc |
112 |
</Grid>
|
|
|
113 |
|
| 5 |
stevensc |
114 |
<ApplyModal
|
|
|
115 |
jobId={job?.job_uuid}
|
|
|
116 |
show={showApplyModal}
|
|
|
117 |
onApplied={handleApply}
|
|
|
118 |
userProfiles={job?.user_profiles}
|
|
|
119 |
onHide={() => setShowApplyModal(false)}
|
|
|
120 |
/>
|
|
|
121 |
</>
|
|
|
122 |
)
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
export default JobViewPage
|