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