Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 637 Rev 3209
Línea -... Línea 1...
-
 
1
/* eslint-disable react/prop-types */
1
import React, { useEffect, useMemo, useState } from "react";
2
import React, { useEffect, useState } from "react";
2
import { axios } from '../../utils';
3
import { axios } from '../../utils';
3
import List from "./list/List";
4
import List from "./list/List";
4
import Test from "./test/Test";
5
import Test from "./test/Test";
5
import Search from "../../shared/search/Search";
6
import Search from "../../shared/search/Search";
6
import Breadcrumbs from "../../shared/breadcrumbs/Breadcrumbs"
7
import Breadcrumbs from "../../shared/breadcrumbs/Breadcrumbs"
Línea 7... Línea 8...
7
 
8
 
Línea 8... Línea -...
8
const SelfEvaluation = (props) => {
-
 
9
 
-
 
10
 
-
 
11
    // get props
-
 
12
    const { backendVars } = props;
-
 
13
 
-
 
14
    /**
-
 
15
     * Init States
9
const SelfEvaluation = ({ backendVars }) => {
16
     */
10
 
17
    const [data, setData] = useState([]);
11
    const [data, setData] = useState([]);
18
    const [action, setAction] = useState();
12
    const [action, setAction] = useState();
Línea 19... Línea -...
19
    const [test, setTest] = useState();
-
 
20
    const [loading, setLoading] = useState(true);
-
 
21
 
-
 
22
    /**
13
    const [test, setTest] = useState();
23
     * Get All self evaluation tests
14
    const [loading, setLoading] = useState(true);
24
     */
15
 
25
    const fetchData = async (searchParam = '') => {
16
    const fetchData = async (searchParam = '') => {
26
        setLoading(true);
17
        setLoading(true);
Línea 32... Línea 23...
32
                }
23
                }
33
            });
24
            });
34
        setLoading(false);
25
        setLoading(false);
35
    };
26
    };
Línea 36... Línea -...
36
 
-
 
37
    /**
-
 
38
     * get info test
-
 
39
     * @param {*} url 
-
 
40
     */
27
 
41
    const getTestByUrl = async (url) => {
28
    const getTestByUrl = async (url) => {
42
        await axios.get(url)
29
        await axios.get(url)
43
            .then((response) => {
30
            .then((response) => {
44
                if (response.data.success) {
31
                if (response.data.success) {
45
                    setAction(url);
32
                    setAction(url);
46
                    setTest(response.data.data);
33
                    setTest(response.data.data);
47
                }
34
                }
48
            });
35
            });
Línea 49... Línea -...
49
    };
-
 
50
 
-
 
51
    /**
-
 
52
     * Search data
-
 
53
     * @param {*} e 
36
    };
54
     */
37
 
55
    const handleSearch = async (e) => fetchData(e);
-
 
56
 
-
 
57
    /**
-
 
58
     * componentDidMount
38
    const handleSearch = async (value) => fetchData(value);
59
     */
39
 
60
    useEffect(() => {
40
    useEffect(() => {
Línea 61... Línea -...
61
        fetchData();
-
 
62
    }, [test]);
-
 
63
 
-
 
64
    const Content = useMemo(() => {
-
 
65
        !test ? (
-
 
66
            <div className="container">
-
 
67
                <div className="row">
-
 
68
                    <Breadcrumbs title={backendVars.LBL_SELF_EVALUATION} />
-
 
69
                </div>
-
 
70
                <div className="row">
-
 
71
                    <Search handleSearch={handleSearch} backendVars={backendVars} />
-
 
72
                </div>
-
 
73
                <div className="row">
-
 
74
                    <List
-
 
75
                        data={data}
-
 
76
                        getTestByUrl={getTestByUrl}
-
 
77
                        backendVars={backendVars}
-
 
78
                        loading={loading}
-
 
79
                    />
-
 
80
                </div>
-
 
81
            </div>
-
 
82
        ) : (
-
 
83
            <div className="container">
-
 
84
                <Test
-
 
85
                    backendVars={backendVars}
-
 
86
                    loading={loading}
-
 
87
                    setTest={setTest}
-
 
88
                    test={test}
-
 
89
                    action={action}
-
 
90
                />
-
 
91
            </div>
-
 
92
        )
41
        fetchData();
93
    }, [test]);
42
    }, [test]);
-
 
43
 
94
 
44
    return (
-
 
45
        <section className="companies-info">
-
 
46
            {
-
 
47
                !test ?
-
 
48
                    <div className="container">
-
 
49
                        <div className="row">
-
 
50
                            <Breadcrumbs title={backendVars.LBL_SELF_EVALUATION} />
-
 
51
                        </div>
-
 
52
                        <div className="row">
-
 
53
                            <Search handleSearch={handleSearch} backendVars={backendVars} />
-
 
54
                        </div>
-
 
55
                        <div className="row">
-
 
56
                            <List
-
 
57
                                data={data}
-
 
58
                                getTestByUrl={getTestByUrl}
-
 
59
                                backendVars={backendVars}
-
 
60
                                loading={loading}
-
 
61
                            />
-
 
62
                        </div>
-
 
63
                    </div>
-
 
64
                    :
-
 
65
                    <div className="container">
-
 
66
                        <Test
-
 
67
                            backendVars={backendVars}
-
 
68
                            loading={loading}
-
 
69
                            setTest={setTest}
-
 
70
                            test={test}
95
    return (
71
                            action={action}
96
        <section className="companies-info">
72
                        />
Línea 97... Línea 73...
97
            <Content
73
                    </div>
98
            />
74
            }
Línea 99... Línea -...
99
        </section>
-
 
100
 
75
        </section>
-
 
76
 
101
    );
77
    );