chore: Show new account modal if user accounts are empty (#2448)
This commit is contained in:
parent
5b3339cd33
commit
9f3f238cb5
3 changed files with 56 additions and 0 deletions
|
@ -3,12 +3,17 @@
|
||||||
<transition name="fade" mode="out-in">
|
<transition name="fade" mode="out-in">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</transition>
|
</transition>
|
||||||
|
<add-account-modal
|
||||||
|
:show="showAddAccountModal"
|
||||||
|
:has-accounts="hasAccounts"
|
||||||
|
/>
|
||||||
<woot-snackbar-box />
|
<woot-snackbar-box />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
import AddAccountModal from '../dashboard/components/layout/sidebarComponents/AddAccountModal';
|
||||||
import WootSnackbarBox from './components/SnackbarContainer';
|
import WootSnackbarBox from './components/SnackbarContainer';
|
||||||
import { accountIdFromPathname } from './helper/URLHelper';
|
import { accountIdFromPathname } from './helper/URLHelper';
|
||||||
|
|
||||||
|
@ -17,14 +22,36 @@ export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
WootSnackbarBox,
|
WootSnackbarBox,
|
||||||
|
AddAccountModal,
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showAddAccountModal: false,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
getAccount: 'accounts/getAccount',
|
getAccount: 'accounts/getAccount',
|
||||||
|
currentUser: 'getCurrentUser',
|
||||||
}),
|
}),
|
||||||
|
hasAccounts() {
|
||||||
|
return (
|
||||||
|
this.currentUser &&
|
||||||
|
this.currentUser.accounts &&
|
||||||
|
this.currentUser.accounts.length !== 0
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
currentUser() {
|
||||||
|
if (!this.hasAccounts) {
|
||||||
|
this.showAddAccountModal = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.dispatch('setUser');
|
this.$store.dispatch('setUser');
|
||||||
this.setLocale(window.chatwootConfig.selectedLocale);
|
this.setLocale(window.chatwootConfig.selectedLocale);
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
:header-title="$t('CREATE_ACCOUNT.NEW_ACCOUNT')"
|
:header-title="$t('CREATE_ACCOUNT.NEW_ACCOUNT')"
|
||||||
:header-content="$t('CREATE_ACCOUNT.SELECTOR_SUBTITLE')"
|
:header-content="$t('CREATE_ACCOUNT.SELECTOR_SUBTITLE')"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="!hasAccounts" class="alert-wrap">
|
||||||
|
<div class="callout alert">
|
||||||
|
<div class="icon-wrap">
|
||||||
|
<i class="ion-alert-circled"></i>
|
||||||
|
</div>
|
||||||
|
{{ $t('CREATE_ACCOUNT.NO_ACCOUNT_WARNING') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form class="row" @submit.prevent="addAccount">
|
<form class="row" @submit.prevent="addAccount">
|
||||||
<div class="medium-12 columns">
|
<div class="medium-12 columns">
|
||||||
|
@ -53,6 +61,10 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
hasAccounts: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -90,3 +102,19 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.alert-wrap {
|
||||||
|
margin: var(--space-zero) var(--space-large);
|
||||||
|
margin-top: var(--space-medium);
|
||||||
|
.callout {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-wrap {
|
||||||
|
font-size: var(--font-size-big);
|
||||||
|
margin-left: var(--space-smaller);
|
||||||
|
margin-right: var(--space-slab);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
"CSAT": "CSAT"
|
"CSAT": "CSAT"
|
||||||
},
|
},
|
||||||
"CREATE_ACCOUNT": {
|
"CREATE_ACCOUNT": {
|
||||||
|
"NO_ACCOUNT_WARNING": "Uh oh! We could not find any Chatwoot accounts. Please create a new account to continue.",
|
||||||
"NEW_ACCOUNT": "New Account",
|
"NEW_ACCOUNT": "New Account",
|
||||||
"SELECTOR_SUBTITLE": "Create a new account",
|
"SELECTOR_SUBTITLE": "Create a new account",
|
||||||
"API": {
|
"API": {
|
||||||
|
|
Loading…
Reference in a new issue