Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4539 | Rev 5912 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4531 stevensc 1
/* eslint-disable react/prop-types */
4534 stevensc 2
import React, { useEffect, useState } from 'react'
4539 stevensc 3
import { axios } from '../../../../../utils';
4
import { useDispatch } from 'react-redux';
5
import { setTimelineUrl } from '../../../../../redux/feed/feed.actions';
4538 stevensc 6
import FeedList from '../../../../../dashboard/templates/linkedin/Feed/FeedList';
4531 stevensc 7
import GroupInfo from '../../../../../group/view/templates/linkedin/components/GroupInfo'
4537 stevensc 8
import AboutCompany from '../components/AboutCompany';
4538 stevensc 9
import CompanyFollowers from '../components/CompanyFollowers';
4540 stevensc 10
import CompanyActions from '../components/CompanyActions';
4531 stevensc 11
 
12
const View = ({ backendVars }) => {
4534 stevensc 13
    const [authorizedLinks, setAuthorizedLinks] = useState(null);
14
    const [isFollower, setIsFollower] = useState(false);
4539 stevensc 15
    const dispatch = useDispatch()
4534 stevensc 16
 
17
    useEffect(() => {
4539 stevensc 18
        dispatch(setTimelineUrl(backendVars.timeline))
4534 stevensc 19
        fetchAuthorizedLinks();
20
    }, []);
21
 
22
    const fetchAuthorizedLinks = async () => {
4539 stevensc 23
        const { data: response } = await axios.get(`/company/view/${backendVars.companyId}`);
24
        if (response.success) {
25
            setAuthorizedLinks(response.data);
26
            if (response.data.link_unfollow) {
4534 stevensc 27
                setIsFollower(true);
28
            } else {
29
                setIsFollower(false);
30
            }
31
        }
32
    };
33
 
4531 stevensc 34
    return (
35
        <main className="w-100">
36
            <div className="container p-0 app__body layout__content">
37
                <div className="d-flex flex-column">
38
                    <GroupInfo
39
                        cover={backendVars.cover}
40
                        image={backendVars.image}
41
                        name={backendVars.companyName}
42
                        overview={backendVars.overview}
43
                        groupId={backendVars.companyId}
44
                        totalMembers={backendVars.totalFollowers}
45
                        groupType={backendVars.companySize}
46
                        accessibility={backendVars.industry}
4533 stevensc 47
                        type='company'
4531 stevensc 48
                    />
49
                </div>
50
                <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
4540 stevensc 51
                    <CompanyActions
52
                        name={backendVars.companyName}
53
                        image={backendVars.image}
54
                        companyId={backendVars.companyId}
55
                        cover={backendVars.cover}
56
                        overview={backendVars.overview}
57
                        refetch={() => fetchAuthorizedLinks()}
58
                        actionLinks={authorizedLinks}
59
                    />
4536 stevensc 60
                    {!isFollower
4537 stevensc 61
                        ? <AboutCompany {...backendVars} />
4539 stevensc 62
                        : <FeedList image={`/storage/type/company/code/${backendVars.companyId}/${backendVars.image ? `filename/${backendVars.image}` : ""}`} />
4534 stevensc 63
                    }
4531 stevensc 64
                </div>
65
                <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
4538 stevensc 66
                    <CompanyFollowers companyId={backendVars.companyId} />
4537 stevensc 67
                    <AboutCompany {...backendVars} />
4531 stevensc 68
                </div>
69
            </div>
70
        </main>
71
    )
72
}
73
 
74
export default View