Skip to content
Snippets Groups Projects
main.tsx 3.13 KiB
Newer Older
import React from 'react';
import ReactDOM from 'react-dom/client';
lcross2002's avatar
lcross2002 committed
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import App from './App.tsx';
import Login from './components/Login/Login.tsx';
import Register from './components/Register/Register.tsx';
import Logout from './components/Logout/Logout.tsx';
import ProtectedRoute from './components/ProtectedRoute/ProtectedRoute.tsx';
import InverseProtectedRoute from './components/ProtectedRoute/InverseProtectedRoute.tsx';
import Dashboard from './components/Dashboard/Dashboard.tsx';
import Flight from './components/Flight/Flight.tsx';
import FlightList from './components/FlightList/FlightList.tsx';
import BookingQuery from './components/BookingQuery/BookingQuery.tsx';
import BookingList from './components/BookingList/BookingList.tsx';
import { AuthoriseUser } from './services/Authorise/Authorise.ts';
import { LogoutUser } from './services/Logout/Logout.ts';
import { GetCustomerDashboardData } from './services/Dashboard/CustomerDashboard.ts';
import { GetAirlineDashboardData } from './services/Dashboard/AirlineDashboard.ts';
import { GetFlightData } from './services/Flight/Flight.ts';
import { GetFlightList } from './services/FlightList/FlightList.ts';
import { GetBookingList } from './services/BookingList/BookingList.ts';
import './index.scss';
Arzan Pour, Arshia (UG - SISC)'s avatar
Arzan Pour, Arshia (UG - SISC) committed
import FlightCreationForm from './components/FlightCreationForm/FlightCreationForm.tsx';
lcross2002's avatar
lcross2002 committed
const router = createBrowserRouter([
  {
    path: '/',
lcross2002's avatar
lcross2002 committed
    element: <App></App>,
    children: [
      {
        element: <InverseProtectedRoute></InverseProtectedRoute>,
        children: [
          {
            path: 'login',
            element: <Login></Login>
          },
          {
            path: 'register',
            element: <Register></Register>
          }
        ]
        element: <ProtectedRoute></ProtectedRoute>,
        children: [
          {
            path: 'logout',
            loader: LogoutUser,
            element: <Logout></Logout>
          },
          {
            path: 'customer-dashboard',
            loader: GetCustomerDashboardData,
            element: <Dashboard></Dashboard>
          },
          {
            path: 'airline-dashboard',
            loader: GetAirlineDashboardData,
            element: <Dashboard></Dashboard>
          {
            path: 'flight/:id',
            loader: GetFlightData,
            element: <Flight></Flight>
          },
          {
            path: 'flights',
            loader: GetFlightList,
            element: <FlightList></FlightList>
          },
          {
            path: 'booking/query',
            element: <BookingQuery></BookingQuery>
          },
          {
            path: 'booking/list',
            loader: GetBookingList,
            element: <BookingList></BookingList>
Arzan Pour, Arshia (UG - SISC)'s avatar
Arzan Pour, Arshia (UG - SISC) committed
          },
          {
            path: 'register-flight',
            element: <FlightCreationForm></FlightCreationForm>
lcross2002's avatar
lcross2002 committed
      }
    ]
  }
]);

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
lcross2002's avatar
lcross2002 committed
    <RouterProvider router={router}></RouterProvider>
  </React.StrictMode>,
)