1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /* eslint-disable prefer-template */
- import Vue from "vue";
- import EvaIcons from "vue-eva-icons";
- import axios from "axios";
- import moment from "moment";
- import App from "./App.vue";
- import router from "./router";
- import store from "./store";
- import VModal from "vue-js-modal";
- import "font-awesome/css/font-awesome.min.css";
- import VueGeolocation from "vue-browser-geolocation";
- import * as VueGoogleMaps from "vue2-google-maps";
- import { BootstrapVue, IconsPlugin } from "bootstrap-vue";
- import "bootstrap/dist/css/bootstrap.css";
- import "bootstrap-vue/dist/bootstrap-vue.css";
- import { library } from "@fortawesome/fontawesome-svg-core";
- import { fas } from "@fortawesome/free-solid-svg-icons";
- import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
-
- library.add(fas);
- Vue.component("font-awesome-icon", FontAwesomeIcon);
- Vue.use(BootstrapVue);
- Vue.use(IconsPlugin);
- Vue.use(VueGeolocation);
- Vue.use(VueGoogleMaps, {
- load: {
- key: "AIzaSyC1Ksf24t03oxHkQYb-DymF9HipgGP30ao",
- libraries: "places" // necessary for places input
- }
- });
-
- Vue.component("VueFontawesome", require("vue-fontawesome-icon/VueFontawesome.vue").default);
-
- Vue.use(EvaIcons);
-
- Vue.config.productionTip = false;
- Vue.prototype.$axios = axios;
-
- 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));
-
- Vue.filter("toTime", value => moment(String(value)).format("hh:mm"));
-
- new Vue({
- render: h => h(App),
- router,
- store
- }).$mount("#app");
-
- Vue.use(VModal);
|