Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2323 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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