Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3426 Rev 3427
Línea 16... Línea 16...
16
export default function App() {
16
export default function App() {
17
  const {
17
  const {
18
    data: credentials,
18
    data: credentials,
19
    error: credentialsError,
19
    error: credentialsError,
20
    loading: loadingCredentials,
20
    loading: loadingCredentials,
21
    execute: fetchCredentials,
-
 
22
  } = useApi(getCredentials);
21
  } = useApi(getCredentials, {
23
  const {
-
 
24
    data: labels,
22
    autofetch: true,
25
    error: labelsError,
-
 
26
    loading: loadingLanguages,
-
 
27
  } = useApi(getLanguages, { autoFetch: true });
-
 
28
 
-
 
29
  const { is_logged_in } = useSelector((state) => state.auth);
-
 
30
  const dispatch = useDispatch();
-
 
31
 
-
 
32
  const loading = loadingCredentials || loadingLanguages;
-
 
33
  const initialError = credentialsError || labelsError;
-
 
34
 
-
 
35
  useEffect(() => {
-
 
36
    dispatch(setIntlLabels(labelsAdapter(labels)));
-
 
37
  }, [labels, dispatch]);
-
 
38
 
-
 
39
  useEffect(() => {
-
 
40
    if (credentials) {
-
 
41
      window.localStorage.setItem("jwt", credentials.jwt);
-
 
42
      dispatch(setCrendentials(credentials));
-
 
43
    }
23
  });
44
  }, [credentials, dispatch]);
-
 
Línea 45... Línea -...
45
 
-
 
46
  useEffect(() => {
24
 
47
    fetchCredentials();
25
  const loading = loadingCredentials;
Línea 48... Línea 26...
48
  }, [is_logged_in, fetchCredentials]);
26
  const initialError = credentialsError;
49
 
27
 
50
  if (loading) {
28
  if (loading) {
Línea 51... Línea 29...
51
    return <Spinner />;
29
    return <Spinner />;
52
  }
30
  }
53
 
31
 
Línea 54... Línea 32...
54
  if (initialError) {
32
  if (initialError) {
-
 
33
    return <ErrorPage />;
-
 
34
  }
-
 
35
 
-
 
36
  return (
55
    return <ErrorPage />;
37
    <>