2020-10-18 18:02:22 +00:00
|
|
|
<template>
|
2022-01-12 10:55:27 +00:00
|
|
|
<div class="px-5">
|
2021-03-13 08:36:25 +00:00
|
|
|
<div class="flex items-center justify-between mb-4">
|
2022-04-01 15:29:03 +00:00
|
|
|
<div
|
|
|
|
class="max-w-xs"
|
|
|
|
:class="$dm('text-black-700', 'dark:text-slate-50')"
|
|
|
|
>
|
2020-10-18 18:02:22 +00:00
|
|
|
<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">
|
2022-10-14 03:43:11 +00:00
|
|
|
{{ replyWaitMessage }}
|
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"
|
|
|
|
>
|
2022-01-12 10:55:27 +00:00
|
|
|
{{
|
|
|
|
hasConversation ? $t('CONTINUE_CONVERSATION') : $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';
|
2021-05-24 07:13:03 +00:00
|
|
|
import { getContrastingTextColor } from '@chatwoot/utils';
|
2020-10-18 18:02:22 +00:00
|
|
|
import AvailableAgents from 'widget/components/AvailableAgents.vue';
|
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';
|
2022-04-01 15:29:03 +00:00
|
|
|
import darkMixin from 'widget/mixins/darkModeMixin.js';
|
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
|
|
|
},
|
2022-04-01 15:29:03 +00:00
|
|
|
mixins: [configMixin, availabilityMixin, darkMixin],
|
2020-10-18 18:02:22 +00:00
|
|
|
props: {
|
|
|
|
availableAgents: {
|
|
|
|
type: Array,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2022-01-12 10:55:27 +00:00
|
|
|
hasConversation: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-10-18 18:02:22 +00:00
|
|
|
},
|
2022-04-18 12:45:20 +00:00
|
|
|
|
2020-10-18 18:02:22 +00:00
|
|
|
computed: {
|
2022-04-01 15:29:03 +00:00
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
2020-10-18 18:02:22 +00:00
|
|
|
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;
|
|
|
|
},
|
2022-10-14 03:43:11 +00:00
|
|
|
replyWaitMessage() {
|
2021-03-13 08:36:25 +00:00
|
|
|
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>
|