diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index 6603a25c6..3a5abf952 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -25,6 +25,7 @@ v-for="chat in conversationList" :key="chat.id" :active-label="label" + :team-id="teamId" :chat="chat" /> @@ -76,14 +77,14 @@ export default { type: [String, Number], default: 0, }, + teamId: { + type: [String, Number], + default: 0, + }, label: { type: String, default: '', }, - activeTeam: { - type: Object, - default: () => {}, - }, }, data() { return { @@ -132,7 +133,7 @@ export default { status: this.activeStatus, page: this.currentPage + 1, labels: this.label ? [this.label] : undefined, - teamId: this.activeTeam.name ? this.activeTeam.id : undefined, + teamId: this.teamId ? this.teamId : undefined, }; }, pageTitle() { @@ -168,6 +169,12 @@ export default { return labels.includes(this.label); }); }, + activeTeam() { + if (this.teamId) { + return this.$store.getters['teams/getTeam'](this.teamId); + } + return {}; + }, }, watch: { activeTeam() { diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue index 4b8193699..43cf1817d 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue @@ -85,6 +85,10 @@ export default { type: Boolean, default: false, }, + teamId: { + type: [String, Number], + default: 0, + }, }, computed: { @@ -171,6 +175,7 @@ export default { activeInbox, id: chat.id, label: this.activeLabel, + teamId: this.teamId, }); router.push({ path: frontendURL(path) }); }, diff --git a/app/javascript/dashboard/helper/URLHelper.js b/app/javascript/dashboard/helper/URLHelper.js index 97744e43b..e9124e097 100644 --- a/app/javascript/dashboard/helper/URLHelper.js +++ b/app/javascript/dashboard/helper/URLHelper.js @@ -5,13 +5,22 @@ export const frontendURL = (path, params) => { return `/app/${path}${stringifiedParams}`; }; -export const conversationUrl = ({ accountId, activeInbox, id, label }) => { +export const conversationUrl = ({ + accountId, + activeInbox, + id, + label, + teamId, +}) => { if (activeInbox) { return `accounts/${accountId}/inbox/${activeInbox}/conversations/${id}`; } if (label) { return `accounts/${accountId}/label/${label}/conversations/${id}`; } + if (teamId) { + return `accounts/${accountId}/team/${teamId}/conversations/${id}`; + } return `accounts/${accountId}/conversations/${id}`; }; diff --git a/app/javascript/dashboard/helper/specs/URLHelper.spec.js b/app/javascript/dashboard/helper/specs/URLHelper.spec.js index 354cffcd6..8b4a5266d 100644 --- a/app/javascript/dashboard/helper/specs/URLHelper.spec.js +++ b/app/javascript/dashboard/helper/specs/URLHelper.spec.js @@ -21,6 +21,11 @@ describe('#URL Helpers', () => { conversationUrl({ accountId: 1, label: 'customer-support', id: 1 }) ).toBe('accounts/1/label/customer-support/conversations/1'); }); + it('should return correct conversation URL if team Id is available', () => { + expect(conversationUrl({ accountId: 1, teamId: 1, id: 1 })).toBe( + 'accounts/1/team/1/conversations/1' + ); + }); }); describe('frontendURL', () => { diff --git a/app/javascript/dashboard/routes/dashboard/conversation/ConversationView.vue b/app/javascript/dashboard/routes/dashboard/conversation/ConversationView.vue index 0e1bfd464..f66ef9587 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/ConversationView.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/ConversationView.vue @@ -3,7 +3,7 @@ @@ -68,12 +68,6 @@ export default { } return false; }, - activeTeam() { - if (this.teamId) { - return this.$store.getters['teams/getTeam'](this.teamId); - } - return {}; - }, }, mounted() {