Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

import React from "react";
import { connect } from "react-redux";
import { setTimelineUrl } from "../../../redux/feed/feed.actions";
import { feedTypes } from "../../../redux/feed/feed.types";
import PeopleYouMayKnow from "../../../shared/helpers/people-you-may-know/PeopleYouMayKnow";
import NotificationAlert from "../../../shared/notification/NotificationAlert";
import FeedSection from "../feed-section/FeedSection";
import ShareFeed from "../share-feed/ShareFeed";
import ShareModal from "../share-modal/ShareModal";

import styles from "./HomeSection.module.scss";
import { axios } from "../../../utils";
import { addNotification } from "../../../redux/notification/notification.actions";
import ProfileInfo from "./ProfileInfo";
import SocialNetworks from "./SocialNetworks";

const HomeSection = (props) => {
  // props destructuring
  const { routeTimeline, addNotification } = props;

  // backendVars destructuring
  const { image, fullName, country, visits, connections, description, feed } = props.backendVars;

  // redux destructuring
  const { setTimelineUrl } = props;
  const [news, setNews] = React.useState([])
  const loadNews = () => {
    axios.get('/helpers/posts')
      .then(res => {
        if(res.data.success){
          setNews(res.data.data)
        }
      })
      .catch(() => {
        addNotification({
          style: "error",
          msg: "Disculpe, ha ocurrido un error buscando novedades",
        });
      })
  }
  React.useEffect(() => {
    loadNews()
  }, [])
  setTimelineUrl(routeTimeline);
  return (
    <div>
      <div className="main-section">
        <div className={styles.mainSection}>
          {/* <!--  LEFT COLUMN START --> */}
          <div className={styles.sectionHeader}>
            <ProfileInfo
              image={image}
              fullName={fullName}
              description={description}
              visits={visits}
              country={country}
              connections={connections}
            />
            <SocialNetworks
            />
          </div>
          {/* <!--  LEFT COLUMN END --> */}

          {/* <!-- CENTER COLUMN START --> */}
          <div className={styles.feedSection}>
            {/* <!--posts-section star--> */}
            <ShareFeed feedType={feedTypes.DASHBOARD} postUrl="/feed/add" />
            <FeedSection
              routeTimeline={routeTimeline}
              feed={feed}
            />
            {/* <!--posts-section end--> */}
          </div>
          {/* <!-- CENTER COLUMN END --> */}

          {/* <!-- RIGTH COLUMN START --> */}
          <div className={styles.peopleYouMayKnow}>
            {/* <?php echo $this->peopleYouMayKnowHelper($currentUser->id) ?> */}
            <PeopleYouMayKnow />
            <div
              style={{
                padding: '5% 0%'
              }}
            >
              <div className={styles.suggestions}>
                <div className="sd-title">
                  <h3>Novedades</h3>
                </div>

                <div className="suggestions-list">
                  {
                    news.map(element => {
                      return(
                        <div
                          key={element.title}
                        >
                          <a
                            href={element.link}
                            target="_blank"
                          >
                            {element.title}
                          </a>
                          <p>
                            {element.date}
                          </p>
                        </div>
                      )
                    })
                  }
                </div>
              </div>
            </div>
          </div>
          {/* <!--right-sidebar end--> */}
        </div>
        {/* <!-- RIGTH COLUMN END --> */}
      </div>
      <ShareModal />
      <NotificationAlert />
    </div>
  );
};

// const mapStateToProps = (state) => ({

// })

const mapDispatchToProps = {
  setTimelineUrl: (url) => setTimelineUrl(url),
  addNotification: (notification) => addNotification(notification),
};

export default connect(null, mapDispatchToProps)(HomeSection);