ConceptPortal-public/rsconcept/frontend/src/app/GlobalLoader.tsx

27 lines
715 B
TypeScript
Raw Normal View History

2025-02-15 17:39:09 +03:00
import { useNavigation } from 'react-router';
import { useDebounce } from 'use-debounce';
2025-02-15 17:11:36 +03:00
import { Loader } from '@/components/Loader';
2025-03-10 16:02:53 +03:00
import { ModalBackdrop } from '@/components/Modal/ModalBackdrop';
2025-02-15 17:39:09 +03:00
import { PARAMETER } from '@/utils/constants';
2025-02-15 17:11:36 +03:00
export function GlobalLoader() {
2025-02-15 17:39:09 +03:00
const navigation = useNavigation();
const isLoading = navigation.state === 'loading';
const [loadingDebounced] = useDebounce(isLoading, PARAMETER.navigationPopupDelay);
2025-02-17 15:12:15 +03:00
if (!loadingDebounced) {
2025-02-15 17:39:09 +03:00
return null;
}
2025-02-15 17:11:36 +03:00
return (
2025-03-10 16:02:53 +03:00
<div className='cc-modal-wrapper'>
<ModalBackdrop />
<div className='cc-fade-in px-10 border rounded-xl bg-prim-100'>
2025-02-15 17:11:36 +03:00
<Loader scale={6} />
</div>
</div>
);
}