mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import { computed } from 'vue';
|
|
import { useRoute } from 'vue-router';
|
|
import { CAMPAIGN_TYPES } from '../constants/campaign';
|
|
|
|
/**
|
|
* Composable to manage campaign types.
|
|
*
|
|
* @returns {Object} - Computed properties for campaign type and its checks.
|
|
*/
|
|
export const useCampaign = () => {
|
|
const route = useRoute();
|
|
|
|
/**
|
|
* Computed property to determine the current campaign type based on the route name.
|
|
*/
|
|
const campaignType = computed(() => {
|
|
const campaignTypeMap = {
|
|
ongoing_campaigns: CAMPAIGN_TYPES.ONGOING,
|
|
one_off: CAMPAIGN_TYPES.ONE_OFF,
|
|
};
|
|
return campaignTypeMap[route.name];
|
|
});
|
|
|
|
/**
|
|
* Computed property to check if the current campaign type is 'ongoing'.
|
|
*/
|
|
const isOngoingType = computed(() => {
|
|
return campaignType.value === CAMPAIGN_TYPES.ONGOING;
|
|
});
|
|
|
|
/**
|
|
* Computed property to check if the current campaign type is 'one-off'.
|
|
*/
|
|
const isOneOffType = computed(() => {
|
|
return campaignType.value === CAMPAIGN_TYPES.ONE_OFF;
|
|
});
|
|
|
|
return {
|
|
campaignType,
|
|
isOngoingType,
|
|
isOneOffType,
|
|
};
|
|
};
|