You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
4.8 KiB
JavaScript
105 lines
4.8 KiB
JavaScript
import React from 'react'
|
|
import ReactDOM from 'react-dom/client'
|
|
import {
|
|
createBrowserRouter,
|
|
RouterProvider,
|
|
} from 'react-router-dom'
|
|
import '@/assets/global.css'
|
|
import App from '@/views/App'
|
|
import Standlone from '@/views/Standlone'
|
|
import Login from '@/views/Login'
|
|
import Logout from '@/views/Logout'
|
|
import ErrorPage from '@/components/ErrorPage'
|
|
import RequireAuth from '@/components/RequireAuth'
|
|
import ReservationNewest from '@/views/reservation/Newest'
|
|
import ReservationDetail from '@/views/reservation/Detail'
|
|
import ChangePassword from '@/views/account/ChangePassword'
|
|
import AccountProfile from '@/views/account/Profile'
|
|
import AccountManagement from '@/views/account/Management'
|
|
import RoleList from '@/views/account/RoleList'
|
|
import FeedbackIndex from '@/views/feedback/Index'
|
|
import FeedbackDetail from '@/views/feedback/Detail'
|
|
import FeedbackCustomerDetail from '@/views/feedback/CustomerDetail'
|
|
import ReportIndex from '@/views/report/Index'
|
|
import NoticeIndex from '@/views/notice/Index'
|
|
import NoticeDetail from '@/views/notice/Detail'
|
|
import InvoiceIndex from '@/views/invoice/Index'
|
|
import InvoiceDetail from '@/views/invoice/Detail'
|
|
import InvoicePaid from '@/views/invoice/Paid'
|
|
import InvoicePaidDetail from '@/views/invoice/PaidDetail'
|
|
import Airticket from '@/views/airticket/Index'
|
|
import AirticketPlan from '@/views/airticket/Plan'
|
|
import { ThemeContext } from '@/stores/ThemeContext'
|
|
import { usingStorage } from '@/hooks/usingStorage'
|
|
import useAuthStore from './stores/Auth'
|
|
import { isNotEmpty } from '@/utils/commons'
|
|
|
|
import ProductsManage from '@/views/products/Manage';
|
|
import ProductsDetail from '@/views/products/Detail';
|
|
import ProductsAudit from '@/views/products/Audit';
|
|
import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT } from '@/config'
|
|
|
|
import './i18n'
|
|
|
|
const initRouter = async () => {
|
|
return createBrowserRouter([
|
|
{
|
|
path: '/',
|
|
element: <App />,
|
|
errorElement: <ErrorPage />,
|
|
children: [
|
|
{ index: true, element: <NoticeIndex /> },
|
|
{ path: 'account/change-password', element: <ChangePassword />},
|
|
{ path: 'account/profile', element: <AccountProfile />},
|
|
{ path: 'account/management', element: <RequireAuth subject={PERM_ACCOUNT_MANAGEMENT} result={true}><AccountManagement /></RequireAuth>},
|
|
{ path: 'account/role-list', element: <RequireAuth subject={PERM_ROLE_NEW} result={true}><RoleList /></RequireAuth>},
|
|
{ path: 'reservation/newest', element: <RequireAuth subject={PERM_OVERSEA} result={true}><ReservationNewest /></RequireAuth>},
|
|
{ path: 'reservation/:reservationId', element: <RequireAuth subject={PERM_OVERSEA} result={true}><ReservationDetail /></RequireAuth>},
|
|
{ path: 'feedback', element: <RequireAuth subject={PERM_OVERSEA} result={true}><FeedbackIndex /></RequireAuth>},
|
|
{ path: 'feedback/:GRI_SN/:CII_SN/:RefNo', element: <RequireAuth subject={PERM_OVERSEA} result={true}><FeedbackCustomerDetail /></RequireAuth>},
|
|
{ path: 'feedback/:GRI_SN/:RefNo', element: <RequireAuth subject={PERM_OVERSEA} result={true}><FeedbackDetail /></RequireAuth>},
|
|
{ path: 'report', element: <RequireAuth subject={PERM_OVERSEA} result={true}><ReportIndex /></RequireAuth>},
|
|
{ path: 'notice', element: <NoticeIndex />},
|
|
{ path: 'notice/:CCP_BLID', element: <NoticeDetail />},
|
|
{ path: 'invoice',element:<RequireAuth subject={PERM_OVERSEA} result={true}><InvoiceIndex /></RequireAuth>},
|
|
{ path: 'invoice/detail/:GMDSN/:GSN',element:<RequireAuth subject={PERM_OVERSEA} result={true}><InvoiceDetail /></RequireAuth>},
|
|
{ path: 'invoice/paid',element:<RequireAuth subject={PERM_OVERSEA} result={true}><InvoicePaid /></RequireAuth>},
|
|
{ path: 'invoice/paid/detail/:flid', element: <RequireAuth subject={PERM_OVERSEA} result={true}><InvoicePaidDetail /></RequireAuth>},
|
|
{ path: 'airticket',element: <RequireAuth subject={PERM_AIR_TICKET} result={true}><Airticket /></RequireAuth>},
|
|
{ path: 'airticket/plan/:coli_sn',element:<RequireAuth subject={PERM_AIR_TICKET} result={true}><AirticketPlan /></RequireAuth>},
|
|
]
|
|
},
|
|
{
|
|
element: <Standlone />,
|
|
children: [
|
|
{ path: '/login', element: <Login /> },
|
|
{ path: '/logout', element: <Logout /> },
|
|
]
|
|
}
|
|
])
|
|
}
|
|
|
|
const initAppliction = async () => {
|
|
|
|
const { loginToken, userId } = usingStorage()
|
|
|
|
if (isNotEmpty(userId) && isNotEmpty(loginToken)) {
|
|
await useAuthStore.getState().initAuth()
|
|
}
|
|
|
|
const router = await initRouter()
|
|
|
|
ReactDOM.createRoot(document.getElementById('root')).render(
|
|
//<React.StrictMode>
|
|
<ThemeContext.Provider value={{ colorPrimary: '#00b96b', borderRadius: 4 }}>
|
|
<RouterProvider
|
|
router={router}
|
|
fallbackElement={() => <div>Loading...</div>}
|
|
/>
|
|
</ThemeContext.Provider>
|
|
//</React.StrictMode>
|
|
)
|
|
}
|
|
|
|
initAppliction()
|