Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: routes in communication tabs[WTEL-4296] #58

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({});
Lera24 marked this conversation as resolved.
Show resolved Hide resolved

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')) {
Lera24 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading