Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3490 Rev 3491
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react';
1
import React, { useEffect, useState } from 'react';
-
 
2
import { Link } from 'react-router-dom';
Línea 2... Línea 3...
2
 
3
 
Línea 3... Línea 4...
3
import { useMicroLearning, useFetch } from '@hooks';
4
import { useFetch, useMicroLearning } from '@hooks';
4
 
5
 
5
import { List, SearchBar } from '@shared/components';
-
 
6
import { CapsuleItem } from '@microlearning/components';
-
 
Línea 7... Línea 6...
7
import CapsuleCard from '@microlearning/components/CapsuleCard';
6
import { List, SearchBar } from '@shared/components';
-
 
7
import { CapsuleCard, CapsuleItem } from '@microlearning/components';
-
 
8
 
8
import Tabs from '@components/UI/Tabs';
9
export default function CapsulesPage() {
9
 
10
  const [activeLink, setActiveLink] = useState('');
10
export default function CapsulesPage() {
11
 
11
  const {
12
  const {
12
    link_capsules_completed: linkCapsulesCompleted,
13
    link_capsules_completed: linkCapsulesCompleted,
13
    link_capsules_in_progress: linkCapsulesInProgress,
14
    link_capsules_in_progress: linkCapsulesInProgress,
Línea 14... Línea -...
14
    link_capsules_pending: linkCapsulesPending,
-
 
15
    link_last_capsule_in_progress: linkLastCapsuleInProgress
-
 
16
  } = useMicroLearning();
15
    link_capsules_pending: linkCapsulesPending,
17
 
16
    link_last_capsule_in_progress: linkLastCapsuleInProgress
Línea 18... Línea 17...
18
  const [activeLink, setActiveLink] = useState('');
17
  } = useMicroLearning();
Línea 19... Línea 18...
19
 
18
 
20
  const { data: capsuleInProgess } = useFetch(linkLastCapsuleInProgress, null);
19
  const { data: capsuleInProgess } = useFetch(linkLastCapsuleInProgress, null);
21
  const { data: capsules } = useFetch(activeLink, []);
-
 
22
 
20
  const { data: capsules } = useFetch(activeLink, []);
23
  const handleChange = (e, url) => setActiveLink(url);
21
 
Línea 24... Línea 22...
24
 
22
  const handleChange = (e, url) => setActiveLink(url);
25
  useEffect(() => {
23
 
26
    if (!linkCapsulesPending) return;
24
  useEffect(() => {
Línea 27... Línea 25...
27
 
25
    if (!linkCapsulesPending) return;
28
    setActiveLink(linkCapsulesPending + '?order_field=added_on&order_direction=desc');
26
    setActiveLink(linkCapsulesPending + '?order_field=added_on&order_direction=desc');
29
  }, [linkCapsulesPending]);
27
  }, [linkCapsulesPending]);
30
 
28
 
31
  return (
29
  return (
32
    <>
30
    <>
Línea 46... Línea 44...
46
          value={
44
          value={
47
            linkCapsulesCompleted &&
45
            linkCapsulesCompleted &&
48
            linkCapsulesCompleted + '?order_field=last_access_on&order_direction=desc'
46
            linkCapsulesCompleted + '?order_field=last_access_on&order_direction=desc'
49
          }
47
          }
50
        />
48
        />
51
      </Tabs>
49
      </Tabs> */}
Línea 52... Línea 50...
52
 
50
 
Línea 53... Línea 51...
53
      <SearchBar />
51
      <SearchBar onChange={handleChange} />
54
 
52
 
-
 
53
      <List
-
 
54
        items={capsules}
55
      <List
55
        renderItem={(capsule) => (
-
 
56
          <Link to={`/microlearning/capsules/${capsule.uuid}`}>
-
 
57
            <CapsuleItem capsule={capsule} readOnly />
56
        items={capsules}
58
          </Link>
57
        renderItem={(capsule) => <CapsuleItem capsule={capsule} readOnly />}
59
        )}
58
        emptyMessage='No hay cápsulas para mostrar'
60
        emptyMessage='No hay cápsulas para mostrar'
59
        keyExtractor='uuid'
61
        keyExtractor='uuid'
60
      />
62
      />