Skip to content

Commit

Permalink
fix: routes in communication tabs[WTEL-4296]
Browse files Browse the repository at this point in the history
  • Loading branch information
Lera24 committed Mar 18, 2024
1 parent b31995e commit 1650566
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/app/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,22 @@ const routes = [
children: [
{
path: 'communications',
redirect: {
name: `${CrmSections.CONTACTS}-communications-phones`
},
name: `${CrmSections.CONTACTS}-communications`,
component: ContactCommunications,
},
{
path: 'communications/phones',
name: `${CrmSections.CONTACTS}-communications-phones`,
component: ContactCommunications,
},
{
path: 'communications/emails',
name: `${CrmSections.CONTACTS}-communications-emails`,
component: ContactCommunications,
},
{
path: 'variables',
name: `${CrmSections.CONTACTS}-variables`,
Expand Down
25 changes: 22 additions & 3 deletions src/modules/contacts/components/opened-contact-communications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:disabled="currentTab.value === tab.value"
:color="currentTab.value !== tab.value && 'secondary'"
wide
@click="currentTab = tab"
@click="changeTab(tab)"
>
<wt-icon
:icon="tab.icon"
Expand All @@ -23,9 +23,11 @@
</template>

<script setup>
import { computed, inject, ref } from 'vue';
import { computed, inject, ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex';
import CrmSections from '@webitel/ui-sdk/src/enums/WebitelApplications/CrmSections.enum';
import TheEmails from '../modules/emails/components/the-emails.vue';
import ThePhones from '../modules/phones/components/the-phones.vue';
Expand All @@ -43,6 +45,8 @@ const phonesNamespace = `${props.namespace}/phones`;
const store = useStore();
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
const tabs = computed(() => [
{
Expand All @@ -52,6 +56,7 @@ const tabs = computed(() => [
namespace: phonesNamespace,
icon: 'call',
channel: 'number', // must be same as comm popup channel
pathName: `${CrmSections.CONTACTS}-communications-phones`,
},
{
value: 'emails',
Expand All @@ -60,10 +65,24 @@ const tabs = computed(() => [
namespace: emailsNamespace,
icon: 'email',
channel: 'email', // must be same as comm popup channel
pathName: `${CrmSections.CONTACTS}-communications-emails`,
},
]);
const currentTab = ref(tabs.value[0]);
const currentTab = ref({});
function changeTab(tab) {
currentTab.value = tab;
return router.push({ name: tab.pathName });
}
function initializeCommunicationsTab() {
currentTab.value = tabs.value.find(({ pathName }) => pathName === route.name)
}
onMounted(() => {
initializeCommunicationsTab();
});
</script>

Expand Down
7 changes: 6 additions & 1 deletion src/modules/contacts/components/opened-contact-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ const tabs = computed(() => [
},
]);
const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name));
const currentTab = computed(() => {
if(route.name.includes('communications')) {
return tabs.value.find(tab => tab.value === 'communications')
}
return tabs.value.find(({ pathName }) => pathName === route.name)
});
function changeTab(tab) {
return router.push({ name: tab.pathName });
Expand Down

0 comments on commit 1650566

Please sign in to comment.