Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1599 | Rev 2312 | 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
        />
1 www 45
        <div className="companies-list">
46
          <div className="row" id="profiles-container">
1158 stevensc 47
            {
48
              joinedGroups.length
49
                ?
50
                joinedGroups.map(
51
                  ({ image, name, privacy, link_view, link_leave }, index) => (
1599 steven 52
                    <Profile
1158 stevensc 53
                      image={image}
54
                      name={name}
1599 steven 55
                      status={privacy}
1158 stevensc 56
                      link_view={link_view}
57
                      link_leave={link_leave}
58
                      key={index}
1600 steven 59
                      fetchCallback={fetchJoinedGroups}
1158 stevensc 60
                    />
61
                  ))
62
                :
63
                <div style={{ margin: "auto", textAlign: "center" }}>
64
                  Ningún registro coincidio con su consulta
65
                </div>
66
            }
1 www 67
          </div>
68
          {/* <!--product-feed-tab end--> */}
69
        </div>
70
      </div>
1158 stevensc 71
      {
72
        loading &&
1 www 73
        <div className="spinner-container">
74
          <Spinner />
75
        </div>
1158 stevensc 76
      }
1 www 77
    </section>
78
  );
79
};
80
 
81
// const mapStateToProps = (state) => ({});
82
 
83
const mapDispatchToProps = {
84
  addNotification: (notification) => addNotification(notification),
85
};
86
 
87
export default connect(null, mapDispatchToProps)(JoinedGroups);