/* eslint-disable prefer-template */ import Vue from 'vue'; import EvaIcons from 'vue-eva-icons'; import axios from 'axios'; import App from './App.vue'; import router from './router'; import store from './store'; Vue.use(EvaIcons); Vue.config.productionTip = false; Vue.prototype.$http = axios; const token = localStorage.getItem('token'); if (token) { Vue.prototype.$http.defaults.headers.common.Authorization = token; } router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requiresAuth)) { if (store.getters.isLoggedIn) { next(); return; } next('/users/login'); } else { next(); } }); Vue.filter('toCurrency', (value) => { if (typeof value !== 'number') { return value; } const formatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, }); return `R ${formatter.format(value)}`; }); Vue.filter('toProper', (value) => { if (typeof value !== 'string') { console.log(typeof value); return value; } value = value.replace(/([a-z])([A-Z])/g, '$1 $2'); return value.charAt(0).toUpperCase() + value.slice(1); }); Vue.filter('toDate', value => value.substring(0, value.length > 9 ? 10 : value.length)); new Vue({ render: h => h(App), router, store, }).$mount('#app');