@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
33 lines (29 loc) • 766 B
text/typescript
import { IGenericContext, IGenericSection } from '../../../generic/types';
import { ISlackContext } from '../../types';
import { getMethods } from '../methods';
export const transformContext = (
{ elements, block_id }: ISlackContext
): IGenericContext|IGenericSection => {
// const res: IGenericContext = {
// type: 'context',
// children: elements.map(item => getMethods(item.type)(item)),
// props: {
// slack: {
// type: 'context'
// }
// }
// };
const res: IGenericSection = {
type: 'section',
children: elements.map(item => getMethods(item.type)(item)),
props: {
slack: {
type: 'context'
}
}
};
if (block_id) {
res.props.slack.block_id = block_id;
}
return res;
};