Rev 637 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */
import React, { useEffect, useState } from "react";
import { axios } from '../../utils';
import List from "./list/List";
import Test from "./test/Test";
import Search from "../../shared/search/Search";
import Breadcrumbs from "../../shared/breadcrumbs/Breadcrumbs"
const SelfEvaluation = ({ backendVars }) => {
const [data, setData] = useState([]);
const [action, setAction] = useState();
const [test, setTest] = useState();
const [loading, setLoading] = useState(true);
const fetchData = async (searchParam = '') => {
setLoading(true);
await axios.get(
"/profile/self-evaluation?search=" + searchParam)
.then((response) => {
if (response.data.success) {
setData(response.data.data);
}
});
setLoading(false);
};
const getTestByUrl = async (url) => {
await axios.get(url)
.then((response) => {
if (response.data.success) {
setAction(url);
setTest(response.data.data);
}
});
};
const handleSearch = async (value) => fetchData(value);
useEffect(() => {
fetchData();
}, [test]);
return (
<section className="companies-info">
{
!test ?
<div className="container">
<div className="row">
<Breadcrumbs title={backendVars.LBL_SELF_EVALUATION} />
</div>
<div className="row">
<Search handleSearch={handleSearch} backendVars={backendVars} />
</div>
<div className="row">
<List
data={data}
getTestByUrl={getTestByUrl}
backendVars={backendVars}
loading={loading}
/>
</div>
</div>
:
<div className="container">
<Test
backendVars={backendVars}
loading={loading}
setTest={setTest}
test={test}
action={action}
/>
</div>
}
</section>
);
};
export default React.memo(SelfEvaluation);