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 };

View File

@ -0,0 +1,54 @@
import { ReactElement } from 'react';
import { Navigate, Route, Routes } from 'react-router';
import { AccountUserProfilePage } from '@/pages/account';
import { AuthPage } from '@/auth';
import { RequireAuth } from '@/auth/RequireAuth';
import { Demo2Layout } from '@/layouts/demo2';
import { ErrorsRouting } from '@/errors';
import DashboardHomePage from '@/pages/dashboards/home/DashboardHomePage';
import ConfigUserPage from '@/pages/configuration/user/user/ConfigUserPage';
import CreditChartPage from '@/pages/pengajuan_kredit/chart/CreditChartPage';
import CreditSummaryPage from '@/pages/pengajuan_kredit/summary/CreditSummaryPage';
import CreditListPage from '@/pages/pengajuan_kredit/list/CreditListPage';
import CreditDetailPage from '@/pages/pengajuan_kredit/list/CreditDetailPage';
import CreditAddPage from '@/pages/pengajuan_kredit/list/CreditAddPage';
import LogActivityPage from '@/pages/configuration/user/log-activity/LogActivityPage';
import ManagePositionPage from '@/pages/configuration/user/manage-position/ManagePositionPage';
import InstansiPage from '@/pages/instansi/InstansiPage';
const AppRoutingSetup = (): ReactElement => {
return (
<Routes>
<Route element={<RequireAuth />}>
<Route element={<Demo2Layout />}>
<Route path="/" element={<DashboardHomePage />} />
<Route path="/account/home/user-profile" element={<AccountUserProfilePage />} />
<Route path="/pengajuan_kredit/chart" element={<CreditChartPage />} />
<Route path="/pengajuan_kredit/summary" element={<CreditSummaryPage />} />
<Route path="/pengajuan_kredit/list" element={<CreditListPage />} />
<Route path="/pengajuan_kredit/list/add" element={<CreditAddPage />} />
<Route path="/pengajuan_kredit/list/details" element={<CreditDetailPage />} />
<Route path="/instansi" element={<InstansiPage />} />
<Route path="/configuration/user-management/manage-user" element={<ConfigUserPage />} />
<Route path="/configuration/user-management/log-activity" element={<LogActivityPage />} />
<Route
path="/configuration/user-management/manage-position"
element={<ManagePositionPage />}
/>
</Route>
</Route>
<Route path="error/*" element={<ErrorsRouting />} />
<Route path="auth/*" element={<AuthPage />} />
<Route path="*" element={<Navigate to="/error/404" />} />
</Routes>
);
};
export { AppRoutingSetup };

2
src/routing/index.ts Normal file
View File

@ -0,0 +1,2 @@
export * from './AppRouting';
export * from './AppRoutingSetup';