import React from 'react'; import 'codemirror/theme/duotone-light.css'; import SelectSearch, { fuzzySearch } from 'react-select-search'; import { CodeHinter } from '../../CodeBuilder/CodeHinter'; import { changeOption } from './utils'; class Airtable extends React.Component { constructor(props) { super(props); this.state = { options: this.props.options, }; } componentDidMount() { this.setState({ options: this.props.options, }); } changeOperation = (operation) => { this.setState( { options: { ...this.state.options, operation, }, }, () => { this.props.optionsChanged(this.state.options); } ); }; render() { const { options } = this.state; return (
{options && (
{ this.changeOperation(value); }} filterOptions={fuzzySearch} placeholder="Select.." />
{['list_records'].includes(this.state.options.operation) && (
changeOption(this, 'base_id', value)} />
changeOption(this, 'table_name', value)} />
changeOption(this, 'page_size', value)} />
changeOption(this, 'offset', value)} />
)} {['retrieve_record'].includes(this.state.options.operation) && (
changeOption(this, 'base_id', value)} />
changeOption(this, 'table_name', value)} />
changeOption(this, 'record_id', value)} />
)} {['update_record'].includes(this.state.options.operation) && (
changeOption(this, 'base_id', value)} />
changeOption(this, 'table_name', value)} />
changeOption(this, 'record_id', value)} />
changeOption(this, 'body', value)} />
)} {['delete_record'].includes(this.state.options.operation) && (
changeOption(this, 'base_id', value)} />
changeOption(this, 'table_name', value)} />
changeOption(this, 'record_id', value)} />
)}
)}
); } } export { Airtable };