Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5831 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5831 Rev 5832
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
2
import React, { useState } from 'react'
3
import parse from 'html-react-parser'
3
import parse from 'html-react-parser'
-
 
4
import { axios } from '../../../utils'
-
 
5
import { useDispatch } from 'react-redux'
-
 
6
import { addNotification } from '../../../redux/notification/notification.actions'
Línea 4... Línea -...
4
 
-
 
5
import Widget from './widget/Widget'
7
 
6
import JobAttr from './components/JobAttr'
8
import JobAttr from './components/JobAttr'
-
 
9
import ApplyModal from './components/ApplyModal'
7
import ApplyModal from './components/ApplyModal'
10
import ClientInfo from './components/ClientInfo'
8
import Description from './components/Description'
-
 
Línea 9... Línea 11...
9
import ApplicationSidebar from './components/ApplicationSidebar'
11
import Description from './components/Description'
10
 
12
 
11
const View = ({
13
const View = ({
12
  jobId,
14
  jobId,
Línea 34... Línea 36...
34
  companyWebsite,
36
  companyWebsite,
35
  companyFoundationYear,
37
  companyFoundationYear,
36
  jobApplyOperation,
38
  jobApplyOperation,
37
  userProfiles,
39
  userProfiles,
38
}) => {
40
}) => {
-
 
41
  const TABS_OPTIONS = {
-
 
42
    info: 'Information',
-
 
43
    advance: 'Advance',
-
 
44
  }
-
 
45
  const [currentTab, setCurrentTab] = useState(TABS_OPTIONS.info)
39
  const [showApplyModal, setShowApplyModal] = useState(false)
46
  const [showApplyModal, setShowApplyModal] = useState(false)
-
 
47
  const [loading, setLoading] = useState(false)
40
  const [isJobApplied, setIsJobApplied] = useState(
48
  const [isJobApplied, setIsJobApplied] = useState(
41
    jobApplyOperation !== 'apply'
49
    jobApplyOperation !== 'apply'
42
  )
50
  )
Línea -... Línea 51...
-
 
51
 
-
 
52
  const dispatch = useDispatch()
43
 
53
 
-
 
54
  const handleShowApplyModal = () => setShowApplyModal(!showApplyModal)
44
  const handleShowApplyModal = () => setShowApplyModal(!showApplyModal)
55
 
Línea -... Línea 56...
-
 
56
  const handleApply = () => setIsJobApplied(!isJobApplied)
-
 
57
 
-
 
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))
45
  const handleApply = () => setIsJobApplied(!isJobApplied)
77
  }
46
 
78
 
47
  return (
79
  return (
48
    <>
80
    <>
49
      <main className="job-page container px-0">
81
      <main className="job-page container px-0">
-
 
82
        <ul className="job-tabs">
50
        <ul className="job-tabs">
83
          <li className="animated fadeIn">
-
 
84
            <button
-
 
85
              className="btn"
51
          <li data-tab="portfolio-dd" className="active animated fadeIn">
86
              onClick={() => setCurrentTab(TABS_OPTIONS.advance)}
52
            <a href="#" title="">
87
            >
53
              <img src="/images/ic3.png" alt="" />
88
              <img src="/images/ic3.png" alt="" />
54
              <span>Avance</span>
89
              <span>Avance</span>
55
            </a>
90
            </button>
-
 
91
          </li>
56
          </li>
92
          <li className="animated fadeIn">
-
 
93
            <button
-
 
94
              className="btn"
57
          <li data-tab="info-dd" className="animated fadeIn">
95
              onClick={() => setCurrentTab(TABS_OPTIONS.info)}
58
            <a href="#" title="">
96
            >
59
              <img src="/images/ic2.png" alt="" />
97
              <img src="/images/ic2.png" alt="" />
60
              <span>Información</span>
98
              <span>Información</span>
61
            </a>
99
            </button>
62
          </li>
100
          </li>
63
        </ul>
101
        </ul>
64
        <section className="job-main-section">
102
        <section className="job-main-section">
Línea 94... Línea 132...
94
          <JobAttr title="Habilidades" info={jobSkills} />
132
          <JobAttr title="Habilidades" info={jobSkills} />
95
          <JobAttr title="Idiomas" info={jobLanguages} />
133
          <JobAttr title="Idiomas" info={jobLanguages} />
96
          <JobAttr title="Grados" info={jobDegrees} />
134
          <JobAttr title="Grados" info={jobDegrees} />
97
        </section>
135
        </section>
98
        <div className="sidebar">
136
        <div className="sidebar">
99
          <ApplicationSidebar
137
          <button
100
            jobId={jobId}
138
            type="button"
101
            showModal={handleShowApplyModal}
139
            className={`btn ${isJobApplied ? 'btn-secondary' : 'btn-primary'}`}
102
            toggleApply={handleApply}
140
            onClick={isJobApplied ? removeApply : handleShowApplyModal}
103
            isJobApplied={isJobApplied}
141
            disabled={loading}
104
          />
142
          >
-
 
143
            {isJobApplied ? 'Quitar aplicación' : 'Aplicar'}
105
          <Widget
144
          </button>
106
            companyIndustry={companyIndustry}
145
          <ClientInfo
107
            companySize={companySize}
146
            companySize={companySize}
108
            companyAddress={companyAddress}
147
            companyAddress={companyAddress}
109
            companyWebsite={companyWebsite}
148
            companyWebsite={companyWebsite}
-
 
149
            companyIndustry={companyIndustry}
110
            companyFoundationYear={companyFoundationYear}
150
            companyFoundationYear={companyFoundationYear}
111
          />
151
          />
112
        </div>
152
        </div>
113
      </main>
153
      </main>
114
      <ApplyModal
154
      <ApplyModal
-
 
155
        jobId={jobId}
115
        show={showApplyModal}
156
        show={showApplyModal}
116
        onApplied={handleApply}
157
        onApplied={handleApply}
117
        onHide={() => setShowApplyModal(false)}
-
 
118
        jobId={jobId}
-
 
119
        userProfiles={userProfiles}
158
        userProfiles={userProfiles}
-
 
159
        onHide={() => setShowApplyModal(false)}
120
      />
160
      />
121
    </>
161
    </>
122
  )
162
  )
123
}
163
}