import React, { PureComponent } from 'react'; import { Label } from 'app/core/components/Label/Label'; import { Select } from 'app/core/components/Select/Select'; import { MappingType, RangeMap, ValueMap } from 'app/types'; interface Props { mapping: ValueMap | RangeMap; updateMapping: (mapping) => void; removeMapping: () => void; } interface State { from: string; id: number; operator: string; text: string; to: string; type: MappingType; value: string; } const mappingOptions = [ { value: MappingType.ValueToText, label: 'Value' }, { value: MappingType.RangeToText, label: 'Range' }, ]; export default class MappingRow extends PureComponent { constructor(props) { super(props); this.state = { ...props.mapping, }; } onMappingValueChange = event => { this.setState({ value: event.target.value }); }; onMappingFromChange = event => { this.setState({ from: event.target.value }); }; onMappingToChange = event => { this.setState({ to: event.target.value }); }; onMappingTextChange = event => { this.setState({ text: event.target.value }); }; onMappingTypeChange = mappingType => { this.setState({ type: mappingType }); }; updateMapping = () => { this.props.updateMapping({ ...this.state }); }; renderRow() { const { from, text, to, type, value } = this.state; if (type === MappingType.RangeToText) { return ( <>
); } return ( <>
); } render() { const { type } = this.state; return (