Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
1 www 1
import React from "react";
2
import { useEffect, useState } from "react";
3
import { connect } from "react-redux";
4
import { useForm } from "react-hook-form";
5
import styled from "styled-components";
1158 stevensc 6
import { axios } from "../../../utils";
1 www 7
import { addNotification } from "../../../redux/notification/notification.actions";
8
import Spinner from "../../../shared/loading-spinner/Spinner";
9
import JoinedGroup from "./joined-group/JoinedGroup";
1599 steven 10
import SearchList from "../../../components/SearchList";
11
import Profile from "../../../components/Profile";
1 www 12
 
13
const JoinedGroups = (props) => {
14
  // states
15
  const [joinedGroups, setJoinedGroups] = useState([]);
16
  const [loading, setLoading] = useState(true);
17
 
18
  useEffect(() => {
19
    fetchJoinedGroups();
20
  }, []);
21
 
1158 stevensc 22
  const fetchJoinedGroups = async (searchParam = '') => {
1 www 23
    setLoading(true);
24
    await axios
25
      .get(
1158 stevensc 26
        "/group/joined-groups?search=" + searchParam,
1 www 27
      )
28
      .then((response) => {
29
        const resData = response.data;
1158 stevensc 30
        (resData);
1 www 31
        if (resData.success) {
32
          setJoinedGroups(resData.data);
33
        }
34
      });
35
    setLoading(false);
36
  };
37
 
38
  return (
39
    <section className="companies-info" style={{ position: "relative" }}>
40
      <div className="container">
1599 steven 41
        <SearchList
42
          title="Grupos unidos"
43
          fetchCallback={fetchJoinedGroups}
44
        />
2312 stevensc 45
        <div className="companies-list" id="profiles-container">
1158 stevensc 46
            {
47
              joinedGroups.length
48
                ?
49
                joinedGroups.map(
50
                  ({ image, name, privacy, link_view, link_leave }, index) => (
1599 steven 51
                    <Profile
1158 stevensc 52
                      image={image}
53
                      name={name}
1599 steven 54
                      status={privacy}
1158 stevensc 55
                      link_view={link_view}
56
                      link_leave={link_leave}
57
                      key={index}
1600 steven 58
                      fetchCallback={fetchJoinedGroups}
1158 stevensc 59
                    />
60
                  ))
61
                :
62
                <div style={{ margin: "auto", textAlign: "center" }}>
63
                  Ningún registro coincidio con su consulta
64
                </div>
2314 stevensc 65
            }
1 www 66
          {/* <!--product-feed-tab end--> */}
67
        </div>
68
      </div>
1158 stevensc 69
      {
70
        loading &&
1 www 71
        <div className="spinner-container">
72
          <Spinner />
73
        </div>
1158 stevensc 74
      }
1 www 75
    </section>
76
  );
77
};
78
 
79
// const mapStateToProps = (state) => ({});
80
 
81
const mapDispatchToProps = {
82
  addNotification: (notification) => addNotification(notification),
83
};
84
 
85
export default connect(null, mapDispatchToProps)(JoinedGroups);