Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5831 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3564 stevensc 1
/* eslint-disable react/prop-types */
5822 stevensc 2
import React, { useState } from 'react'
3
import parse from 'html-react-parser'
5832 stevensc 4
import { axios } from '../../../utils'
5
import { useDispatch } from 'react-redux'
6
import { addNotification } from '../../../redux/notification/notification.actions'
1 www 7
 
5822 stevensc 8
import JobAttr from './components/JobAttr'
9
import ApplyModal from './components/ApplyModal'
5832 stevensc 10
import ClientInfo from './components/ClientInfo'
5822 stevensc 11
import Description from './components/Description'
12
 
5000 stevensc 13
const View = ({
14
  jobId,
15
  companyId,
16
  companyImage,
17
  jobTitle,
18
  companyName,
19
  timeElapsed,
20
  location,
21
  jobSaved,
22
  lastDateOfApplication,
23
  employmentType,
24
  jobCategory,
25
  jobDescription,
26
  jobSkills,
27
  totalApplications,
28
  jobVisits,
29
  experience,
30
  salary,
31
  jobLanguages,
32
  jobDegrees,
33
  companyIndustry,
34
  companySize,
35
  companyAddress,
36
  companyWebsite,
37
  companyFoundationYear,
38
  jobApplyOperation,
39
  userProfiles,
40
}) => {
5832 stevensc 41
  const TABS_OPTIONS = {
42
    info: 'Information',
43
    advance: 'Advance',
44
  }
45
  const [currentTab, setCurrentTab] = useState(TABS_OPTIONS.info)
5822 stevensc 46
  const [showApplyModal, setShowApplyModal] = useState(false)
5832 stevensc 47
  const [loading, setLoading] = useState(false)
1 www 48
  const [isJobApplied, setIsJobApplied] = useState(
5822 stevensc 49
    jobApplyOperation !== 'apply'
50
  )
1 www 51
 
5832 stevensc 52
  const dispatch = useDispatch()
53
 
5822 stevensc 54
  const handleShowApplyModal = () => setShowApplyModal(!showApplyModal)
5832 stevensc 55
 
5822 stevensc 56
  const handleApply = () => setIsJobApplied(!isJobApplied)
1 www 57
 
5832 stevensc 58
  const removeApply = async () => {
59
    setLoading(true)
60
    axios
61
      .post(`/job/remove-apply-job/${jobId}`)
62
      .then(({ data: response }) => {
63
        const { data, success } = response
64
 
65
        if (!success) {
66
          const errorMessage =
67
            typeof data === 'string'
68
              ? data
69
              : 'Ha ocurrido un error, por favor intente más tarde'
70
 
71
          dispatch(addNotification({ styled: 'danger', msg: errorMessage }))
72
        }
73
 
74
        handleApply()
75
      })
76
      .finally(() => setLoading(false))
77
  }
78
 
1 www 79
  return (
5000 stevensc 80
    <>
5827 stevensc 81
      <main className="job-page container px-0">
5828 stevensc 82
        <ul className="job-tabs">
5832 stevensc 83
          <li className="animated fadeIn">
84
            <button
85
              className="btn"
86
              onClick={() => setCurrentTab(TABS_OPTIONS.advance)}
87
            >
5828 stevensc 88
              <img src="/images/ic3.png" alt="" />
89
              <span>Avance</span>
5832 stevensc 90
            </button>
5828 stevensc 91
          </li>
5832 stevensc 92
          <li className="animated fadeIn">
93
            <button
94
              className="btn"
95
              onClick={() => setCurrentTab(TABS_OPTIONS.info)}
96
            >
5828 stevensc 97
              <img src="/images/ic2.png" alt="" />
98
              <span>Información</span>
5832 stevensc 99
            </button>
5828 stevensc 100
          </li>
101
        </ul>
5822 stevensc 102
        <section className="job-main-section">
103
          <div className="description_header fadeIn">
104
            <Description
105
              jobId={jobId}
106
              companyId={companyId}
107
              companyImage={companyImage}
108
              jobTitle={jobTitle}
109
              companyName={companyName}
110
              timeElapsed={timeElapsed}
111
              location={location}
112
              jobSaved={jobSaved}
113
              lastDateOfApplication={lastDateOfApplication}
114
              employmentType={employmentType}
115
              jobCategory={jobCategory}
116
              jobDescription={jobDescription}
117
              jobSkills={jobSkills}
118
              totalApplications={totalApplications}
119
              jobVisits={jobVisits}
120
            />
121
          </div>
122
          <JobAttr title="Visión general" info={parse(jobDescription)} />
123
          <JobAttr
124
            title="Último día de aplicación"
125
            info={lastDateOfApplication}
126
          />
127
          <JobAttr title="Tipo de empleo" info={employmentType} />
128
          <JobAttr title="Ubicación" info={location} />
129
          <JobAttr title="Experiencia" info={experience} />
130
          <JobAttr title="Salario" info={salary} />
131
          <JobAttr title="Categoría" info={jobCategory} />
132
          <JobAttr title="Habilidades" info={jobSkills} />
133
          <JobAttr title="Idiomas" info={jobLanguages} />
134
          <JobAttr title="Grados" info={jobDegrees} />
135
        </section>
136
        <div className="sidebar">
5832 stevensc 137
          <button
138
            type="button"
139
            className={`btn ${isJobApplied ? 'btn-secondary' : 'btn-primary'}`}
140
            onClick={isJobApplied ? removeApply : handleShowApplyModal}
141
            disabled={loading}
142
          >
143
            {isJobApplied ? 'Quitar aplicación' : 'Aplicar'}
144
          </button>
145
          <ClientInfo
5822 stevensc 146
            companySize={companySize}
147
            companyAddress={companyAddress}
148
            companyWebsite={companyWebsite}
5832 stevensc 149
            companyIndustry={companyIndustry}
5822 stevensc 150
            companyFoundationYear={companyFoundationYear}
151
          />
152
        </div>
153
      </main>
1 www 154
      <ApplyModal
5832 stevensc 155
        jobId={jobId}
1 www 156
        show={showApplyModal}
5822 stevensc 157
        onApplied={handleApply}
5832 stevensc 158
        userProfiles={userProfiles}
1 www 159
        onHide={() => setShowApplyModal(false)}
160
      />
5000 stevensc 161
    </>
5822 stevensc 162
  )
163
}
1 www 164
 
5822 stevensc 165
export default View