APIPathCard.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, {Component} from 'react';
  2. import {Input, Radio, Collapse, Button} from 'antd';
  3. const Panel = Collapse.Panel;
  4. class APIPathCard extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. configs: ['apiGWName', 'apiGWDesc'],
  9. apiGWName: 'default schema name',
  10. apiGWDesc: '',
  11. requestMethod: ''
  12. };
  13. }
  14. switchConfig = (label) => {
  15. return (e) => {
  16. this.setState({
  17. [label]: e.target.value
  18. })
  19. };
  20. };
  21. render() {
  22. const customPanelStyle = {
  23. background: '#f7f7f7',
  24. borderRadius: 4,
  25. marginBottom: 24,
  26. border: 0,
  27. overflow: 'hidden',
  28. };
  29. return (
  30. <div>
  31. <Collapse bordered={false}>
  32. <Panel header="Want more options?" style={customPanelStyle}>
  33. {
  34. this.state.configs.map(config => (
  35. <div key={config} style={{marginBottom: 10}}>
  36. <span className='vice-title'>{config}: </span>
  37. <Input value={this.state[config]} style={{width: 200}}
  38. onChange={this.switchConfig(config)}/>
  39. </div>
  40. ))
  41. }
  42. <div style={{marginBottom: 10}}>
  43. <span className='vice-title'>requestMethod: </span>
  44. <Radio.Group onChange={this.switchConfig('requestMethod')} defaultValue="get"
  45. buttonStyle="solid">
  46. <Radio.Button value="get">get</Radio.Button>
  47. <Radio.Button value="post">post</Radio.Button>
  48. </Radio.Group>
  49. </div>
  50. </Panel>
  51. </Collapse>
  52. <Button type='primary'>ok</Button>
  53. </div>
  54. )
  55. }
  56. }
  57. export default APIPathCard;