Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PADV-1645 - Add spinner loader before display unauthorized page #116

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/features/Main/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'react-router-dom';

import { getConfig } from '@edx/frontend-platform';
import { Container } from '@edx/paragon';
import { Container, Spinner } from '@edx/paragon';

import CookiePolicyBanner from '@pearsonedunext/frontend-component-cookie-policy-banner';

Expand All @@ -36,7 +36,7 @@ import { updateSelectedInstitution } from 'features/Main/data/slice';

import { useInstitutionIdQueryParam } from 'hooks';

import { cookieText, INSTITUTION_QUERY_ID } from 'features/constants';
import { cookieText, INSTITUTION_QUERY_ID, RequestStatus } from 'features/constants';

import './index.scss';

Expand All @@ -49,6 +49,9 @@ const Main = () => {

const searchParams = new URLSearchParams(location.search);

const statusInstitutions = useSelector((state) => state.main.institution.status);
const isLoadingInstitutions = statusInstitutions === RequestStatus.LOADING;

useEffect(() => {
dispatch(fetchInstitutionData());
}, [dispatch]);
Expand Down Expand Up @@ -82,8 +85,17 @@ const Main = () => {
<Header />
<div className="pageWrapper">
<main className="d-flex">
{institutions.length < 1 && <UnauthorizedPage />}
{institutions.length > 0 && (
{isLoadingInstitutions && (
<div className="w-100 h-100 d-flex justify-content-center align-items-center">
<Spinner
animation="border"
className="mie-3"
screenReaderText="loading"
/>
</div>
)}
{!isLoadingInstitutions && institutions.length < 1 && <UnauthorizedPage />}
{!isLoadingInstitutions && institutions.length > 0 && (
<>
<Sidebar />
<Container className="px-0 container-pages">
Expand Down
Loading