
import React from "react";
import {HashRouter,Routes, Route } from 'react-router-dom';
import Protected from './components/Protected';
import Frontend from './components/frontend/Frontend';
import Home from './components/frontend/Home';
import UserLogin from './components/frontend/UserLogin';
import AddTrade from './components/frontend/AddTrade';
import UserDashboard from './components/frontend/UserDashboard';
import MyOrders from './components/frontend/MyOrders';
import TradeBook from './components/frontend/TradeBook';
import Funds from './components/frontend/Funds';
import Deposite from './components/frontend/Deposite';
import Withdrawl from './components/frontend/Withdrawl';
import Settings from './components/frontend/Settings';
import Bank from './components/frontend/Bank';
import Password from './components/frontend/Password';
import Company from './components/frontend/Company';
import Profile from './components/frontend/Profile';
import Contact from './components/frontend/Contact';
import Register from './components/frontend/Register';
import ForgotPassword from './components/frontend/ForgotPassword';
import ResetPassword from "./components/frontend/ResetPassword";
import AdminLogin from './components/frontend/AdminLogin';
import Dashboard from './components/backend/Dashboard';
import Backend from './components/backend/Backend';
import DemoLink from './components/frontend/DemoLink';
import MatchView from './components/frontend/MatchView';

import Matchlist from './components/backend/Matchlist';
import MatchDetails from './components/backend/MatchDetails';

import AdminAddUser from './components/backend/AdminAddUser';
import AdminEditUser from './components/backend/AdminEditUser';
import AdminUserList from './components/backend/AdminUserList';
import AdminStaff from  './components/backend/AdminStaff';
import AdminProducts from './components/backend/AdminProducts';
import AdminStores from './components/backend/AdminStores';
import AdminCenters from  './components/backend/AdminCenters';
import AdminOrders from './components/backend/AdminOrders';

import AdminAssTypes from './components/backend/AdminAssTypes';
import AdminAssocs from './components/backend/AdminAssocs';
import AdminEvents from './components/backend/AdminEvents';
import AdminFunds from './components/backend/AdminFunds';
import AdminCampns from './components/backend/AdminCampns';
import AdminContri from './components/backend/AdminContri';

function App() {
  const isLoggedIn = JSON.parse(localStorage.getItem("isLoggedIn"));
  return (
    <HashRouter basename="/">
      <Routes>
        <Route path='/login' element={<UserLogin/>}/>
        <Route path='/register' element={<Register/>}/>
        <Route path='/forgotpassword' element={<ForgotPassword/>}/>
        <Route path='/resetpassword/:user' element={<ResetPassword/>}/>
        <Route path='/adminlogin' element={<AdminLogin/>}/>
        <Route path='/addtrade/:metal' element={<AddTrade/>}/>
        <Route path='/deposite' element={<Deposite/>}/>
        <Route path='/withdrawl' element={<Withdrawl/>}/>
        <Route path='/bank' element={<Bank/>}/>
        <Route path='/password' element={<Password/>}/>
        <Route path='/company' element={<Company/>}/>
        <Route path='/contact' element={<Contact/>}/>
        <Route path='/' element={<Frontend/>}>
          <Route index element={<Home/>}/>
          <Route path='/dashboard' element={<UserDashboard/>}/>
          {/* <Route path='/dashboard' element={<Protected isLoggedIn={isLoggedIn}><UserDashboard/></Protected>}/> */}
          <Route path='/orders' element={<MyOrders/>}/>
          <Route path='/tradebook' element={<TradeBook/>}/>
          <Route path='/profile' element={<Profile/>}/>
          <Route path='/settings' element={<Settings/>}/>
          <Route path='/funds' element={<Funds/>}/>
        </Route>
        <Route path='admin' element={<Backend/>}>
          <Route index element={<Protected isLoggedIn={isLoggedIn}><Dashboard/></Protected>}/>
          <Route path='/admin/adduser' element={<Protected isLoggedIn={isLoggedIn}><AdminAddUser /></Protected>}/>
          <Route path='/admin/matchlist' element={<Protected isLoggedIn={isLoggedIn}><Matchlist /></Protected>}/>
          <Route path='/admin/matchdetails/:matchid' element={<Protected isLoggedIn={isLoggedIn}><MatchDetails /></Protected>}/>
          <Route path='/admin/edituser/:userid' element={<Protected isLoggedIn={isLoggedIn}><AdminEditUser /></Protected>}/>
          <Route path='/admin/users'  element={<Protected isLoggedIn={isLoggedIn}><AdminUserList /></Protected>}/>
          
          <Route path='/admin/staff' element={<Protected isLoggedIn={isLoggedIn}><AdminStaff/></Protected>}/>
          <Route path='/admin/medicines' element={<Protected isLoggedIn={isLoggedIn}><AdminProducts/></Protected>}/>
          <Route path='/admin/stores' element={<Protected isLoggedIn={isLoggedIn}><AdminStores/></Protected>}/>
          <Route path='/admin/centers' element={<Protected isLoggedIn={isLoggedIn}><AdminCenters/></Protected>}/>
          <Route path='/admin/orders' element={<Protected isLoggedIn={isLoggedIn}><AdminOrders/></Protected>}/> 
          
          <Route path='/admin/types' element={<Protected isLoggedIn={isLoggedIn}><AdminAssTypes/></Protected>}/>
          <Route path='/admin/associations' element={<Protected isLoggedIn={isLoggedIn}><AdminAssocs/></Protected>}/>
          <Route path='/admin/events' element={<Protected isLoggedIn={isLoggedIn}><AdminEvents/></Protected>}/>
          <Route path='/admin/funds' element={<Protected isLoggedIn={isLoggedIn}><AdminFunds/></Protected>}/>
          <Route path='/admin/campaings' element={<Protected isLoggedIn={isLoggedIn}><AdminCampns/></Protected>}/>
          <Route path='/admin/contributions' element={<Protected isLoggedIn={isLoggedIn}><AdminContri/></Protected>}/>
        </Route>
      </Routes> 
    </HashRouter>
  );
}

export default App;