Rev 636 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect, useMemo, 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 = (props) => {// get propsconst { backendVars } = props;/*** Init States*/const [data, setData] = useState([]);const [action, setAction] = useState();const [test, setTest] = useState();const [loading, setLoading] = useState(true);/*** Get All self evaluation tests*/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);};/*** get info test* @param {*} url*/const getTestByUrl = async (url) => {await axios.get(url).then((response) => {if (response.data.success) {setAction(url);setTest(response.data.data);}});};/*** Search data* @param {*} e*/const handleSearch = async (e) => fetchData(e);/*** componentDidMount*/useEffect(() => {fetchData();}, [test]);const Content = useMemo(() => {!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"><Listdata={data}getTestByUrl={getTestByUrl}backendVars={backendVars}loading={loading}/></div></div>) : (<div className="container"><TestbackendVars={backendVars}loading={loading}setTest={setTest}test={test}action={action}/></div>)}, [test]);return (<section className="companies-info"><Content/></section>);};export default SelfEvaluation;