import React, { Component } from 'react';
import {Button, Modal, Select} from 'antd';
import SessionStyles from './Session.css';
import { BUTTON } from '../../../../gui-common/components/AntdTypes';
import {executeScript} from '../../actions/Session';

let selectScript = '';
export default class ExecuteSelector extends Component {
  render () {
    const { isSelectExecuteScript, t, endSelectExecuteScript, files, executeScript } = this.props;
    const options = [];
    for (let i = 0; i < files.length; i++) {
      const dic = {value: files[i], label: files[i]};
      options[i] = dic;
    }
    const footer = [<Button key="back" type={BUTTON.PRIMARY} onClick={ () => executeScript(selectScript)}>{t('Done')} </Button>];
    return <Modal key="modal"
                  className={SessionStyles.cloudProviderModal}
                  visible={isSelectExecuteScript}
                  onCancel={ endSelectExecuteScript }
                  footer={footer}
                  title={t('Select Execute Script')}>
<Select
  showSearch
  optionFilterProp="children"
  placeholder="Select a script"
  onChange={(value) => {
    selectScript = value;
  } }
  onSearch={() => {
  }
  }
  style={{
    width: '100%',
  }}
  filterOption={(input, option) => option.label.toLowerCase().includes(input.toLowerCase())}
  options={options}
/>
    </Modal>;
  }

}

/*
*
* import React from 'react';
import { Select } from 'antd';

const onChange = (value: string) => {
  console.log(`selected ${value}`);
};

const onSearch = (value: string) => {
  console.log('search:', value);
};

const App: React.FC = () => (
  <Select
    showSearch
    placeholder="Select a person"
    optionFilterProp="children"
    onChange={onChange}
    onSearch={onSearch}
    filterOption={(input, option) =>
      (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
    }
    options={[
      {
        value: 'jack',
        label: 'Jack',
      },
      {
        value: 'lucy',
        label: 'Lucy',
      },
      {
        value: 'tom',
        label: 'Tom',
      },
    ]}
  />
);

export default App;
* */