2019-10-29 07:20:54 +00:00
|
|
|
<template>
|
2021-09-29 08:58:32 +00:00
|
|
|
<div class="home" @keydown.esc="closeChat">
|
2021-10-01 09:33:58 +00:00
|
|
|
<div class="flex flex-col flex-1 overflow-auto">
|
|
|
|
<div class="header-wrap bg-white expanded">
|
|
|
|
<chat-header-expanded
|
|
|
|
:intro-heading="channelConfig.welcomeTitle"
|
|
|
|
:intro-body="channelConfig.welcomeTagline"
|
|
|
|
:avatar-url="channelConfig.avatarUrl"
|
|
|
|
:show-popout-button="showPopoutButton"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<banner />
|
|
|
|
|
2021-09-29 08:58:32 +00:00
|
|
|
<team-availability
|
|
|
|
:available-agents="availableAgents"
|
|
|
|
@start-conversation="startConversation"
|
|
|
|
/>
|
2021-10-01 09:33:58 +00:00
|
|
|
|
|
|
|
<div class="px-6 mt-8">
|
|
|
|
<h3 class="text-xl font-medium text-gray-900">
|
|
|
|
Last conversation
|
|
|
|
</h3>
|
|
|
|
<conversation-item :conversation="lastActiveConversation" />
|
|
|
|
<chat-footer :conversation-id="lastActiveConversationId" />
|
|
|
|
<button
|
|
|
|
class="mt-2 font-medium text-woot-600 hover:text-woot-500 transition
|
|
|
|
ease-in-out duration-150"
|
|
|
|
@click="clickAllConversations"
|
|
|
|
>
|
|
|
|
See all conversations
|
|
|
|
<span aria-hidden="true">→</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="px-6 mt-8">
|
|
|
|
<h3 class="text-xl font-medium text-gray-900">
|
|
|
|
FAQ
|
|
|
|
</h3>
|
|
|
|
<div>
|
|
|
|
<h4></h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button
|
|
|
|
class="font-medium text-woot-600 hover:text-woot-500 transition
|
|
|
|
ease-in-out duration-150"
|
|
|
|
@click="clickAllConversations"
|
|
|
|
>
|
|
|
|
See all conversations
|
|
|
|
<span aria-hidden="true">→</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="footer-wrap">
|
|
|
|
<branding></branding>
|
|
|
|
</div>
|
2019-10-29 07:20:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-08-03 12:52:50 +00:00
|
|
|
import Branding from 'shared/components/Branding.vue';
|
2021-10-01 09:33:58 +00:00
|
|
|
import ChatFooter from 'widget/components/ChatFooter.vue';
|
2019-10-29 07:20:54 +00:00
|
|
|
import ChatHeaderExpanded from 'widget/components/ChatHeaderExpanded.vue';
|
2021-10-01 09:33:58 +00:00
|
|
|
import ConversationItem from 'widget/components/ConversationItem';
|
2021-09-29 08:58:32 +00:00
|
|
|
|
2021-09-02 06:43:53 +00:00
|
|
|
import { IFrameHelper } from 'widget/helpers/utils';
|
2020-05-09 16:32:43 +00:00
|
|
|
import configMixin from '../mixins/configMixin';
|
2020-10-18 18:02:22 +00:00
|
|
|
import TeamAvailability from 'widget/components/TeamAvailability';
|
|
|
|
import Spinner from 'shared/components/Spinner.vue';
|
2021-07-13 06:01:21 +00:00
|
|
|
import Banner from 'widget/components/Banner.vue';
|
2020-10-18 18:02:22 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-04-15 16:58:19 +00:00
|
|
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
2021-09-23 06:50:53 +00:00
|
|
|
|
2019-10-29 07:20:54 +00:00
|
|
|
export default {
|
|
|
|
name: 'Home',
|
|
|
|
components: {
|
2020-10-18 18:02:22 +00:00
|
|
|
Branding,
|
2021-10-01 09:33:58 +00:00
|
|
|
ChatFooter,
|
2019-10-29 07:20:54 +00:00
|
|
|
ChatHeaderExpanded,
|
2020-10-18 18:02:22 +00:00
|
|
|
Spinner,
|
|
|
|
TeamAvailability,
|
2021-10-01 09:33:58 +00:00
|
|
|
ConversationItem,
|
2021-07-13 06:01:21 +00:00
|
|
|
Banner,
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
2020-05-09 16:32:43 +00:00
|
|
|
mixins: [configMixin],
|
2020-07-07 18:34:44 +00:00
|
|
|
props: {
|
2021-09-29 08:58:32 +00:00
|
|
|
conversationId: {
|
2020-07-07 18:34:44 +00:00
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-08-28 12:09:46 +00:00
|
|
|
showPopoutButton: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
2020-10-18 18:02:22 +00:00
|
|
|
data() {
|
2021-06-30 15:39:44 +00:00
|
|
|
return {
|
|
|
|
isOnCollapsedView: false,
|
|
|
|
isOnNewConversation: false,
|
|
|
|
};
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
2019-10-29 07:20:54 +00:00
|
|
|
computed: {
|
2020-10-18 18:02:22 +00:00
|
|
|
...mapGetters({
|
2021-02-15 18:44:13 +00:00
|
|
|
availableAgents: 'agent/availableAgents',
|
|
|
|
conversationAttributes: 'conversationAttributes/getConversationParams',
|
2021-09-29 08:58:32 +00:00
|
|
|
getTotalMessageCount: 'conversationV2/allMessagesCountIn',
|
|
|
|
getGroupedMessages: 'conversationV2/groupByMessagesIn',
|
|
|
|
getIsFetchingList: 'conversationV2/isFetchingConversationsList',
|
2021-10-01 09:33:58 +00:00
|
|
|
lastActiveConversationId: 'conversationV2/lastActiveConversationId',
|
|
|
|
getConversationById: 'conversationV2/getConversationById',
|
2021-09-29 08:58:32 +00:00
|
|
|
getCurrentUser: 'contactV2/getCurrentUser',
|
2020-10-18 18:02:22 +00:00
|
|
|
}),
|
2021-09-29 08:58:32 +00:00
|
|
|
conversationSize() {
|
|
|
|
return this.getTotalMessageCount(this.conversationId);
|
2020-05-09 16:32:43 +00:00
|
|
|
},
|
2021-09-29 08:58:32 +00:00
|
|
|
groupedMessages() {
|
|
|
|
return this.getGroupedMessages(this.conversationId);
|
2021-04-15 16:58:19 +00:00
|
|
|
},
|
2021-09-29 08:58:32 +00:00
|
|
|
isFetchingList() {
|
|
|
|
return this.getIsFetchingList(this.conversationId);
|
2020-05-09 16:32:43 +00:00
|
|
|
},
|
2021-09-29 08:58:32 +00:00
|
|
|
currentUser() {
|
|
|
|
return this.getCurrentUser(this.conversationId);
|
2020-04-20 06:25:06 +00:00
|
|
|
},
|
2021-10-01 09:33:58 +00:00
|
|
|
lastActiveConversation() {
|
|
|
|
const conversationId = this.lastActiveConversationId;
|
|
|
|
return this.getConversationById(conversationId);
|
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
},
|
2021-04-15 16:58:19 +00:00
|
|
|
mounted() {
|
2021-06-30 15:39:44 +00:00
|
|
|
bus.$on(BUS_EVENTS.START_NEW_CONVERSATION, () => {
|
|
|
|
this.isOnCollapsedView = true;
|
|
|
|
this.isOnNewConversation = true;
|
|
|
|
});
|
2021-04-15 16:58:19 +00:00
|
|
|
},
|
2020-10-18 18:02:22 +00:00
|
|
|
methods: {
|
2021-10-01 09:33:58 +00:00
|
|
|
async startConversation() {
|
2021-02-15 18:44:13 +00:00
|
|
|
this.isOnCollapsedView = !this.isOnCollapsedView;
|
2021-10-01 09:33:58 +00:00
|
|
|
const conversationId = await this.$store.dispatch(
|
|
|
|
'conversationV2/createConversation',
|
|
|
|
{
|
|
|
|
inboxIdentifier: window.chatwootWebChannel.inboxIdentifier,
|
|
|
|
contactIdentifier: window.contactIdentifier,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.$router.push({
|
|
|
|
name: 'chat',
|
|
|
|
params: {
|
|
|
|
conversationId: conversationId,
|
|
|
|
},
|
2021-09-29 08:58:32 +00:00
|
|
|
});
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
2021-09-02 06:43:53 +00:00
|
|
|
closeChat() {
|
|
|
|
IFrameHelper.sendMessage({ event: 'closeChat' });
|
|
|
|
},
|
2021-09-29 08:58:32 +00:00
|
|
|
clickAllConversations() {
|
|
|
|
this.$router.push({
|
|
|
|
name: 'conversations',
|
|
|
|
});
|
|
|
|
},
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
2019-10-29 07:20:54 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2020-10-18 18:02:22 +00:00
|
|
|
@import '~widget/assets/scss/variables';
|
2021-02-15 18:44:13 +00:00
|
|
|
@import '~widget/assets/scss/mixins';
|
2019-10-29 07:20:54 +00:00
|
|
|
|
|
|
|
.home {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-wrap: nowrap;
|
2020-10-18 18:02:22 +00:00
|
|
|
overflow: hidden;
|
2019-10-29 07:20:54 +00:00
|
|
|
|
|
|
|
.header-wrap {
|
2021-02-15 18:44:13 +00:00
|
|
|
border-radius: $space-normal $space-normal 0 0;
|
2019-10-29 07:20:54 +00:00
|
|
|
flex-shrink: 0;
|
2021-02-15 18:44:13 +00:00
|
|
|
transition: max-height 300ms;
|
2020-03-07 18:09:41 +00:00
|
|
|
z-index: 99;
|
2021-02-15 18:44:13 +00:00
|
|
|
|
|
|
|
&.expanded {
|
|
|
|
max-height: 16rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.collapsed {
|
|
|
|
max-height: 4.5rem;
|
|
|
|
}
|
2020-02-05 05:57:22 +00:00
|
|
|
|
2020-03-07 18:09:41 +00:00
|
|
|
@media only screen and (min-device-width: 320px) and (max-device-width: 667px) {
|
2020-02-05 05:57:22 +00:00
|
|
|
border-radius: 0;
|
|
|
|
}
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.footer-wrap {
|
|
|
|
flex-shrink: 0;
|
2020-01-13 06:40:40 +00:00
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-01-17 08:06:05 +00:00
|
|
|
position: relative;
|
2020-01-13 06:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.input-wrap {
|
2021-09-02 06:43:53 +00:00
|
|
|
padding: 0 $space-two;
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|