[#25] changed loading order + added condition to keep loading screen while loading calendar list
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Callback } from "./oidcAuth";
|
||||
import { useAppDispatch } from "../../app/hooks";
|
||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||
import { push } from "redux-first-history";
|
||||
import { setTokens, setUserData } from "./userSlice";
|
||||
import { getOpenPaasUserIdAsync, setTokens, setUserData } from "./userSlice";
|
||||
import { Loading } from "../../components/Loading/Loading";
|
||||
import { getCalendarsAsync } from "../Calendars/CalendarSlice";
|
||||
import {
|
||||
getCalendarDetailAsync,
|
||||
getCalendarsListAsync,
|
||||
} from "../Calendars/CalendarSlice";
|
||||
|
||||
export function CallbackResume() {
|
||||
const dispatch = useAppDispatch();
|
||||
const hasRun = useRef(false);
|
||||
const calendars = useAppSelector((state) => state.calendars);
|
||||
const userId = useAppSelector((state) => state.user.userData?.openpaasId);
|
||||
const saved = sessionStorage.getItem("redirectState")
|
||||
? JSON.parse(sessionStorage.getItem("redirectState")!)
|
||||
: null;
|
||||
@@ -22,7 +27,9 @@ export function CallbackResume() {
|
||||
const data = await Callback(saved?.code_verifier, saved?.state);
|
||||
dispatch(setUserData(data?.userinfo));
|
||||
dispatch(setTokens(data?.tokenSet));
|
||||
dispatch(getCalendarsAsync(data?.tokenSet.access_token || ""));
|
||||
dispatch(getOpenPaasUserIdAsync(data?.tokenSet.access_token ?? ""));
|
||||
dispatch(getCalendarsListAsync(data?.tokenSet.access_token ?? ""));
|
||||
|
||||
sessionStorage.removeItem("redirectState");
|
||||
// Redirect to main page after successful callback
|
||||
dispatch(push("/"));
|
||||
|
||||
Reference in New Issue
Block a user