chore: integrate the composable replacing the mixing in pages and components
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
import { computed } from 'vue';
|
||||
import { utcToZonedTime } from 'date-fns-tz';
|
||||
import { isTimeAfter } from 'shared/helpers/DateHelper';
|
||||
import { useI18n } from 'dashboard/composables/useI18n';
|
||||
|
||||
/**
|
||||
* Composable for handling availability-related computations.
|
||||
* @param {Object} i18n - Vue i18n instance for translations.
|
||||
* @param {Object} $t - Vue i18n instance for translations.
|
||||
* @returns {Object} An object containing computed properties and methods for availability management.
|
||||
*/
|
||||
export function useAvailability(availableAgents, i18n) {
|
||||
export function useAvailability(availableAgents) {
|
||||
const { t: $t } = useI18n();
|
||||
const channelConfig = computed(() => window.chatwootWebChannel);
|
||||
const replyTime = computed(() => window.chatwootWebChannel.replyTime);
|
||||
|
||||
const replyTimeStatus = computed(() => {
|
||||
switch (replyTime.value) {
|
||||
case 'in_a_few_minutes':
|
||||
return i18n.t('REPLY_TIME.IN_A_FEW_MINUTES');
|
||||
return $t('REPLY_TIME.IN_A_FEW_MINUTES');
|
||||
case 'in_a_few_hours':
|
||||
return i18n.t('REPLY_TIME.IN_A_FEW_HOURS');
|
||||
return $t('REPLY_TIME.IN_A_FEW_HOURS');
|
||||
case 'in_a_day':
|
||||
return i18n.t('REPLY_TIME.IN_A_DAY');
|
||||
return $t('REPLY_TIME.IN_A_DAY');
|
||||
default:
|
||||
return i18n.t('REPLY_TIME.IN_A_FEW_HOURS');
|
||||
return $t('REPLY_TIME.IN_A_FEW_HOURS');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,11 +31,11 @@ export function useAvailability(availableAgents, i18n) {
|
||||
if (workingHoursEnabled) {
|
||||
return isOnline.value
|
||||
? replyTimeStatus.value
|
||||
: `${i18n.t('REPLY_TIME.BACK_IN')} ${timeLeftToBackInOnline.value}`;
|
||||
: `${$t('REPLY_TIME.BACK_IN')} ${timeLeftToBackInOnline.value}`;
|
||||
}
|
||||
return isOnline.value
|
||||
? replyTimeStatus.value
|
||||
: i18n.t('TEAM_AVAILABILITY.OFFLINE');
|
||||
: $t('TEAM_AVAILABILITY.OFFLINE');
|
||||
});
|
||||
|
||||
const outOfOfficeMessage = computed(
|
||||
|
||||
Reference in New Issue
Block a user