import React, { useState, useEffect, useCallback } from 'react'
import { Table, InputNumber, Input, Form } from 'antd'
import { useActions, useData, useCommit } from '@ttk/app-loader'

const EditableContext = React.createContext();

export default function Com(props) {
  const getInput = () => {
    console.log(123456, props)
    if (props.inputType === 'number') {
      return <InputNumber value={props.record[props.dataIndex]}/>;
    }
    return <Input value={props.record[props.dataIndex]}/>;
  };

  const renderCell = () => {
    const {
      editing,
      dataIndex,
      title,
      inputType,
      record,
      index,
      children,
      ...restProps
    } = props;
    return (
      <td {...restProps}>
        {editing ? (
          <Form.Item style={{ margin: 0 }}>
            {(getInput())}
          </Form.Item>
        ) : (
          children
        )}
      </td>
    );
  };

  return <EditableContext.Consumer>{renderCell}</EditableContext.Consumer>;
}