Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1564 | Rev 2113 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1564 Rev 1569
Línea 6... Línea 6...
6
import {axios} from "../../../utils";
6
import {axios} from "../../../utils";
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 Entity from "./entity/Entity";
9
import Entity from "./entity/Entity";
10
import Profile from "../../../components/Profile";
10
import Profile from "../../../components/Profile";
-
 
11
import SearchList from "../../../components/SearchList";
Línea 11... Línea 12...
11
 
12
 
12
const StyledSpinnerContainer = styled.div`
13
const StyledSpinnerContainer = styled.div`
13
  position: absolute;
14
  position: absolute;
14
  left: 0;
15
  left: 0;
Línea 24... Línea 25...
24
 
25
 
25
const MyConnections = (props) => {
26
const MyConnections = (props) => {
26
  // states
27
  // states
27
  const [myConnections, setMyConnections] = useState([]);
28
  const [myConnections, setMyConnections] = useState([]);
28
  const [loading, setLoading] = useState(true);
29
  const [loading, setLoading] = useState(true);
29
 
-
 
30
  // redux destructuring
-
 
31
  const { addNotification } = props;
-
 
32
 
-
 
33
  // React hook form
-
 
34
  const { register, getValues } = useForm();
-
 
35
 
-
 
36
  let axiosThrottle = null;
-
 
37
 
30
  
38
  useEffect(() => {
31
  useEffect(() => {
39
    fetchMyConnections();
-
 
40
    return () => {
-
 
41
      clearTimeout(axiosThrottle);
-
 
42
    };
32
    fetchMyConnections();
Línea 43... Línea -...
43
  }, []);
-
 
44
 
-
 
45
  const handleBlock = (link) => {
-
 
46
    handleAction(link);
-
 
47
  };
-
 
48
 
-
 
49
  const handleCancel = (link) => {
-
 
50
    handleAction(link);
-
 
51
  };
-
 
52
 
-
 
53
  const handleAction = (link) => {
-
 
54
    setLoading(true);
-
 
55
    axios
-
 
56
      .post(link)
-
 
57
      .then((response) => {
-
 
58
        const resData = response.data;
-
 
59
         (resData);
-
 
60
        if (resData.success) {
-
 
61
          const msg = resData.data;
-
 
62
          addNotification({
-
 
63
            style: "success",
-
 
64
            msg: msg,
-
 
65
          });
-
 
66
          fetchMyConnections();
-
 
67
        } else {
-
 
68
          setLoading(false);
-
 
69
        }
-
 
70
      })
-
 
71
      .catch((error) => {
-
 
72
        setLoading(false);
-
 
73
      });
-
 
74
  };
33
  }, []);
75
 
34
 
76
  const fetchMyConnections = async (searchParam='') => {
35
  const fetchMyConnections = async (searchParam='') => {
77
    setLoading(true);
36
    setLoading(true);
78
    await axios
37
    await axios
Línea 85... Línea 44...
85
        }
44
        }
86
      });
45
      });
87
    setLoading(false);
46
    setLoading(false);
88
  };
47
  };
Línea 89... Línea -...
89
 
-
 
90
  const handleSearch = () => {
-
 
91
    //  (getValues());
-
 
92
    clearTimeout(axiosThrottle);
-
 
93
    // setLoading(true);
-
 
94
    const searchValue = getValues("search");
-
 
95
    axiosThrottle = setTimeout(() => {
-
 
96
      fetchMyConnections(searchValue);
-
 
97
    }, 500);
-
 
98
  };
-
 
99
 
48
 
100
  return (
49
  return (
101
    <section className="companies-info">
50
    <section className="companies-info">
102
      <div className="container">
51
      <div className="container">
103
        <div className="company-title">
-
 
104
          <div className="section_admin_title_buttons">
-
 
105
            <div style={{ float: "left" }}>
52
        <SearchList
106
              <h1 className="title">Personas con relación directa, de 1er nivel</h1>
-
 
107
            </div>
-
 
108
          </div>
-
 
109
        </div>
-
 
110
 
-
 
111
        <div className="company-title">
-
 
112
          <div className="section_admin_title_buttons">
-
 
113
            <form
53
          title="Personas con Relación directa, de 1er nivel"
114
              name="form-connection-search"
-
 
115
              id="form-connection-search"
-
 
116
              onSubmit={(event) => event.preventDefault()}
-
 
117
            >
-
 
118
              <div className="form-group">
-
 
119
                <input
-
 
120
                  type="text"
-
 
121
                  name="search"
-
 
122
                  id="search"
-
 
123
                  className="form-control"
-
 
124
                  placeholder="Buscar"
-
 
125
                  ref={register}
-
 
126
                  onChange={handleSearch}
-
 
127
                />
-
 
128
              </div>
-
 
129
            </form>
-
 
130
          </div>
54
          fetchCallback={fetchMyConnections}
Línea 131... Línea 55...
131
        </div>
55
        />
132
 
56
 
133
        <div className="companies-list">
57
        <div className="companies-list">
134
          <div
58
          <div