import React, { useState, useEffect,useRef } from 'react';
import { Input ,Form} from 'antd';

import { getNumber } from '../../utils/string';


const MoneyInput = (props:any) => {

  // const [onChange] = props
  
  const formRef = useRef(null);

  const keyup = (e: any) => {
    var value=e.target.value
    value = value.replace(/[^\d^\.]+/g, '')  
    var last=getNumber(value)
    e.target.value=last    
    formRef.current.setFieldsValue({ input: last })
    // onChange(last)
  }
  return (
    <>
     
      <Form ref={formRef}  name="basic2">
      <Form.Item name="input">
          <Input prefix="$" placeholder="00.00" onKeyUp={keyup} allowClear />
      </Form.Item>
      </Form>
      
    </>
  );
};

export default MoneyInput;
