You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* eslint-disable prefer-template */
  2. import Vue from "vue";
  3. import EvaIcons from "vue-eva-icons";
  4. import axios from "axios";
  5. import moment from "moment";
  6. import App from "./App.vue";
  7. import router from "./router";
  8. import store from "./store";
  9. import VModal from "vue-js-modal";
  10. import "font-awesome/css/font-awesome.min.css";
  11. import VueGeolocation from "vue-browser-geolocation";
  12. import * as VueGoogleMaps from "vue2-google-maps";
  13. import { BootstrapVue, IconsPlugin } from "bootstrap-vue";
  14. import "bootstrap/dist/css/bootstrap.css";
  15. import "bootstrap-vue/dist/bootstrap-vue.css";
  16. import { library } from "@fortawesome/fontawesome-svg-core";
  17. import { fas } from "@fortawesome/free-solid-svg-icons";
  18. import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
  19. library.add(fas);
  20. Vue.component("font-awesome-icon", FontAwesomeIcon);
  21. Vue.use(BootstrapVue);
  22. Vue.use(IconsPlugin);
  23. Vue.use(VueGeolocation);
  24. Vue.use(VueGoogleMaps, {
  25. load: {
  26. key: "AIzaSyC1Ksf24t03oxHkQYb-DymF9HipgGP30ao",
  27. libraries: "places" // necessary for places input
  28. }
  29. });
  30. Vue.component("VueFontawesome", require("vue-fontawesome-icon/VueFontawesome.vue").default);
  31. Vue.use(EvaIcons);
  32. Vue.config.productionTip = false;
  33. Vue.prototype.$axios = axios;
  34. Vue.prototype.$http = axios;
  35. const token = localStorage.getItem("token");
  36. if (token) {
  37. Vue.prototype.$http.defaults.headers.common.Authorization = token;
  38. }
  39. router.beforeEach((to, from, next) => {
  40. if (to.matched.some(record => record.meta.requiresAuth)) {
  41. if (store.getters.isLoggedIn) {
  42. next();
  43. return;
  44. }
  45. next("/users/login");
  46. } else {
  47. next();
  48. }
  49. });
  50. Vue.filter("toCurrency", value => {
  51. if (typeof value !== "number") {
  52. return value;
  53. }
  54. const formatter = new Intl.NumberFormat("en-US", {
  55. minimumFractionDigits: 2
  56. });
  57. return `R ${formatter.format(value)}`;
  58. });
  59. Vue.filter("toProper", value => {
  60. if (typeof value !== "string") {
  61. console.log(typeof value);
  62. return value;
  63. }
  64. value = value.replace(/([a-z])([A-Z])/g, "$1 $2");
  65. return value.charAt(0).toUpperCase() + value.slice(1);
  66. });
  67. Vue.filter("toDate", value => value.substring(0, value.length > 9 ? 10 : value.length));
  68. Vue.filter("toTime", value => moment(String(value)).format("hh:mm"));
  69. new Vue({
  70. render: h => h(App),
  71. router,
  72. store
  73. }).$mount("#app");
  74. Vue.use(VModal);