feat: add loading indicator and improve loading screens

This commit is contained in:
swve 2024-06-13 23:00:33 +01:00
parent 866111aa4c
commit 29219391ea
5 changed files with 32 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import { swrFetcher } from '@services/utils/ts/requests'
import React, { createContext, useContext, useEffect, useReducer } from 'react'
import useSWR from 'swr'
import { useLHSession } from '@components/Contexts/LHSessionContext'
import PageLoading from '@components/Objects/Loaders/PageLoading'
export const CourseContext = createContext(null)
export const CourseDispatchContext = createContext(null)
@ -33,7 +34,7 @@ export function CourseProvider({ children, courseuuid }: any) {
}, [courseStructureData]);
if (error) return <div>Failed to load course structure</div>;
if (!courseStructureData) return <div>Loading...</div>;
if (!courseStructureData) return <PageLoading/>;
return (
<CourseContext.Provider value={state}>

View file

@ -30,7 +30,7 @@ export function OrgProvider({ children, orgslug }: { children: React.ReactNode,
const isUserPartOfTheOrg = useMemo(() => orgs?.some((userOrg: any) => userOrg.id === org?.id), [orgs, org?.id])
if (orgError || orgsError) return <ErrorUI message='An error occurred while fetching data' />
if (!org || !orgs || !session) return <div>Loading...</div>
if (!org || !orgs || !session) return <div></div>
if (!isOrgActive) return <ErrorUI message='This organization is no longer active' />
if (!isUserPartOfTheOrg && session.status == 'authenticated' && !isAllowedPathname) {
return (