feat: Add inbox view page (#8814)

* feat: Add inbox view page

* Update accounts.js

* Update index.js
This commit is contained in:
Muhsin Keloth
2024-01-30 13:55:20 +05:30
committed by GitHub
parent 0805f362d3
commit f2115b15f7
9 changed files with 91 additions and 2 deletions

View File

@@ -4,6 +4,9 @@ import AccountAPI from '../../api/account';
import EnterpriseAccountAPI from '../../api/enterprise/account';
import { throwErrorMessage } from '../utils/api';
const findRecordById = ($state, id) =>
$state.records.find(record => record.id === Number(id)) || {};
const state = {
records: [],
uiFlags: {
@@ -30,10 +33,15 @@ export const getters = {
return true;
}
const { features = {} } =
$state.records.find(record => record.id === Number(id)) || {};
const { features = {} } = findRecordById($state, id);
return features[featureName] || false;
},
// There are some features which can be enabled/disabled globally
isFeatureEnabledGlobally: $state => (id, featureName) => {
const { features = {} } = findRecordById($state, id);
return features[featureName] || false;
},
};
export const actions = {

View File

@@ -4,6 +4,10 @@ const accountData = {
id: 1,
name: 'Company one',
locale: 'en',
features: {
auto_resolve_conversations: false,
agent_management: false,
},
};
describe('#getters', () => {
@@ -29,4 +33,32 @@ describe('#getters', () => {
isDeleting: false,
});
});
it('isFeatureEnabledonAccount', () => {
const state = {
records: [accountData],
};
const rootGetters = {
getCurrentUser: {
type: 'SuperAdmin',
},
};
expect(
getters.isFeatureEnabledonAccount(
state,
null,
null,
rootGetters
)(1, 'auto_resolve_conversations')
).toEqual(true);
});
it('isFeatureEnabledGlobally', () => {
const state = {
records: [accountData],
};
expect(
getters.isFeatureEnabledGlobally(state)(1, 'auto_resolve_conversations')
).toEqual(false);
});
});