Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

/* eslint-disable react/prop-types */
import React, { useEffect, useState } from 'react'
import FeedList from '../../../../../dashboard/templates/linkedin/Feed/FeedList';
import GroupInfo from '../../../../../group/view/templates/linkedin/components/GroupInfo'
import { setTimelineUrl } from '../../../../../redux/feed/feed.actions';
import { axios } from '../../../../../utils';
import AboutCompany from '../components/AboutCompany';
import CompanyFollowers from '../components/CompanyFollowers';

const View = ({ backendVars }) => {

    const [authorizedLinks, setAuthorizedLinks] = useState(null);
    const [followers, setFollowers] = useState(backendVars.totalFollowers);
    const [isFollower, setIsFollower] = useState(false);

    useEffect(() => {
        setTimelineUrl(backendVars.timeline);
        fetchAuthorizedLinks();
    }, []);

    const fetchAuthorizedLinks = async () => {
        const response = await axios.get(`/company/view/${backendVars.companyId}`);
        const resData = response.data;
        if (resData.success) {
            setAuthorizedLinks(resData.data);
            setFollowers(resData.data.total_followers);
            if (resData.data.link_unfollow) {
                setIsFollower(true);
            } else {
                setIsFollower(false);
            }
        }
    };

    return (
        <main className="w-100">
            <div className="container p-0 app__body layout__content">
                <div className="d-flex flex-column">
                    <GroupInfo
                        cover={backendVars.cover}
                        image={backendVars.image}
                        name={backendVars.companyName}
                        overview={backendVars.overview}
                        groupId={backendVars.companyId}
                        totalMembers={backendVars.totalFollowers}
                        groupType={backendVars.companySize}
                        accessibility={backendVars.industry}
                        type='company'
                    />
                </div>
                <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
                    {!isFollower
                        ? <AboutCompany {...backendVars} />
                        : <FeedList
                            image={`/storage/type/company/code/${backendVars.companyId}/${backendVars.image ? `filename/${backendVars.image}` : ""}`}
                            routeTimeline={backendVars.timeline}
                        />
                    }
                </div>
                <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
                    <CompanyFollowers companyId={backendVars.companyId} />
                    <AboutCompany {...backendVars} />
                </div>
            </div>
        </main>
    )
}

export default View