/** ** **
** Libs
** ** **/
import Vue from 'vue';
import VueRouter from 'vue-router';
import auth from '../services/OAuthService';
/** ** **
** Components
** ** * */
import Home from '../components/Home.vue';
import Login from './Login';
/** ** **
** Routes
** ** * */
const Dashboard = () => System.import('./dashboard/router');
const Deals = () => System.import('./deals/deals');
const Tasks = () => System.import('./tasks');
const WorkSchedule = () => System.import('./workSchedule');
const Contacts = () => System.import('./contacts');
const Plannings = () => System.import('./planning/plannings');
const Meetings = () => System.import('./meetings');
const Swot = () => System.import('./planning/swot');
const Vision = () => System.import('./planning/vision');
const Projects = () => System.import('./projects');
const Settings = () => System.import('./settings');
const Customers = () => System.import('./customers/customers');
const Products = () => System.import('./products');
const Timesheets = () => System.import('./timesheets');
// const Login = () => System.import('./login');
const PlanTree = () => System.import('./planning/plantree');
const Tickers = () => System.import('./tickets/tickets');
const Scorecard = () => System.import('./scorecard');
const Kanban = () => System.import('./kanban');
const Reports = () => System.import('./reports');
const mycalendar = () => System.import('./mycalendar');
const Kpi = () => System.import('./kpi');
const KpiDataEntry = () => System.import('./kpidataentry');
const LicenseControl = () => System.import('./licensecontrol');
const ProductLicense = () => System.import('./productlicense');
const routes = [{
path: '*',
redirect: '/',
component: App,
meta: {
requireAuth: true,
},
},
{
path: '/',
component: Home,
meta: {
requireAuth: true,
},
},
Dashboard,
Deals,
Tasks,
Contacts,
Plannings,
Projects,
Settings,
Customers,
Products,
Timesheets,
Swot,
Vision,
Tickers,
PlanTree,
Login,
Meetings,
Scorecard,
Kanban,
Reports,
mycalendar,
Kpi,
KpiDataEntry,
WorkSchedule,
LicenseControl,
ProductLicense,
];
/** ** **
** Uses
** ** **/
Vue.use(VueRouter);
/** ** **
** Main Export
** ** * */
const router = new VueRouter({
// mode: 'history',
linkActiveClass: 'active-link',
routes,
});
router.beforeEach((to, from, next) => {
if (!auth.isAccessTokenValid()) {
if (!to.meta.isLogin) {
auth.getNewAccessToken().then(
sucess => {
next();
},
error => {
next('/login');
},
);
} else {
next();
}
} else {
next();
}
});
export default router;