chore: Sets up store for teams settings page (#1727)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
committed by
GitHub
parent
c61edff189
commit
6a614a520b
15
app/javascript/dashboard/api/specs/teams.spec.js
Normal file
15
app/javascript/dashboard/api/specs/teams.spec.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import teams from '../teams';
|
||||
import ApiClient from '../ApiClient';
|
||||
|
||||
describe('#TeamsAPI', () => {
|
||||
it('creates correct instance', () => {
|
||||
expect(teams).toBeInstanceOf(ApiClient);
|
||||
expect(teams).toHaveProperty('get');
|
||||
expect(teams).toHaveProperty('show');
|
||||
expect(teams).toHaveProperty('create');
|
||||
expect(teams).toHaveProperty('update');
|
||||
expect(teams).toHaveProperty('delete');
|
||||
expect(teams).toHaveProperty('getAgents');
|
||||
expect(teams).toHaveProperty('addAgents');
|
||||
});
|
||||
});
|
||||
20
app/javascript/dashboard/api/teams.js
Normal file
20
app/javascript/dashboard/api/teams.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/* global axios */
|
||||
import ApiClient from './ApiClient';
|
||||
|
||||
export class TeamsAPI extends ApiClient {
|
||||
constructor() {
|
||||
super('teams', { accountScoped: true });
|
||||
}
|
||||
|
||||
getAgents({ teamId }) {
|
||||
return axios.get(`${this.url}/${teamId}/team_members`);
|
||||
}
|
||||
|
||||
addAgents({ teamId, agentsList }) {
|
||||
return axios.post(`${this.url}/${teamId}/team_members`, {
|
||||
user_ids: agentsList,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new TeamsAPI();
|
||||
Reference in New Issue
Block a user