2020-10-18 18:02:22 +00:00
|
|
|
<template>
|
|
|
|
<div class="px-4">
|
2021-03-13 08:36:25 +00:00
|
|
|
<div class="flex items-center justify-between mb-4">
|
2020-10-18 18:02:22 +00:00
|
|
|
<div class="text-black-700">
|
|
|
|
<div class="text-base leading-5 font-medium mb-1">
|
2021-03-13 06:14:28 +00:00
|
|
|
{{
|
2021-03-13 08:36:25 +00:00
|
|
|
isOnline
|
2021-03-13 06:14:28 +00:00
|
|
|
? $t('TEAM_AVAILABILITY.ONLINE')
|
|
|
|
: $t('TEAM_AVAILABILITY.OFFLINE')
|
|
|
|
}}
|
2020-10-18 18:02:22 +00:00
|
|
|
</div>
|
|
|
|
<div class="text-xs leading-4 mt-1">
|
2021-03-13 08:36:25 +00:00
|
|
|
{{ replyWaitMeessage }}
|
2020-10-18 18:02:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-13 08:36:25 +00:00
|
|
|
<available-agents v-if="isOnline" :agents="availableAgents" />
|
2020-10-18 18:02:22 +00:00
|
|
|
</div>
|
2021-04-07 06:13:16 +00:00
|
|
|
<custom-button
|
2020-10-18 18:02:22 +00:00
|
|
|
class="font-medium"
|
|
|
|
block
|
|
|
|
:bg-color="widgetColor"
|
|
|
|
:text-color="textColor"
|
|
|
|
@click="startConversation"
|
|
|
|
>
|
|
|
|
{{ $t('START_CONVERSATION') }}
|
2021-04-07 06:13:16 +00:00
|
|
|
</custom-button>
|
2020-10-18 18:02:22 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import AvailableAgents from 'widget/components/AvailableAgents.vue';
|
|
|
|
import { getContrastingTextColor } from 'shared/helpers/ColorHelper';
|
2021-04-07 06:13:16 +00:00
|
|
|
import CustomButton from 'shared/components/Button';
|
2020-10-18 18:02:22 +00:00
|
|
|
import configMixin from 'widget/mixins/configMixin';
|
2021-03-13 08:36:25 +00:00
|
|
|
import availabilityMixin from 'widget/mixins/availability';
|
2020-10-18 18:02:22 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'TeamAvailability',
|
|
|
|
components: {
|
|
|
|
AvailableAgents,
|
2021-04-07 06:13:16 +00:00
|
|
|
CustomButton,
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
2021-03-13 08:36:25 +00:00
|
|
|
mixins: [configMixin, availabilityMixin],
|
2020-10-18 18:02:22 +00:00
|
|
|
props: {
|
|
|
|
availableAgents: {
|
|
|
|
type: Array,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({ widgetColor: 'appConfig/getWidgetColor' }),
|
|
|
|
textColor() {
|
|
|
|
return getContrastingTextColor(this.widgetColor);
|
|
|
|
},
|
2021-03-13 08:36:25 +00:00
|
|
|
isOnline() {
|
|
|
|
const { workingHoursEnabled } = this.channelConfig;
|
|
|
|
const anyAgentOnline = this.availableAgents.length > 0;
|
2021-03-13 06:14:28 +00:00
|
|
|
|
2021-03-13 08:36:25 +00:00
|
|
|
if (workingHoursEnabled) {
|
|
|
|
return this.isInBetweenTheWorkingHours;
|
2021-03-13 06:14:28 +00:00
|
|
|
}
|
2021-03-13 08:36:25 +00:00
|
|
|
return anyAgentOnline;
|
|
|
|
},
|
|
|
|
replyWaitMeessage() {
|
|
|
|
const { workingHoursEnabled } = this.channelConfig;
|
2021-03-13 06:14:28 +00:00
|
|
|
|
2021-03-13 08:36:25 +00:00
|
|
|
if (this.isOnline) {
|
|
|
|
return this.replyTimeStatus;
|
2021-03-13 06:14:28 +00:00
|
|
|
}
|
2021-03-13 08:36:25 +00:00
|
|
|
if (workingHoursEnabled) {
|
|
|
|
return this.outOfOfficeMessage;
|
|
|
|
}
|
2021-03-27 07:38:09 +00:00
|
|
|
return '';
|
2021-03-13 06:14:28 +00:00
|
|
|
},
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
startConversation() {
|
|
|
|
this.$emit('start-conversation');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|