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 all commits
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
16 changes: 16 additions & 0 deletions src/app/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,25 @@ const routes = [
children: [
{
path: 'communications',
redirect: {
name: `${CrmSections.CONTACTS}-communications-phones`,
},
name: `${CrmSections.CONTACTS}-communications`,
component: ContactCommunications,
children: [
{
path: 'phones',
name: `${CrmSections.CONTACTS}-communications-phones`,
component: ContactCommunications,
},
{
path: 'emails',
name: `${CrmSections.CONTACTS}-communications-emails`,
component: ContactCommunications,
},
],
},

{
path: 'variables',
name: `${CrmSections.CONTACTS}-variables`,
Expand Down
16 changes: 13 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,15 @@ 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 = computed(() => tabs.value.find(({ pathName }) => pathName === route.name))

function changeTab(tab) {
return router.push({ name: tab.pathName });
}

</script>

Expand Down
12 changes: 3 additions & 9 deletions src/modules/contacts/components/opened-contact-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,13 @@ const tabs = computed(() => [
},
]);

const currentTab = computed(() => tabs.value.find(({ pathName }) => pathName === route.name));
const currentTab = computed(() => {
return tabs.value.find(({ pathName }) => route?.matched?.find(({name}) => name === pathName));
});

function changeTab(tab) {
return router.push({ name: tab.pathName });
}

function initializeTab() {
if (!currentTab.value) changeTab(tabs.value[0]);
}

onMounted(() => {
initializeTab();
});
</script>

<style lang="scss" scoped>
Expand Down
Loading