feat: add util for checking feature enabled
This commit is contained in:
@@ -13,6 +13,11 @@ export function useAccount() {
|
||||
*/
|
||||
const route = useRoute();
|
||||
const getAccountFn = useMapGetter('accounts/getAccount');
|
||||
const isOnChatwootCloud = useMapGetter('globalConfig/isOnChatwootCloud');
|
||||
const isFeatureEnabledonAccount = useMapGetter(
|
||||
'accounts/isFeatureEnabledonAccount'
|
||||
);
|
||||
|
||||
const accountId = computed(() => {
|
||||
return Number(route.params.accountId);
|
||||
});
|
||||
@@ -28,6 +33,13 @@ export function useAccount() {
|
||||
return `/app/accounts/${accountId.value}/${url}`;
|
||||
};
|
||||
|
||||
const isCloudFeatureEnabled = feature => {
|
||||
// always return true if not on cloud
|
||||
if (!isOnChatwootCloud.value) return true;
|
||||
|
||||
return isFeatureEnabledonAccount.value(currentAccount.value.id, feature);
|
||||
};
|
||||
|
||||
const accountScopedRoute = (name, params, query) => {
|
||||
return {
|
||||
name,
|
||||
@@ -42,5 +54,6 @@ export function useAccount() {
|
||||
currentAccount,
|
||||
accountScopedUrl,
|
||||
accountScopedRoute,
|
||||
isCloudFeatureEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user