Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3416 Rev 3424
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);
-
 
23
  const {
-
 
24
    data: labels,
-
 
25
    error: labelsError,
-
 
26
    loading: loadingLanguages,
-
 
27
  } = useApi(getLanguages, { autoFetch: true });
21
  } = useApi(getCredentials, { 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
    }
-
 
44
  }, [credentials, dispatch]);
-
 
Línea 45... Línea -...
45
 
-
 
46
  useEffect(() => {
22
 
47
    fetchCredentials();
23
  const loading = loadingCredentials;
Línea 48... Línea 24...
48
  }, [is_logged_in, fetchCredentials]);
24
  const initialError = credentialsError;
49
 
25
 
50
  if (loading) {
26
  if (loading) {
Línea 51... Línea 27...
51
    return <Spinner />;
27
    return <Spinner />;
52
  }
28
  }
53
 
29
 
Línea 54... Línea 30...
54
  if (initialError) {
30
  if (initialError) {
-
 
31
    return <ErrorPage />;
-
 
32
  }
-
 
33
 
-
 
34
  return (
55
    return <ErrorPage />;
35
    <>