Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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