175 lines
6.4 KiB
JavaScript
175 lines
6.4 KiB
JavaScript
import React from "react";
|
|
import {observer, inject} from 'mobx-react';
|
|
import {BrowserRouter as Router, Route, Switch, Redirect} from "react-router-dom";
|
|
import RegisterComponent from "./pages/RegisterNew";
|
|
import LoginComponent from "./pages/Login";
|
|
import LoginBTNComponent from "./pages/Login/LoginBtn";
|
|
import ForgotPasswordComponent from "./pages/ForgotPassword";
|
|
import ChangePassword from './pages/ChangePassword';
|
|
import AppContainer from "./pages/App";
|
|
import InviteConfirmationComponent from './pages/InviteConfirmation';
|
|
import InviteConfirmationLoginComponent from './pages/InviteConfirmationLogin/index';
|
|
import AcceptInvite from "./pages/AcceptInvite/index";
|
|
import OtpPage from "./pages/Otp";
|
|
|
|
export const LINKS = {
|
|
ROOT: '/',
|
|
APP_CONTAINER: '/app',
|
|
DASHBOARD: '/app/dashboard',
|
|
DATA : '/app/data',
|
|
CONTENT : '/app/content',
|
|
LAYOUT : '/app/layout',
|
|
REPORT: '/app/report',
|
|
CATEGORIES: '/app/categories',
|
|
RECIPES: '/app/recipes',
|
|
FORM_RECIPE : '/app/recipes/form',
|
|
FORM_RECIPE_EDIT : '/app/recipes/form/:id',
|
|
HELP: '/app/help',
|
|
CONTENT_MANAGER: '/app/content_manager',
|
|
FORM_HELP : '/app/help/form',
|
|
FORM_HELP_EDIT : '/app/help/form/:id',
|
|
FORM : '/app/content/posts/form',
|
|
FORM_EDIT : '/app/content/posts/form/:id',
|
|
SURF: '/app/surf_turf',
|
|
FORM_SURF : '/app/surf_turf/form',
|
|
FORM_SURF_EDIT : '/app/surf_turf/form/:id',
|
|
SETTING: '/app/setting',
|
|
WALLET: '/app/wallet',
|
|
WALLET_DETAIL: '/app/wallet/:id',
|
|
PROFILE: '/app/profile',
|
|
SERVICE: '/app/service',
|
|
ITEMS: '/app/shop',
|
|
FORM_UPLOAD: '/app/items/form_upload',
|
|
FORM_UPLOAD_ADMIN: '/app/items/form_upload/:id',
|
|
FORM_UPLOAD_PROMOTION: '/app/promotion/form_upload_promotion/:id',
|
|
FORM_ITEMS: '/app/items/form',
|
|
FORM_ITEMS_ADMIN: '/app/items/form/:id',
|
|
FORM_ITEMS_EDIT: '/app/items/form/edit/:id',
|
|
FORM_PROMOTION: '/app/promotion/form/:id',
|
|
SERVICE_PACKAGES: '/app/service/packages',
|
|
SERVICE_PACKAGES_DETAIL: '/app/service/packages/:id',
|
|
SERVICE_AIRLINES: '/app/service/airlines',
|
|
SERVICE_AIRLINES_SEARCH: '/app/service/airlines/search',
|
|
SERVICE_AIRLINES_SEARCH_RETURN: '/app/service/airlines/search_return',
|
|
SERVICE_AIRLINES_BOOK: '/app/service/airlines/book',
|
|
SERVICE_AIRLINES_REVIEW: '/app/service/airlines/review',
|
|
SERVICE_TRAINS: '/app/service/trains',
|
|
SERVICE_RAILINKS: '/app/service/railinks',
|
|
SERVICE_BUSSES: '/app/service/busses',
|
|
SERVICE_HOTELS: '/app/service/hotels',
|
|
SERVICE_PPOB: '/app/service/ppob',
|
|
NOTFICATION_ADMIN: '/app/notification_admin',
|
|
SERVICE_PACKAGE: '/app/service/package',
|
|
SERVICE_PACKAGE_DETAIL: '/app/service/package/:id',
|
|
STORES: '/app/store',
|
|
STORES_LIST: '/app/stores_list',
|
|
STORES_LIST_DETAIL: '/app/stores_list/:id',
|
|
AGENT: '/app/agents',
|
|
AGENT_DETAIL: '/app/agents/:id',
|
|
EMPLOYEE: '/app/employee',
|
|
EMPLOYEE_DETAIL: '/app/employee/:id',
|
|
LAYERS: '/app/layers',
|
|
CUSTOMER: '/app/customers',
|
|
CUSTOMER_DETAIL: '/app/customers/:id',
|
|
WALLET_CUSTOMER: '/app/customers/:id/wallet',
|
|
WALLET_CUSTOMER_DETAIL: '/app/customers/:id/wallet/:id',
|
|
ORDER: '/app/order',
|
|
ORDER_DETAIL: '/app/order/:id',
|
|
ORDER_DETAIL_AIRLINES: '/app/order_detail_airline/:id',
|
|
ORDER_DETAIL_AIRLINES_WO_ID: '/app/order_detail_airline',
|
|
REGISTER: '/register',
|
|
LOGIN: '/login',
|
|
FORGOT_PASSWORD: '/forgot_password',
|
|
ACCEPT_INVITE: '/register_store',
|
|
ENTITIES: '/app/entities',
|
|
INVITE_CONFIRMATION: '/invite_confirmation',
|
|
INVITE_CONFIRMATION_LOGIN: '/invite_confirmation_login',
|
|
PACKAGE_SETTING: '/app/setting/package',
|
|
PACKAGE_SETTING_DETAIL: '/app/setting/package/:id',
|
|
PAYMENT_METHOD: '/app/setting/payment_method',
|
|
PAYMENT_METHOD_DETAIL: '/app/setting/payment_method/:id',
|
|
REWARD: '/app/setting/reward',
|
|
// CATEGORIES: '/app/setting/categories',
|
|
REWARD_DETAIL: '/app/setting/reward/:id',
|
|
CATEGORIES_DETAIL: '/app/setting/categories/:id',
|
|
CURRENCY: '/app/setting/currency',
|
|
CURRENCY_DETAIL: '/app/setting/currency/:id',
|
|
USER: '/app/setting/user',
|
|
USER_DETAIL: '/app/setting/user/:id',
|
|
ROLE_CREATE: '/app/setting/role/create',
|
|
ROLE_DETAIL: '/app/setting/role/:id',
|
|
ROLE_DETAIL_WO_ID: '/app/setting/role/',
|
|
INBOX:'/app/inbox',
|
|
TASKS:'/app/tasks',
|
|
TASKS_DETAIL: '/app/tasks/:id',
|
|
CHANGE_PASSWORD : '/change_password',
|
|
FEATURED_STORES : '/app/featured_stores',
|
|
FEATURED_CATEGORY : '/app/featured_categories',
|
|
FEATURED_ITEMS : '/app/featured_banners',
|
|
CUSTOM_MENU : '/app/custom_menu',
|
|
PROMOTION:'/app/promotion',
|
|
HOTEL:'/app/hotel',
|
|
HOTEL_SEARCH:'/app/hotel/search',
|
|
CAR:'/app/car',
|
|
CAR_SEARCH:'/app/car/search',
|
|
VOUCHERS: '/app/vouchers',
|
|
VERIFY_VOUCHERS: '/app/vouchers/verify',
|
|
CHECKOUT_VOUCHERS: '/app/vouchers/checkout',
|
|
PAYMENT_VOUCHERS: '/app/vouchers/payment',
|
|
CART_DETAIL: '/app/cart',
|
|
TRANSACTION: '/app/transaction',
|
|
OTP : '/login/otp',
|
|
VOUCHER_STEPPER: '/app/vouchers/buy',
|
|
};
|
|
|
|
@inject('appstate')
|
|
@observer
|
|
export default class Routes extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.props = props;
|
|
this.state = {};
|
|
this.defaultState = Object.assign({}, this.state);
|
|
this.authStore = props.appstate.auth;
|
|
}
|
|
|
|
componentDidMount() {
|
|
console.log("Checking User Status: ", this.authStore.isLoggedIn);
|
|
}
|
|
|
|
render() {
|
|
|
|
const PrivateRoute = ({component: Component, ...rest}) => (
|
|
<Route
|
|
{...rest}
|
|
render={
|
|
(props) => true === true
|
|
? (<Component {...props}/>)
|
|
: (<Redirect to={{pathname : LINKS.LOGIN}}/>
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
|
|
return (
|
|
<Router>
|
|
<Switch>
|
|
<Route exact path={LINKS.ROOT} render={props => (<Redirect
|
|
to={{
|
|
pathname: this.authStore.isLoggedIn ? LINKS.DASHBOARD : LINKS.LOGIN
|
|
}}/>)}/>
|
|
<Route exact path={LINKS.REGISTER} component={RegisterComponent}/>
|
|
<Route exact path={LINKS.LOGIN} component={LoginBTNComponent}/>
|
|
<Route exact path={LINKS.OTP} component={OtpPage}/>
|
|
<Route exact path={LINKS.FORGOT_PASSWORD} component={ForgotPasswordComponent}/>
|
|
<Route exact path={LINKS.INVITE_CONFIRMATION} component={InviteConfirmationComponent}/>
|
|
<Route exact path={LINKS.INVITE_CONFIRMATION_LOGIN} component={InviteConfirmationLoginComponent}/>
|
|
<Route exact path={LINKS.ACCEPT_INVITE} component={AcceptInvite}/>
|
|
<Route path={LINKS.CHANGE_PASSWORD} component={ChangePassword}/>
|
|
<PrivateRoute path={LINKS.APP_CONTAINER} component={AppContainer}/>
|
|
</Switch>
|
|
</Router>
|
|
);
|
|
}
|
|
};
|