revamp template

This commit is contained in:
fro1991
2025-02-01 16:44:51 +07:00
parent c432df568a
commit 276a289580
1212 changed files with 112762 additions and 0 deletions

View File

@ -0,0 +1,51 @@
import { ReactElement, useEffect, useState } from 'react';
import { useLocation } from 'react-router';
import { useAuthContext } from '@/auth';
import { useLoaders } from '@/providers';
import { AppRoutingSetup } from '.';
const AppRouting = (): ReactElement => {
const { setProgressBarLoader } = useLoaders();
const { verify, setLoading } = useAuthContext();
const [previousLocation, setPreviousLocation] = useState('');
const [firstLoad, setFirstLoad] = useState(true);
const location = useLocation();
const path = location.pathname.trim();
useEffect(() => {
if (firstLoad) {
verify().finally(() => {
setLoading(false);
setFirstLoad(false);
});
}
});
useEffect(() => {
if (!firstLoad) {
setProgressBarLoader(true);
verify()
.catch(() => {
throw new Error('User verify request failed!');
})
.finally(() => {
setPreviousLocation(path);
setProgressBarLoader(false);
if (path === previousLocation) {
setPreviousLocation('');
}
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location]);
useEffect(() => {
if (!CSS.escape(window.location.hash)) {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
}, [previousLocation]);
return <AppRoutingSetup />;
};
export { AppRouting };