import { Route, Routes } from "react-router-dom";
import { lazy } from "react";

import LoginLandingPage from './views/LoginLandingPage'
import LoginPage from "./views/LoginPage";
import HomePages from "./views/HomePages";
import SocketConnection from "./middleware/SocketConnection";


const FourZeroFour = lazy(() => import("./components/FourZeroFour"));
const ScrollToTop = lazy(() => import("./components/Helpers/ScrollToTop"));
const StartJob = lazy(() => import("./components/MyJobs/StartJob"));
const Notification = lazy(() => import("./components/Notification"));
const AuthRoute = lazy(() => import("./middleware/AuthRoute"));
const AppDownloadPage = lazy(() => import("./views/AppDownloadPage"));
const AppleRedirectPage = lazy(() => import("./views/AppleRedirectPage"));
const AuthProfilePage = lazy(() => import("./views/AuthProfilePage"));
const AuthRedirect = lazy(() => import("./views/AuthRedirect"));
const BlogPage = lazy(() => import("./views/BlogPage"));
const CalendarPage = lazy(() => import("./views/CalendarPage"));
const CollectionItemPage = lazy(() => import("./views/CollectionItemPage"));
const FacebookRedirect = lazy(() => import("./views/FacebookRedirect"));
const FamilyManagePage = lazy(() => import("./views/FamilyManagePage"));
const FamilyMarketPage = lazy(() => import("./views/FamilyMarketPage"));

const ForgotPasswordPages = lazy(()=> import("./views/ForgotPasswordPages"));
const ForgotPasswordPagesTwo = lazy(()=> import("./views/ForgotPasswordPagesTwo"));
const HistoryPage = lazy(()=> import("./views/HistoryPage"));
const JobGroupsPage = lazy(()=> import("./views/JobGroupsPage"));
const LndPage = lazy(()=> import("./views/LndPage"));
const LoginPageTwo = lazy(()=> import("./views/LoginPageTwo"));
const ManageActiveJobs = lazy(()=> import("./views/ManageActiveJobs"));
const ManageInterestOfferPage = lazy(()=> import("./views/ManageInterestOfferPage"));
const MarketPlacePage = lazy(()=> import("./views/MarketPlacePage"));
const MyActiveJobsPage = lazy(()=> import("./views/MyActiveJobsPage"));
const MyCouponPage = lazy(()=> import("./views/MyCouponPage"));
const MyJobsPage = lazy(()=> import("./views/MyJobsPage"));
const MyOffersPage = lazy(()=> import("./views/MyOffersPage"));
const MyPastDueJobsPage = lazy(()=> import("./views/MyPastDueJobsPage"));
const MyReviewDueJobsPage = lazy(()=> import("./views/MyReviewDueJobsPage"));
const MyTaskPage = lazy(()=> import("./views/MyTaskPage"));
const MyWaitingJobsPage = lazy(()=> import("./views/MyWaitingJobsPage"));
const MyWalletPage = lazy(()=> import("./views/MyWalletPage"));
const OffersInterestPage = lazy(()=> import("./views/OffersInterestPage"));
const ReferralPage = lazy(()=> import("./views/ReferralPage"));
const RemindersPage = lazy(()=> import("./views/RemindersPage"));
const ResourcePage = lazy(()=> import("./views/ResourcePage"));
const SavedPage = lazy(()=> import("./views/SavedPage"));
const SellPage = lazy(()=> import("./views/SellPage"));
const SettingsPage = lazy(()=> import("./views/SettingsPage"));
const SignupPage = lazy(()=> import("./views/SignupPage"));
const SignupPageTwo = lazy(()=> import("./views/SignupPageTwo"));
const TrackingPage = lazy(()=> import("./views/TrackingPage"));
const UpdatePasswordPages = lazy(()=> import("./views/UpdatePasswordPages"));
const UpdatePasswordPagesTwo = lazy(()=> import("./views/UpdatePasswordPagesTwo"));
const UploadProductPage = lazy(()=> import("./views/UploadProductPage"));
const UserProfilePage = lazy(()=> import("./views/UserProfilePage"));
const VerifyLinkPages = lazy(()=> import("./views/VerifyLinkPages"));
const VerifyLinkPagesTwo = lazy(()=> import("./views/VerifyLinkPagesTwo"));
const VerifyPasswordPages = lazy(()=> import("./views/VerifyPasswordPages"));
const VerifyPasswordPagesTwo = lazy(()=> import("./views/VerifyPasswordPagesTwo"));
const VerifyYouPages = lazy(()=> import("./views/VerifyYouPages"));
const VerifyYouPagesTwo = lazy(()=> import("./views/VerifyYouPagesTwo"));
const YourPages = lazy(()=> import("./views/YourPage_"));
const ParentWaitingPage = lazy(()=> import("./views/ParentWaitingPage"));
const FamilyPendingOfferPage = lazy(()=> import("./views/FamilyPendingOfferPage"));
const FamBlogPage = lazy(()=> import("./views/FamBlogPage"));
const FamAIQuestionPage = lazy(()=> import("./views/FamAIQuestionPage"));
const FamMyFilesPage = lazy(()=> import("./views/FamMyFilesPage"));
const FamWorkInProgressPage = lazy(()=> import("./views/FamWorkInProgressPage"));
const MyPastDueTasksPage = lazy(()=> import("./views/MyPastDueTasksPage"));
const FamilyWalletPage = lazy(()=> import("./views/FamilyWalletPage"));
const LearnMorePage = lazy(()=> import("./views/LearnMorePage"));
const FamGamesPage = lazy(()=> import("./views/FamGamesPage"));
const FamilyRoutesPage = lazy(()=> import("./views/FamilyRoutesPage"));
const PromoPage = lazy(()=> import("./views/PromoPage"));

export default function Routers() {
  return (
    <ScrollToTop>
      <Routes>
        {/* guest routes */}
        {process.env.REACT_APP_NEW_LOGIN_LAYOUT == 1 ? (
          <>
            <Route exact path="/login" element={<LoginLandingPage />} />
            <Route exact path="/login/:type" element={<LoginPageTwo />} />
            <Route exact path="/signup" element={<SignupPageTwo />} />
            <Route
              exact
              path="/forgot-password"
              element={<ForgotPasswordPagesTwo />}
            />
            <Route
              exact
              path="/update-password"
              element={<UpdatePasswordPagesTwo />}
            />
            <Route path="/vemail" element={<VerifyLinkPagesTwo />} />
            <Route path="/complereset" element={<VerifyPasswordPagesTwo />} />
            <Route exact path="/outmessage" element={<VerifyYouPagesTwo />} />
            <Route exact path="/eoffer" element={<LoginPageTwo />} />
            <Route exact path="/invite" element={<LoginPageTwo />} />
            <Route exact path="/promo/:name/:id" element={<PromoPage />} />
          </>
        ) : (
          <>
            <Route exact path="/login" element={<LoginPage />} />
            <Route exact path="/signup" element={<SignupPage />} />
            <Route
              exact
              path="/forgot-password"
              element={<ForgotPasswordPages />}
            />
            <Route
              exact
              path="/update-password"
              element={<UpdatePasswordPages />}
            />
            <Route path="/vemail" element={<VerifyLinkPages />} />
            <Route path="/complereset" element={<VerifyPasswordPages />} />
            <Route exact path="/outmessage" element={<VerifyYouPages />} />
            <Route exact path="/eoffer" element={<LoginPage />} />
            <Route exact path="/invite" element={<LoginPage />} />
          </>
        )}
        <Route exact path="/login/auth" element={<AuthRedirect />} />
        <Route exact path="/login/auth/flogin" element={<FacebookRedirect />} />
        <Route exact path="/login/auth/apple" element={<AppleRedirectPage />} />
        <Route exact path="/lnd/*" element={<LndPage />} />
        <Route exact path="/app" element={<AppDownloadPage />} />

        {/* private route */}
        <Route element={<SocketConnection />}>
          <Route element={<AuthRoute />}>
            <Route exact path="/" element={<HomePages />} />
            {/*  <Route exact path="/active-bids" element={<AcitveBidsPage />} />
            <Route exact path="/notification" element={<Notification />} />
            <Route exact path="/market-place" element={<MarketPlacePage />} />
            <Route exact path="/shop-details" element={<ShopDetailsPage />} />
          <Route exact path="/my-collection" element={<MyCollection />} />*/}
            <Route exact path="/reminders" element={<RemindersPage />} />
            <Route exact path="/tracking" element={<TrackingPage />} />
            <Route exact path="/calendar" element={<CalendarPage />} />
            <Route exact path="/resources" element={<ResourcePage />} />
            <Route exact path="/my-wallet/*" element={<MyWalletPage />} />
            <Route exact path="/family-wallet" element={<FamilyWalletPage />} />
            <Route exact path="/my-coupon" element={<MyCouponPage />} />
            <Route exact path="/notification" element={<Notification />} />
            <Route exact path="/market-place" element={<MarketPlacePage />} />
            <Route exact path="/market" element={<MarketPlacePage />} />
            <Route exact path="/familymarket" element={<FamilyMarketPage />} />
            <Route exact path="/suggested" element={<ParentWaitingPage />} />
            <Route exact path="/parentwaiting" element={<ParentWaitingPage />} />
            <Route exact path="/pending" element={<FamilyPendingOfferPage />} />
            <Route exact path="/fam-blog" element={<FamBlogPage />} />
            <Route exact path="/ai-question" element={<FamAIQuestionPage />} />
            <Route exact path="/myfiles" element={<FamMyFilesPage />} />
            <Route exact path="/ai-lab" element={<FamAIQuestionPage />} />
            <Route exact path="/fam-games" element={<FamGamesPage />} />
            <Route exact path="/work-in-progress" element={<FamWorkInProgressPage />} />

            <Route exact path="/pastdue" element={<MyPastDueTasksPage />} />
            <Route exact path="/notification" element={<Notification />} />
            <Route exact path="/mytask" element={<MyTaskPage />} />
            <Route exact path="/myjobs" element={<MyJobsPage />} />
            {/* <Route exact path="/add-job" element={<AddJobPage />} /> */}
            <Route exact path="/my-active-jobs" element={<MyActiveJobsPage />} />
            <Route
              exact
              path="/my-pastdue-jobs"
              element={<MyPastDueJobsPage />}
            />
            <Route exact path="/my-offers" element={<MyOffersPage />} />
            <Route exact path="/pend-interest" element={<MyWaitingJobsPage />} />
            <Route
              exact
              path="/my-review-jobs"
              element={<MyReviewDueJobsPage />}
            />

            {/* <Route exact path='/acc-family' element={<FamilyAccPage />} />
            <Route exact path="/acc-family/activities" element={<FamilyActivitiesPage />} />
            <Route exact path="/acc-family/familysettings" element={<FamilySettingsPage />} /> */}
            <Route path='/acc-family/*' element={<FamilyRoutesPage />} />

            <Route exact path="/manage-family" element={<FamilyManagePage />} />
            <Route exact path="/start-job" element={<StartJob />} />
            <Route exact path="/yourpage" element={<YourPages />} />
            <Route
              exact
              path="/manage-active-job"
              element={<ManageActiveJobs />}
            />
            <Route exact path="/blog-page" element={<BlogPage />} />
            <Route
              exact
              path="/offer-interest"
              element={<OffersInterestPage />}
            />
            <Route
              exact
              path="/manage-offer"
              element={<ManageInterestOfferPage />}
            />

            <Route
              exact
              path="/my-collection/collection-item"
              element={<CollectionItemPage />}
            />
            <Route exact path="/sell" element={<SellPage />} />
            <Route exact path="/saved" element={<SavedPage />} />
            <Route exact path="/history" element={<HistoryPage />} />
            <Route exact path="/learnmore" element={<LearnMorePage />} />
            {/*<Route exact path="/upload-product" element={<UploadProductPage />} />*/}
            <Route exact path="/my-uploads" element={<UploadProductPage />} />
            <Route exact path="/profile" element={<AuthProfilePage />} />
            <Route exact path="/user-profile" element={<UserProfilePage />} />
            <Route exact path="/settings" element={<SettingsPage />} />
            <Route exact path="/referral" element={<ReferralPage />} />
            <Route exact path="/job-groups" element={<JobGroupsPage />} />
          </Route>
        </Route>
        <Route path="*" element={<FourZeroFour />} />
      </Routes>
    </ScrollToTop>
  );
}
