Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 5414 Rev 5416
Línea 1... Línea 1...
1
/* eslint-disable camelcase */
1
/* eslint-disable camelcase */
2
/* eslint-disable react/prop-types */
2
/* eslint-disable react/prop-types */
3
import React, { useEffect, useRef, useState } from 'react'
3
import React, { useEffect, useRef, useState } from 'react'
4
import parse from 'html-react-parser'
4
import parse from 'html-react-parser'
5
import { axios } from '../../../utils'
-
 
6
import { connect } from 'react-redux'
5
import { connect } from 'react-redux'
7
import { setIntlLabels } from '../../../redux/intl/intl.action'
6
import { setIntlLabels } from '../../../redux/intl/intl.action'
8
import { setTimelineUrl } from '../../../redux/feed/feed.actions'
7
import { setTimelineUrl } from '../../../redux/feed/feed.actions'
9
import { addNotification } from '../../../redux/notification/notification.actions'
8
import { addNotification } from '../../../redux/notification/notification.actions'
10
import Spinner from '../../../shared/loading-spinner/Spinner'
9
import Spinner from '../../../shared/loading-spinner/Spinner'
11
import FeedSection from '../../../dashboard/components/feed-section/FeedSection'
10
import FeedSection from '../../../dashboard/components/feed-section/FeedSection'
12
import SuggestWidget from '../../../shared/helpers/my-groups-helper/SuggestWidget'
11
import SuggestWidget from '../../../shared/helpers/my-groups-helper/SuggestWidget'
13
import CompanyFollowersHelper from '../../../shared/helpers/company-followers-helper/CompanyFollowers'
12
import CompanyFollowersHelper from '../../../shared/helpers/company-followers-helper/CompanyFollowers'
-
 
13
import CompanyInfo from '../components/CompanyInfo'
Línea 14... Línea 14...
14
 
14
 
15
const TABS = {
15
const TABS = {
16
  FEEDS: 'FEEDS',
16
  FEEDS: 'FEEDS',
17
  INFO: 'INFO'
17
  INFO: 'INFO'
Línea 39... Línea 39...
39
    companySize,
39
    companySize,
40
    foundationYear,
40
    foundationYear,
41
    website,
41
    website,
42
    timeline
42
    timeline
43
  } = backendVars
43
  } = backendVars
44
 
-
 
45
  const [authorizedLinks, setAuthorizedLinks] = useState(null)
-
 
46
  const [followers, setFollowers] = useState(totalFollowers)
-
 
47
  const [initialLoading, setInitialLoading] = useState(true)
44
  const [initialLoading, setInitialLoading] = useState(true)
48
  const [isFollower, setIsFollower] = useState(false)
45
  const [isFollower, setIsFollower] = useState(false)
49
  const [currentTab, setCurrentTab] = useState(TABS.INFO)
46
  const [currentTab, setCurrentTab] = useState(TABS.INFO)
50
  const shouldSetInitialTab = useRef(true)
47
  const shouldSetInitialTab = useRef(true)
Línea 51... Línea 48...
51
 
48
 
52
  useEffect(() => {
49
  useEffect(() => {
53
    setTimelineUrl(timeline)
-
 
54
    fetchAuthorizedLinks()
50
    setTimelineUrl(timeline)
55
    shouldSetInitialTab.current = false
51
    shouldSetInitialTab.current = false
56
    setInitialLoading(false)
52
    setInitialLoading(false)
57
    setIntlLabels(labels)
53
    setIntlLabels(labels)
Línea 61... Línea 57...
61
    isFollower
57
    isFollower
62
      ? setCurrentTab(TABS.FEEDS)
58
      ? setCurrentTab(TABS.FEEDS)
63
      : setCurrentTab(TABS.INFO)
59
      : setCurrentTab(TABS.INFO)
64
  }, [isFollower])
60
  }, [isFollower])
Línea 65... Línea -...
65
 
-
 
66
  const fetchAuthorizedLinks = async () => {
-
 
67
    const response = await axios.get(`/company/view/${companyId}`)
-
 
68
    const resData = response.data
61
 
69
    if (resData.success) {
-
 
70
      setAuthorizedLinks(resData.data)
-
 
71
      setFollowers(resData.data.total_followers)
-
 
72
      if (resData.data.link_unfollow) {
-
 
73
        setIsFollower(true)
62
  useEffect(() => {
74
        if (shouldSetInitialTab.current) setCurrentTab(TABS.FEEDS)
-
 
75
      } else {
63
    if (shouldSetInitialTab.current && isFollower) setCurrentTab(TABS.FEEDS)
76
        setIsFollower(false)
-
 
77
      }
-
 
78
    }
-
 
79
  }
-
 
80
 
-
 
81
  const handleButtonAction = async (link) => {
-
 
82
    const response = await axios.post(link)
-
 
83
    const resData = response.data
-
 
84
    if (resData.success) {
-
 
85
      addNotification({
-
 
86
        style: 'success',
-
 
87
        msg: resData.data
-
 
88
      })
-
 
89
      fetchAuthorizedLinks()
-
 
90
    } else {
-
 
91
      addNotification({
-
 
92
        style: 'danger',
-
 
93
        msg: 'ha ocurrido un error'
-
 
94
      })
-
 
95
    }
-
 
Línea 96... Línea 64...
96
  }
64
  }, [isFollower])
Línea -... Línea 65...
-
 
65
 
-
 
66
  const changeCurrentTab = (tab) => setCurrentTab(tab)
97
 
67
 
98
  const changeCurrentTab = (tab) => setCurrentTab(tab)
68
  const markIsFollower = (val) => setIsFollower(val)
99
 
69
 
100
  return (
-
 
101
    <>
-
 
102
      <section className="cover-sec">
70
  return (
103
        <img
-
 
104
          id="user-cover-img"
-
 
105
          src={`/storage/type/company-cover/code/${companyId}/${cover ? `filename/${cover}` : ''
-
 
106
            }`}
71
    <>
107
          alt="cover-image"
72
      <section className="cover-sec">
108
        />
73
        <img src={`/storage/type/company-cover/code/${companyId}/${cover ? `filename/${cover}` : ''}`} alt="cover-image" />
109
      </section>
-
 
110
      <main className="main-section-data container px-0 mt-3">
-
 
111
        <div className="main-left-sidebar">
74
      </section>
112
          <div className="user_profile">
-
 
113
            <div className="user-pro-img">
75
      <main className="main-section-data container px-0 mt-3">
114
              <img
-
 
115
                src={`/storage/type/company/code/${companyId}/${image ? `filename/${image}` : ''}`}
-
 
116
                alt="profile-image"
-
 
117
              />
76
        <div className="main-left-sidebar">
118
            </div>
-
 
119
            <div className="user_pro_status horizontal-list">
-
 
120
              <h1>{companyName}</h1>
77
          <CompanyInfo
121
              <div className="row px-5" style={{ marginTop: '10px' }}>
-
 
122
                {facebook &&
-
 
123
                  <i
-
 
124
                    onClick={() => window.location.href = facebook}
-
 
125
                    className="cursor-pointer fa fa-facebook"
-
 
126
                    style={{ fontSize: '1.4rem' }}
78
            companyId={companyId}
127
                  />
-
 
128
                }
-
 
129
                {twitter &&
-
 
130
                  <i
-
 
131
                    onClick={() => window.location.href = twitter}
-
 
132
                    className="cursor-pointer fa fa-twitter"
-
 
133
                    style={{ fontSize: '1.4rem' }}
79
            companyName={companyName}
134
                  />
-
 
135
                }
-
 
136
                {instagram &&
-
 
137
                  <i
-
 
138
                    onClick={() => window.location.href = instagram}
-
 
139
                    className="fa fa-instagram cursor-pointer"
-
 
140
                    style={{ fontSize: '1.4rem' }}
-
 
141
                  />
-
 
142
                }
80
            image={image}
143
              </div>
-
 
144
              <div className="container horizontal-list">
-
 
145
                <div className="row ">
-
 
146
                  <div className="members_count">
-
 
147
                    <b style={{ fontSize: '1rem' }} id="total-followers">{followers}</b>
-
 
148
                    <p style={{ fontSize: '1rem' }} className="ellipsis">Seguidores</p>
-
 
149
                  </div>
-
 
150
                  {authorizedLinks?.link_unfollow &&
-
 
151
                    <button
-
 
152
                      className="btn btn-secondary"
-
 
153
                      onClick={() => handleButtonAction(authorizedLinks?.link_unfollow)}
-
 
154
                    >
-
 
155
                      Dejar de seguir
-
 
156
                    </button>
-
 
157
                  }
-
 
158
                  {authorizedLinks?.link_follow &&
-
 
159
                    <button
-
 
160
                      className="btn btn-secondary"
-
 
161
                      onClick={() => handleButtonAction(authorizedLinks?.link_follow)}
-
 
162
                    >
-
 
163
                      Seguir
-
 
164
                    </button>
-
 
165
                  }
-
 
166
                  {
-
 
167
                    (authorizedLinks?.link_request && authorizedLinks?.link_unfollow) &&
-
 
168
                    <button
-
 
169
                      className="btn btn-tertiary"
-
 
170
                      onClick={() => handleButtonAction(authorizedLinks?.link_request)}
-
 
171
                    >
-
 
172
                      ¿Trabaja en esta empresa?
-
 
173
                    </button>
-
 
174
                  }
-
 
175
                  {authorizedLinks?.link_accept &&
-
 
176
                    <button
-
 
177
                      className="btn btn-tertiary"
-
 
178
                      onClick={() => handleButtonAction(authorizedLinks?.link_accept)}
-
 
179
                    >
-
 
180
                      Aceptar
-
 
181
                    </button>
-
 
182
                  }
81
            facebook={facebook}
183
                  {authorizedLinks?.link_cancel &&
-
 
184
                    <button
-
 
185
                      title=""
-
 
186
                      className="btn btn-tertiary"
-
 
187
                      onClick={() => handleButtonAction(authorizedLinks?.link_cancel)}
-
 
188
                    >
-
 
189
                      Cancelar
-
 
190
                    </button>
-
 
191
                  }
-
 
192
                  {authorizedLinks?.link_reject &&
-
 
193
                    <button
-
 
194
                      title=""
-
 
195
                      className="btn btn-tertiary"
-
 
196
                      onClick={() => handleButtonAction(authorizedLinks?.link_reject)}
-
 
197
                    >
-
 
198
                      Rechazar
-
 
199
                    </button>
-
 
200
                  }
-
 
201
                  {authorizedLinks?.link_leave &&
-
 
202
                    <button
-
 
203
                      data-link="{{>link_leave}}"
-
 
204
                      title=""
-
 
205
                      className="btn btn-tertiary"
82
            instagram={instagram}
206
                      onClick={() => handleButtonAction(authorizedLinks?.link_leave)}
-
 
207
                    >
-
 
208
                      Abandonar esta empresa
-
 
209
                    </button>
-
 
210
                  }
-
 
211
                  {authorizedLinks?.link_contact &&
-
 
212
                    <a
-
 
213
                      href={authorizedLinks?.link_contact}
-
 
214
                      className="btn btn-primary"
-
 
215
                    >
-
 
216
                      Mensaje
-
 
217
                    </a>
-
 
218
                  }
-
 
219
                </div>
83
            totalFollowers={totalFollowers}
220
              </div>
84
            twitter={twitter}
221
            </div>
85
            markFollower={markIsFollower}
222
          </div>
86
          />
223
          <div className="d-none d-md-block">
87
          <div className="d-none d-md-block">
224
            <CompanyFollowersHelper companyId={companyId} />
88
            <CompanyFollowersHelper companyId={companyId} />