2019-10-29 07:20:54 +00:00
|
|
|
<template>
|
2020-10-18 18:02:22 +00:00
|
|
|
<div
|
|
|
|
v-if="!conversationSize && isFetchingList"
|
|
|
|
class="flex flex-1 items-center h-full bg-black-25 justify-center"
|
|
|
|
>
|
2021-02-15 18:44:13 +00:00
|
|
|
<spinner size="" />
|
2020-10-18 18:02:22 +00:00
|
|
|
</div>
|
|
|
|
<div v-else class="home">
|
2021-02-15 18:44:13 +00:00
|
|
|
<div
|
|
|
|
class="header-wrap bg-white"
|
|
|
|
:class="{ expanded: !isHeaderCollapsed, collapsed: isHeaderCollapsed }"
|
|
|
|
>
|
2020-10-18 18:02:22 +00:00
|
|
|
<transition
|
|
|
|
enter-active-class="transition-all delay-200 duration-300 ease"
|
|
|
|
leave-active-class="transition-all duration-200 ease-in"
|
2021-02-15 18:44:13 +00:00
|
|
|
enter-class="opacity-0 transform"
|
|
|
|
enter-to-class="opacity-100 transform"
|
|
|
|
leave-class="opacity-100 transform"
|
|
|
|
leave-to-class="opacity-0 transform"
|
2020-10-18 18:02:22 +00:00
|
|
|
>
|
|
|
|
<chat-header-expanded
|
2021-02-15 18:44:13 +00:00
|
|
|
v-if="!isHeaderCollapsed"
|
|
|
|
:intro-heading="channelConfig.welcomeTitle"
|
|
|
|
:intro-body="channelConfig.welcomeTagline"
|
2020-10-18 18:02:22 +00:00
|
|
|
:avatar-url="channelConfig.avatarUrl"
|
|
|
|
:show-popout-button="showPopoutButton"
|
|
|
|
/>
|
|
|
|
<chat-header
|
2021-02-15 18:44:13 +00:00
|
|
|
v-if="isHeaderCollapsed"
|
2020-10-18 18:02:22 +00:00
|
|
|
:title="channelConfig.websiteName"
|
|
|
|
:avatar-url="channelConfig.avatarUrl"
|
|
|
|
:show-popout-button="showPopoutButton"
|
|
|
|
:available-agents="availableAgents"
|
|
|
|
/>
|
|
|
|
</transition>
|
2019-10-29 07:20:54 +00:00
|
|
|
</div>
|
2021-04-15 16:58:19 +00:00
|
|
|
<div v-if="showAttachmentError" class="banner">
|
|
|
|
<span>
|
|
|
|
{{
|
|
|
|
$t('FILE_SIZE_LIMIT', {
|
|
|
|
MAXIMUM_FILE_UPLOAD_SIZE: fileUploadSizeLimit,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</div>
|
2021-02-15 19:28:57 +00:00
|
|
|
<div class="flex flex-1 overflow-auto">
|
2021-02-15 18:44:13 +00:00
|
|
|
<conversation-wrap
|
|
|
|
v-if="currentView === 'messageView'"
|
|
|
|
:grouped-messages="groupedMessages"
|
|
|
|
/>
|
|
|
|
<pre-chat-form
|
|
|
|
v-if="currentView === 'preChatFormView'"
|
|
|
|
:options="preChatFormOptions"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-10-29 07:20:54 +00:00
|
|
|
<div class="footer-wrap">
|
2020-10-18 18:02:22 +00:00
|
|
|
<transition
|
|
|
|
enter-active-class="transition-all delay-300 duration-300 ease"
|
|
|
|
leave-active-class="transition-all duration-200 ease-in"
|
2021-02-15 18:44:13 +00:00
|
|
|
enter-class="opacity-0 transform"
|
2020-10-18 18:02:22 +00:00
|
|
|
enter-to-class="opacity-100 transform translate-y-0"
|
|
|
|
leave-class="opacity-100 transform translate-y-0"
|
2021-02-15 18:44:13 +00:00
|
|
|
leave-to-class="opacity-0 transform "
|
2020-10-18 18:02:22 +00:00
|
|
|
>
|
2021-06-01 17:04:25 +00:00
|
|
|
<div v-if="currentView === 'messageView'" class="input-wrap">
|
2020-10-18 18:02:22 +00:00
|
|
|
<chat-footer />
|
|
|
|
</div>
|
|
|
|
<team-availability
|
2021-02-15 18:44:13 +00:00
|
|
|
v-if="currentView === 'cardView'"
|
2020-10-18 18:02:22 +00:00
|
|
|
:available-agents="availableAgents"
|
|
|
|
@start-conversation="startConversation"
|
|
|
|
/>
|
|
|
|
</transition>
|
2020-01-13 06:40:40 +00:00
|
|
|
<branding></branding>
|
2019-10-29 07:20:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-01-13 06:40:40 +00:00
|
|
|
import Branding from 'widget/components/Branding.vue';
|
2019-10-29 07:20:54 +00:00
|
|
|
import ChatFooter from 'widget/components/ChatFooter.vue';
|
|
|
|
import ChatHeaderExpanded from 'widget/components/ChatHeaderExpanded.vue';
|
2019-11-26 17:05:26 +00:00
|
|
|
import ChatHeader from 'widget/components/ChatHeader.vue';
|
2019-10-29 07:20:54 +00:00
|
|
|
import ConversationWrap from 'widget/components/ConversationWrap.vue';
|
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';
|
|
|
|
import { mapGetters } from 'vuex';
|
2021-04-15 16:58:19 +00:00
|
|
|
import { MAXIMUM_FILE_UPLOAD_SIZE } from 'shared/constants/messages';
|
|
|
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
2021-02-15 18:44:13 +00:00
|
|
|
import PreChatForm from '../components/PreChat/Form';
|
2019-10-29 07:20:54 +00:00
|
|
|
export default {
|
|
|
|
name: 'Home',
|
|
|
|
components: {
|
2020-10-18 18:02:22 +00:00
|
|
|
Branding,
|
2019-10-29 07:20:54 +00:00
|
|
|
ChatFooter,
|
2020-10-18 18:02:22 +00:00
|
|
|
ChatHeader,
|
2019-10-29 07:20:54 +00:00
|
|
|
ChatHeaderExpanded,
|
|
|
|
ConversationWrap,
|
2021-02-15 18:44:13 +00:00
|
|
|
PreChatForm,
|
2020-10-18 18:02:22 +00:00
|
|
|
Spinner,
|
|
|
|
TeamAvailability,
|
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: {
|
|
|
|
hasFetched: {
|
|
|
|
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,
|
|
|
|
showAttachmentError: 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',
|
|
|
|
conversationSize: 'conversation/getConversationSize',
|
|
|
|
groupedMessages: 'conversation/getGroupedConversation',
|
2020-10-18 18:02:22 +00:00
|
|
|
isFetchingList: 'conversation/getIsFetchingList',
|
2021-03-20 12:14:20 +00:00
|
|
|
currentUser: 'contacts/getCurrentUser',
|
2020-10-18 18:02:22 +00:00
|
|
|
}),
|
2021-02-15 18:44:13 +00:00
|
|
|
currentView() {
|
2021-03-20 12:14:20 +00:00
|
|
|
const { email: currentUserEmail = '' } = this.currentUser;
|
2021-02-15 18:44:13 +00:00
|
|
|
if (this.isHeaderCollapsed) {
|
|
|
|
if (this.conversationSize) {
|
|
|
|
return 'messageView';
|
|
|
|
}
|
2021-06-30 15:39:44 +00:00
|
|
|
if (
|
|
|
|
this.isOnNewConversation ||
|
|
|
|
(this.preChatFormEnabled && !currentUserEmail)
|
|
|
|
) {
|
2021-02-15 18:44:13 +00:00
|
|
|
return 'preChatFormView';
|
|
|
|
}
|
|
|
|
return 'messageView';
|
|
|
|
}
|
|
|
|
return 'cardView';
|
|
|
|
},
|
2020-05-09 16:32:43 +00:00
|
|
|
isOpen() {
|
|
|
|
return this.conversationAttributes.status === 'open';
|
|
|
|
},
|
2021-04-15 16:58:19 +00:00
|
|
|
fileUploadSizeLimit() {
|
|
|
|
return MAXIMUM_FILE_UPLOAD_SIZE;
|
|
|
|
},
|
2021-02-15 18:44:13 +00:00
|
|
|
isHeaderCollapsed() {
|
|
|
|
if (!this.hasIntroText || this.conversationSize) {
|
2020-10-18 18:02:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-02-15 18:44:13 +00:00
|
|
|
|
|
|
|
return this.isOnCollapsedView;
|
2020-05-09 16:32:43 +00:00
|
|
|
},
|
2021-02-15 18:44:13 +00:00
|
|
|
hasIntroText() {
|
|
|
|
return (
|
|
|
|
this.channelConfig.welcomeTitle || this.channelConfig.welcomeTagline
|
|
|
|
);
|
2020-04-20 06:25:06 +00:00
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
},
|
2021-04-15 16:58:19 +00:00
|
|
|
mounted() {
|
|
|
|
bus.$on(BUS_EVENTS.ATTACHMENT_SIZE_CHECK_ERROR, () => {
|
|
|
|
this.showAttachmentError = true;
|
|
|
|
setTimeout(() => {
|
|
|
|
this.showAttachmentError = false;
|
|
|
|
}, 3000);
|
|
|
|
});
|
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: {
|
|
|
|
startConversation() {
|
2021-02-15 18:44:13 +00:00
|
|
|
this.isOnCollapsedView = !this.isOnCollapsedView;
|
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
|
|
|
background: $color-background;
|
|
|
|
|
|
|
|
.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
|
|
|
@include shadow-large;
|
|
|
|
|
|
|
|
&.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;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
|
|
|
top: -$space-normal;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: $space-normal;
|
2020-01-19 08:47:15 +00:00
|
|
|
opacity: 0.1;
|
2020-01-17 08:06:05 +00:00
|
|
|
background: linear-gradient(
|
|
|
|
to top,
|
|
|
|
$color-background,
|
|
|
|
rgba($color-background, 0)
|
|
|
|
);
|
|
|
|
}
|
2020-01-13 06:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.input-wrap {
|
2020-02-05 05:57:22 +00:00
|
|
|
padding: 0 $space-normal;
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
2021-04-15 16:58:19 +00:00
|
|
|
.banner {
|
|
|
|
background: $color-error;
|
|
|
|
color: $color-white;
|
|
|
|
font-size: $font-size-default;
|
|
|
|
font-weight: $font-weight-bold;
|
|
|
|
padding: $space-slab;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2019-10-29 07:20:54 +00:00
|
|
|
}
|
|
|
|
</style>
|