Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3494 Rev 3495
Línea 1... Línea 1...
1
import { useState } from 'react';
1
import { useRef, useState } from 'react';
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
import { useFetch, useSearch } from '@shared/hooks';
3
import { useFetch, useSearch } from '@shared/hooks';
4
 
4
 
Línea 38... Línea 38...
38
  }
38
  }
39
];
39
];
Línea 40... Línea 40...
40
 
40
 
41
export function useMicrolearning() {
41
export function useMicrolearning() {
-
 
42
  const [category, setCategory] = useState(CAPSULES_CATEGORIES[0].value);
-
 
43
  const capsulesRoutes = useRef(CAPSULES_ROUTES);
Línea -... Línea 44...
-
 
44
  const capsuleCategories = useRef(CAPSULES_CATEGORIES);
-
 
45
 
42
  const [category, setCategory] = useState(CAPSULES_CATEGORIES[0].value);
46
  const {
-
 
47
    data: capsules,
43
 
48
    loading: capsulesLoading,
Línea 44... Línea -...
44
  const url = CAPSULES_ROUTES[category].link;
-
 
45
  const params = CAPSULES_ROUTES[category].params;
49
    handleSearch
46
 
50
  } = useSearch(capsulesRoutes.current[category].link);
47
  const { data: capsules, loading: capsulesLoading, handleSearch } = useSearch(url, { params });
51
 
Línea 48... Línea 52...
48
  const { data: currentCapsule, loading: currentCapsuleLoading } = useFetch(
52
  const { data: currentCapsule, loading: currentCapsuleLoading } = useFetch(
Línea 56... Línea 60...
56
  return {
60
  return {
57
    capsules,
61
    capsules,
58
    currentCapsule,
62
    currentCapsule,
59
    loading: capsulesLoading || currentCapsuleLoading,
63
    loading: capsulesLoading || currentCapsuleLoading,
60
    category,
64
    category,
61
    categories: CAPSULES_CATEGORIES,
65
    categories: capsuleCategories.current,
62
    changeCategory,
66
    changeCategory,
63
    handleSearch
67
    handleSearch
64
  };
68
  };
65
}
69
}