{"size": 1483, "ext": "js", "max_stars_repo_path": "src/main.js", "max_stars_repo_name": "ranmaru74/dotory", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/main.js", "max_issues_repo_name": "ranmaru74/dotory", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/main.js", "max_forks_repo_name": "ranmaru74/dotory", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.7166666667, "max_line_length": 106, "alphanum_fraction": 0.5306810519}
import Vue from 'vue';
import VueRouter from 'vue-router';

import { routes } from './routes';
import store from './stores/store';
import { ref, firebaseListener } from './config/firebaseConfig';
import './assets/styles/app.scss'

require("dotenv").config();
import App from './App.vue';

Vue.use(VueRouter);


firebaseListener(authStatusChange);


const router = new VueRouter({
    mode: 'history',
    routes
});

// router.beforeEach((to, from, next) => {
//     if (to.onlyGuest && store.getters.isLoggedIn) {
//         next('/');
//     } else {
//         next();
//     }
// });


new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
})

function authStatusChange(loggedIn, user) {
    if (store) {
        console.log('AUTH_STATUS_CHANGE');

        store.commit('AUTH_STATUS_CHANGE');
        if (user) {
            // ref.child('account').once('value', (accounts) => {
            //     const data = accounts.val();
            //     store.commit('setAccount', {});
            //     for(let key in data) {
            //         store.commit('setAccount', data[key]);
            //         if(user.email == data[key].wallet) {
            //             store.commit('setCurrentAccount', data[key]);
            //         }
            //     }
            // })
            store.dispatch('listenToAccountList', user)
            store.dispatch('getShoppingCart', { uid: user.uid, currentCart: store.getters.cartItemList });
        }
    }
}
