Proyectos de Subversion LeadersLinked - SPA

Rev

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

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