[WEB-1748] fix: onboarding infinite loading issue. (#4961)

This commit is contained in:
Prateek Shourya 2024-06-28 13:40:57 +05:30 committed by GitHub
parent b5a2e5c727
commit 589576257e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,25 +43,13 @@ const OnboardingPage = observer(() => {
// computed values
const workspacesList = Object.values(workspaces ?? {});
// fetching workspaces list
const { isLoading: workspaceListLoader } = useSWR(
USER_WORKSPACES_LIST,
() => {
user?.id && fetchWorkspaces();
},
{
shouldRetryOnError: false,
}
);
const { isLoading: workspaceListLoader } = useSWR(USER_WORKSPACES_LIST, () => {
user?.id && fetchWorkspaces();
});
// fetching user workspace invitations
const { data: invitations } = useSWR(
"USER_WORKSPACE_INVITATIONS_LIST",
() => {
user?.id && workspaceService.userWorkspaceInvitations();
},
{
shouldRetryOnError: false,
}
);
const { isLoading: invitationsLoader, data: invitations } = useSWR("USER_WORKSPACE_INVITATIONS_LIST", () => {
if (user?.id) return workspaceService.userWorkspaceInvitations();
});
// handle step change
const stepChange = async (steps: Partial<TOnboardingSteps>) => {
if (!user) return;
@ -144,7 +132,7 @@ const OnboardingPage = observer(() => {
return (
<AuthenticationWrapper pageType={EPageTypes.ONBOARDING}>
{user && totalSteps && step !== null && invitations ? (
{user && totalSteps && step !== null && !invitationsLoader ? (
<div className={`flex h-full w-full flex-col`}>
{step === EOnboardingSteps.PROFILE_SETUP ? (
<ProfileSetup
@ -155,7 +143,7 @@ const OnboardingPage = observer(() => {
/>
) : step === EOnboardingSteps.WORKSPACE_CREATE_OR_JOIN ? (
<CreateOrJoinWorkspaces
invitations={invitations}
invitations={invitations ?? []}
totalSteps={totalSteps}
stepChange={stepChange}
finishOnboarding={finishOnboarding}