refactor: Use getDynamicData instead of getData

This commit is contained in:
Faruk AYDIN
2022-11-10 19:46:04 +01:00
parent a415c7ef4e
commit d2b8d2beff
33 changed files with 57 additions and 42 deletions

View File

@@ -0,0 +1,3 @@
import listChannels from './list-channels';
export default [listChannels];

View File

@@ -0,0 +1,31 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
export default {
name: 'List channels',
key: 'listChannels',
async run($: IGlobalVariable) {
const channels: {
data: IJSONObject[];
error: IJSONObject | null;
} = {
data: [],
error: null,
};
const response = await $.http.get('/conversations.list');
if (response.data.ok === false) {
throw new Error(response.data);
}
channels.data = response.data.channels.map((channel: IJSONObject) => {
return {
value: channel.id,
name: channel.name,
};
});
return channels;
},
};