2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div id="app" class="app-wrapper app-root">
|
|
|
|
<transition name="fade" mode="out-in">
|
|
|
|
<router-view></router-view>
|
|
|
|
</transition>
|
2021-08-02 03:24:53 +00:00
|
|
|
<add-account-modal
|
|
|
|
:show="showAddAccountModal"
|
|
|
|
:has-accounts="hasAccounts"
|
|
|
|
/>
|
2019-12-16 12:53:14 +00:00
|
|
|
<woot-snackbar-box />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-04-06 16:47:07 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-08-02 03:24:53 +00:00
|
|
|
import AddAccountModal from '../dashboard/components/layout/sidebarComponents/AddAccountModal';
|
2019-08-14 09:48:44 +00:00
|
|
|
import WootSnackbarBox from './components/SnackbarContainer';
|
2020-04-06 16:47:07 +00:00
|
|
|
import { accountIdFromPathname } from './helper/URLHelper';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2019-08-25 06:13:15 +00:00
|
|
|
name: 'App',
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
components: {
|
|
|
|
WootSnackbarBox,
|
2021-08-02 03:24:53 +00:00
|
|
|
AddAccountModal,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showAddAccountModal: false,
|
|
|
|
};
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
|
2020-04-06 16:47:07 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
getAccount: 'accounts/getAccount',
|
2021-08-02 03:24:53 +00:00
|
|
|
currentUser: 'getCurrentUser',
|
2020-04-06 16:47:07 +00:00
|
|
|
}),
|
2021-08-02 03:24:53 +00:00
|
|
|
hasAccounts() {
|
|
|
|
return (
|
|
|
|
this.currentUser &&
|
|
|
|
this.currentUser.accounts &&
|
|
|
|
this.currentUser.accounts.length !== 0
|
|
|
|
);
|
|
|
|
},
|
2020-04-06 16:47:07 +00:00
|
|
|
},
|
|
|
|
|
2021-08-02 03:24:53 +00:00
|
|
|
watch: {
|
|
|
|
currentUser() {
|
|
|
|
if (!this.hasAccounts) {
|
|
|
|
this.showAddAccountModal = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
mounted() {
|
2020-02-16 11:50:38 +00:00
|
|
|
this.$store.dispatch('setUser');
|
2020-11-24 13:04:31 +00:00
|
|
|
this.setLocale(window.chatwootConfig.selectedLocale);
|
2020-04-06 16:47:07 +00:00
|
|
|
this.initializeAccount();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-11-24 13:04:31 +00:00
|
|
|
setLocale(locale) {
|
2020-12-12 06:38:36 +00:00
|
|
|
this.$root.$i18n.locale = locale;
|
2020-11-24 13:04:31 +00:00
|
|
|
},
|
|
|
|
|
2020-04-06 16:47:07 +00:00
|
|
|
async initializeAccount() {
|
|
|
|
const { pathname } = window.location;
|
|
|
|
const accountId = accountIdFromPathname(pathname);
|
|
|
|
|
|
|
|
if (accountId) {
|
|
|
|
await this.$store.dispatch('accounts/get');
|
|
|
|
const { locale } = this.getAccount(accountId);
|
2020-11-24 13:04:31 +00:00
|
|
|
this.setLocale(locale);
|
2020-04-06 16:47:07 +00:00
|
|
|
}
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import './assets/scss/app';
|
|
|
|
</style>
|
2019-08-25 06:13:15 +00:00
|
|
|
|
|
|
|
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
|