@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
22 lines (15 loc) • 608 B
text/typescript
import { IGenericCreditCard } from "../../../../generic/types";
import { IRWCAnswerComponent } from '../../../types';
import { RWCAnswerComponent } from '../../../classes/v5';
export const transformCreditCard = ({props, children}: IGenericCreditCard): IRWCAnswerComponent => {
const initResult = {
...props.rwc
};
const result = children.reduce((acc, child) => {
const { type, props } = child;
if (!acc[type]) acc[type] = [];
acc[type].push(props?.rwc);
return acc;
}, initResult);
return new RWCAnswerComponent(result, 'rwc-credit');
};