[#25] changed loading order + added condition to keep loading screen while loading calendar list

This commit is contained in:
Camille Moussu
2025-07-04 15:27:25 +02:00
parent 1b55f82e45
commit aae4d729f6
11 changed files with 216 additions and 86 deletions
+11 -4
View File
@@ -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("/"));