Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6801 | Rev 6806 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6801 Rev 6802
Línea 1... Línea 1...
1
import React, { useState, useEffect } from 'react'
1
import React, { useState, useEffect } from 'react'
2
import parse from 'html-react-parser'
-
 
3
import { Modal } from 'react-bootstrap'
2
import { Modal } from 'react-bootstrap'
4
import { axios } from '../../../utils'
3
import { axios } from '../../../utils'
5
import { useDispatch, useSelector } from 'react-redux'
4
import { useDispatch, useSelector } from 'react-redux'
6
import { addNotification } from '../../../redux/notification/notification.actions'
5
import { addNotification } from '../../../redux/notification/notification.actions'
-
 
6
import parse from 'html-react-parser'
7
import EditIcon from '@mui/icons-material/EditOutlined'
7
import EditIcon from '@mui/icons-material/EditOutlined'
Línea 8... Línea 8...
8
 
8
 
9
import ImageModal from '../../modals/ImageModal'
9
import ImageModal from '../../modals/ImageModal'
10
import CoverModal from '../../cover/CoverModal'
10
import CoverModal from '../../cover/CoverModal'
Línea 43... Línea 43...
43
  const labels = useSelector(({ intl }) => intl.labels)
43
  const labels = useSelector(({ intl }) => intl.labels)
44
  const dispatch = useDispatch()
44
  const dispatch = useDispatch()
Línea 45... Línea 45...
45
 
45
 
Línea -... Línea 46...
-
 
46
  const PATH = window.location.pathname
46
  const PATH = window.location.pathname
47
 
-
 
48
  const displayModal = () => {
Línea 47... Línea 49...
47
 
49
    setIsModalShow(!isModalShow)
48
  const displayModal = () => setIsModalShow(!isModalShow)
50
  }
49
 
51
 
-
 
52
  const getProfileData = async () => {
Línea 50... Línea 53...
50
  const getProfileData = async () => {
53
    try {
51
    try {
54
      const { data: response } = await axios.get(window.location.href)
-
 
55
      const { link_request, link_cancel } = response
52
      const { data: response } = await axios.get(window.location.href)
56
 
Línea 53... Línea 57...
53
 
57
      if (link_request) {
54
      if (response.link_request) {
58
        setConnectionUrl(link_request)
55
        return setConnectionUrl(response.link_request)
-
 
56
      }
-
 
57
 
59
        return
58
      return setConnectionUrl(response.link_cancel)
-
 
59
    } catch (error) {
60
      }
60
      console.log(error)
61
 
Línea 61... Línea 62...
61
      return dispatch(
62
      setConnectionUrl(link_cancel)
62
        addNotification({ style: 'danger', msg: 'Ha ocurrido un error' })
63
    } catch (err) {
63
      )
64
      dispatch(addNotification({ style: 'danger', msg: err }))
-
 
65
    }
Línea 64... Línea 66...
64
    }
66
  }
65
  }
-
 
66
 
67
 
67
  const connect = async () => {
-
 
68
    try {
68
  const connect = async () => {
Línea 69... Línea 69...
69
      const { data: response } = await axios.post(connectionUrl)
69
    try {
70
 
70
      const { data: response } = await axios.post(connectionUrl)
71
      if (!response.success) {
71
      const { data, success } = response
Línea 72... Línea 72...
72
        return dispatch(
72
 
73
          addNotification({ style: 'danger', msg: response.data })
73
      if (!success) {
74
        )
74
        return dispatch(addNotification({ style: 'danger', msg: data }))
75
      }
75
      }
76
 
76
 
77
      if (response.success && isModalShow) {
77
      if (success && isModalShow) {
78
        displayModal()
78
        displayModal()
Línea 79... Línea 79...
79
      }
79
      }
-
 
80
 
-
 
81
      await getProfileData()
Línea 80... Línea 82...
80
 
82
      dispatch(addNotification({ style: 'success', msg: data }))
81
      await getProfileData()
83
      setIsAdded(!isAdded)
82
      dispatch(addNotification({ style: 'success', msg: response.data }))
84
    } catch (error) {
83
      setIsAdded(!isAdded)
85
      dispatch(addNotification({ style: 'danger', msg: `Error: ${error}` }))
Línea 141... Línea 143...
141
                  onClick={(e) => {
143
                  onClick={(e) => {
142
                    e.preventDefault()
144
                    e.preventDefault()
143
                    setModalToShow('info')
145
                    setModalToShow('info')
144
                  }}
146
                  }}
145
                >
147
                >
146
                  {labels.PERSONAL_INFO}
148
                  {labels.personal_info}
147
                </a>
149
                </a>
148
              </div>
150
              </div>
149
              <div
151
              <div
150
                className="d-inline-flex align-items-center mt-2"
152
                className="d-inline-flex align-items-center mt-2"
151
                style={{ gap: '1rem' }}
153
                style={{ gap: '1rem' }}
152
              >
154
              >
153
                {Boolean(totalConnections) && view_total_connections && (
155
                {Boolean(totalConnections) && view_total_connections && (
154
                  <a href="/connection/my-connections" target="_blank">
156
                  <a href="/connection/my-connections" target="_blank">
155
                    {`${totalConnections} ${labels.CONNECTIONS}`}
157
                    {`${totalConnections} ${labels.connections}`}
156
                  </a>
158
                  </a>
157
                )}
159
                )}
158
                {Boolean(follower) && view_following && (
160
                {Boolean(follower) && view_following && (
159
                  <a
161
                  <a
160
                    href=""
162
                    href=""
161
                    className="cursor-auto"
163
                    className="cursor-auto"
162
                    onClick={(e) => e.preventDefault()}
164
                    onClick={(e) => e.preventDefault()}
163
                  >
165
                  >
164
                    {`${follower} ${labels.FOLLOWERS}`}
166
                    {`${follower} ${labels.followers}`}
165
                  </a>
167
                  </a>
166
                )}
168
                )}
167
                {Boolean(following) && view_following && (
169
                {Boolean(following) && view_following && (
168
                  <a href="/company/following-companies" target="_blank">
170
                  <a href="/company/following-companies" target="_blank">
169
                    {`${following} ${labels.FOLLOWING}`}
171
                    {`${following} ${labels.following}`}
170
                  </a>
172
                  </a>
171
                )}
173
                )}
172
              </div>
174
              </div>
173
              <div className="button-actions mt-2">
175
              <div className="button-actions mt-2">
174
                {connectionUrl && isAdded && (
176
                {connectionUrl && isAdded && (
175
                  <button
177
                  <button
176
                    className="btn button btn-primary"
178
                    className="btn button btn-primary"
177
                    onClick={() => displayModal()}
179
                    onClick={() => displayModal()}
178
                  >
180
                  >
179
                    {labels.CANCEL}
181
                    {labels.cancel}
180
                  </button>
182
                  </button>
181
                )}
183
                )}
182
                {connectionUrl && !isAdded && (
184
                {connectionUrl && !isAdded && (
183
                  <button
185
                  <button
184
                    className="btn button btn-primary"
186
                    className="btn button btn-primary"
185
                    onClick={() => connect()}
187
                    onClick={() => connect()}
186
                  >
188
                  >
187
                    {labels.CONNECT}
189
                    {labels.connect}
188
                  </button>
190
                  </button>
189
                )}
191
                )}
190
                {showContact && (
192
                {showContact && (
191
                  <a href={linkInmail} className="btn button btn-secondary">
193
                  <a href={linkInmail} className="btn button btn-secondary">
192
                    {labels.MESSAGE}
194
                    {labels.message}
193
                  </a>
195
                  </a>
194
                )}
196
                )}
195
              </div>
197
              </div>
196
            </div>
198
            </div>
197
            <div className="card-experiences">
199
            <div className="card-experiences">
Línea 267... Línea 269...
267
  const labels = useSelector(({ intl }) => intl.labels)
269
  const labels = useSelector(({ intl }) => intl.labels)
Línea 268... Línea 270...
268
 
270
 
269
  return (
271
  return (
270
    <Modal show={show} onHide={closeModal}>
272
    <Modal show={show} onHide={closeModal}>
271
      <Modal.Header closeButton>
273
      <Modal.Header closeButton>
272
        <h2>{labels.ABOUT_GROUP}</h2>
274
        <h2>{labels.about_group}</h2>
273
      </Modal.Header>
275
      </Modal.Header>
274
      <Modal.Body>
276
      <Modal.Body>
275
        <div className="description__label">
277
        <div className="description__label">
276
          <label htmlFor="name">{labels.FIRST_NAME}</label>
278
          <label htmlFor="name">{labels.first_name}</label>
277
          <p>{fullName}</p>
279
          <p>{fullName}</p>
278
        </div>
280
        </div>
279
        {overview && (
281
        {overview && (
280
          <div className="description__label">
282
          <div className="description__label">
281
            <label htmlFor="name">{labels.DESCRIPTION}</label>
283
            <label htmlFor="name">{labels.description}</label>
282
            {parse(overview)}
284
            {parse(overview)}
283
          </div>
285
          </div>
284
        )}
286
        )}
285
        {formatted_address && (
287
        {formatted_address && (
286
          <div className="description__label">
288
          <div className="description__label">
287
            <label htmlFor="name">{labels.LOCATION}</label>
289
            <label htmlFor="name">{labels.location}</label>
288
            <p>{formatted_address}</p>
290
            <p>{formatted_address}</p>
289
          </div>
291
          </div>
290
        )}
292
        )}
291
        {total_connections && (
293
        {total_connections && (
292
          <div className="description__label">
294
          <div className="description__label">
293
            <label htmlFor="name">{labels.CONNECTIONS}</label>
295
            <label htmlFor="name">{labels.connections}</label>
294
            <p>{total_connections}</p>
296
            <p>{total_connections}</p>
295
          </div>
297
          </div>
296
        )}
298
        )}
297
        {follower && (
299
        {follower && (
298
          <div className="description__label">
300
          <div className="description__label">
299
            <label htmlFor="name">{labels.FOLLOWERS}</label>
301
            <label htmlFor="name">{labels.followers}</label>
300
            <p>{follower}</p>
302
            <p>{follower}</p>
301
          </div>
303
          </div>
302
        )}
304
        )}
303
        {following && (
305
        {following && (
304
          <div className="description__label">
306
          <div className="description__label">
305
            <label htmlFor="name">{labels.FOLLOWING}</label>
307
            <label htmlFor="name">{labels.following}</label>
306
            <p>{following}</p>
308
            <p>{following}</p>
307
          </div>
309
          </div>
308
        )}
310
        )}
309
        <div className="description__label">
311
        <div className="description__label">
310
          <label htmlFor="name">{labels.SOCIAL_NETWORKS}</label>
312
          <label htmlFor="name">{labels.social_networks}</label>
311
          {facebook && (
313
          {facebook && (
312
            <a href={facebook} target="_blank" rel="noreferrer">
314
            <a href={facebook} target="_blank" rel="noreferrer">
313
              <p className="mb-1">{facebook}</p>
315
              <p className="mb-1">{facebook}</p>
314
            </a>
316
            </a>