2021-05-17 16:08:59 +00:00
|
|
|
<template>
|
|
|
|
<div class="chat-bubble-wrap">
|
2022-04-01 15:29:03 +00:00
|
|
|
<button
|
|
|
|
class="chat-bubble agent"
|
|
|
|
:class="$dm('bg-white', 'dark:bg-slate-50')"
|
|
|
|
@click="onClickMessage"
|
|
|
|
>
|
2021-05-17 16:08:59 +00:00
|
|
|
<div v-if="showSender" class="row--agent-block">
|
|
|
|
<thumbnail
|
|
|
|
:src="avatarUrl"
|
|
|
|
size="20px"
|
|
|
|
:username="agentName"
|
2021-05-17 18:52:43 +00:00
|
|
|
:status="availabilityStatus"
|
2021-05-17 16:08:59 +00:00
|
|
|
/>
|
|
|
|
<span class="agent--name">{{ agentName }}</span>
|
|
|
|
<span class="company--name"> {{ companyName }}</span>
|
|
|
|
</div>
|
2022-04-21 05:57:28 +00:00
|
|
|
<div
|
|
|
|
v-dompurify-html="formatMessage(message, false)"
|
|
|
|
class="message-content"
|
|
|
|
></div>
|
2021-06-15 14:39:42 +00:00
|
|
|
</button>
|
2021-05-17 16:08:59 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
|
|
|
import Thumbnail from 'dashboard/components/widgets/Thumbnail';
|
|
|
|
import configMixin from '../mixins/configMixin';
|
|
|
|
import { isEmptyObject } from 'widget/helpers/utils';
|
2022-01-12 10:55:27 +00:00
|
|
|
import {
|
|
|
|
ON_CAMPAIGN_MESSAGE_CLICK,
|
|
|
|
ON_UNREAD_MESSAGE_CLICK,
|
|
|
|
} from '../constants/widgetBusEvents';
|
2022-04-01 15:29:03 +00:00
|
|
|
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
2021-05-17 16:08:59 +00:00
|
|
|
export default {
|
|
|
|
name: 'UnreadMessage',
|
|
|
|
components: { Thumbnail },
|
2022-04-01 15:29:03 +00:00
|
|
|
mixins: [messageFormatterMixin, configMixin, darkModeMixin],
|
2021-05-17 16:08:59 +00:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
showSender: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
sender: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2021-06-15 14:39:42 +00:00
|
|
|
campaignId: {
|
|
|
|
type: Number,
|
|
|
|
default: null,
|
|
|
|
},
|
2021-05-17 16:08:59 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
companyName() {
|
|
|
|
return `${this.$t('UNREAD_VIEW.COMPANY_FROM')} ${
|
|
|
|
this.channelConfig.websiteName
|
|
|
|
}`;
|
|
|
|
},
|
|
|
|
avatarUrl() {
|
|
|
|
// eslint-disable-next-line
|
|
|
|
const BotImage = require('dashboard/assets/images/chatwoot_bot.png');
|
|
|
|
const displayImage = this.useInboxAvatarForBot
|
|
|
|
? this.inboxAvatarUrl
|
|
|
|
: BotImage;
|
2021-05-17 18:52:43 +00:00
|
|
|
if (this.isSenderExist(this.sender)) {
|
|
|
|
const { avatar_url: avatarUrl } = this.sender;
|
|
|
|
return avatarUrl;
|
|
|
|
}
|
|
|
|
return displayImage;
|
2021-05-17 16:08:59 +00:00
|
|
|
},
|
|
|
|
agentName() {
|
2021-05-17 18:52:43 +00:00
|
|
|
if (this.isSenderExist(this.sender)) {
|
|
|
|
const { available_name: availableName, name } = this.sender;
|
2021-05-17 16:08:59 +00:00
|
|
|
return availableName || name;
|
|
|
|
}
|
|
|
|
return this.$t('UNREAD_VIEW.BOT');
|
|
|
|
},
|
2021-05-17 18:52:43 +00:00
|
|
|
availabilityStatus() {
|
|
|
|
if (this.isSenderExist(this.sender)) {
|
|
|
|
const { availability_status: availabilityStatus } = this.sender;
|
|
|
|
return availabilityStatus;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isSenderExist(sender) {
|
|
|
|
return sender && !isEmptyObject(sender);
|
|
|
|
},
|
2021-06-15 14:39:42 +00:00
|
|
|
onClickMessage() {
|
|
|
|
if (this.campaignId) {
|
2022-01-12 10:55:27 +00:00
|
|
|
bus.$emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId);
|
2021-10-08 08:38:13 +00:00
|
|
|
} else {
|
2022-01-12 10:55:27 +00:00
|
|
|
bus.$emit(ON_UNREAD_MESSAGE_CLICK);
|
2021-06-15 14:39:42 +00:00
|
|
|
}
|
|
|
|
},
|
2021-05-17 16:08:59 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2021-05-17 18:52:43 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-05-17 16:08:59 +00:00
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
.chat-bubble {
|
|
|
|
max-width: 85%;
|
|
|
|
padding: $space-normal;
|
2021-06-15 14:39:42 +00:00
|
|
|
cursor: pointer;
|
2021-05-17 16:08:59 +00:00
|
|
|
}
|
2021-06-15 14:39:42 +00:00
|
|
|
|
2021-05-17 16:08:59 +00:00
|
|
|
.row--agent-block {
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
text-align: left;
|
|
|
|
padding-bottom: $space-small;
|
|
|
|
font-size: $font-size-small;
|
|
|
|
.agent--name {
|
2021-05-17 18:52:43 +00:00
|
|
|
font-weight: $font-weight-medium;
|
2021-05-17 16:08:59 +00:00
|
|
|
margin-left: $space-smaller;
|
|
|
|
}
|
|
|
|
.company--name {
|
|
|
|
color: $color-light-gray;
|
|
|
|
margin-left: $space-smaller;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|