import { Auth } from "../Pages/Auth";
import { Menu } from "../Pages/Menu";
import { checkIsMobile } from "../utils/checkIsMobile";
import * as R from "./paths";
import MainPage from "../Pages/MainPage";
import UserProfile from "../Pages/UserProfile";
import Users from "../Pages/Users";
import Statics from "../Pages/Statics";
import UserInspections from "../Pages/UserInspections";
import AutoLogin from "../Pages/AutoLogin";
import NationalInfo from "../Pages/NationalInfo";
import LadingInfo from "../Pages/LadingInfo";
import VeterinaryTransfer from "../Pages/VeterinaryTransfer";

interface Route {
  path: string;
  component: React.ComponentType | any;
}

export const getRoutes = (auth: string | null): Route[] => {
  let generalRoutes: Route[] = [];

  if (auth) {
    generalRoutes = [
      { path: R.HOME, component: MainPage },
      { path: R.PROFILE, component: UserProfile },
      { path: R.USERS, component: Users },
      { path: R.STATICS, component: Statics },
      { path: R.USER_INSPECTIONS, component: UserInspections },
      { path: R.NATIONAL_INFO, component: NationalInfo },
      { path: R.LADING_INFO, component: LadingInfo },
      { path: R.VETERINARY_TRANSFER, component: VeterinaryTransfer },
    ];

    if (checkIsMobile()) {
      generalRoutes.push({ path: R.MENU, component: Menu });
    }
  } else {
    generalRoutes = [
      { path: R.HOME, component: Auth },
      { path: R.AUTO_LOGIN, component: AutoLogin },
    ];
  }

  return generalRoutes;
};
