@onereach/channel-transformer
Version:
Convert data model between different channels (Slack, Microsoft Teams, Generic...)
33 lines (27 loc) • 945 B
text/typescript
import { IGenericRange } from '../../../../generic/types';
import { IRWCAnswerComponent } from '../../../types';
import { RWCAnswerComponent } from '../../../classes/v5';
export const transformRange = ({ props }: IGenericRange): IRWCAnswerComponent => {
const type = 'rwc-slider';
const result: any = {
min: props.min,
max: props.max,
step: props.step,
unit: props.unit,
unitPosition: props.unitPosition,
mode: props.rwc?.mode,
useCustomLabels: props.rwc?.useCustomLabels
};
if (props.rwc?.mode === "single") {
result.defaultValue = props.rwc.defaultValue;
}
if (props.rwc?.mode === "range") {
result.defaultValueStart = props.rwc.defaultValueStart;
result.defaultValueEnd = props.rwc.defaultValueEnd;
}
if (props.rwc?.useCustomLabels) {
result.labelFunction = props.rwc.labelFunction,
result.options = props.rwc.options;
}
return new RWCAnswerComponent(result, type);
};