import { ProFormItemProps, ProFormText } from '@ant-design/pro-components';
import { IAddressProps, TMapModal } from '@chageable/components';
import { Button } from 'antd';
import useFormInstance from 'antd/es/form/hooks/useFormInstance';
import React from 'react';
import '../index.less';

interface ProFormUploadMaterialProps extends ProFormItemProps {
  fieldProps?: any;
}

const ProFormTMap: React.FC<ProFormUploadMaterialProps> = ({ ...rest }) => {
  const formInstance = useFormInstance();
  console.log('form', formInstance.getFieldsValue());

  return (
    <ProFormText
      {...rest}
      addonAfter={
        <TMapModal
          trigger={<Button type={'primary'}>选择地址</Button>}
          onFinish={(address?: IAddressProps) => {
            formInstance?.setFieldValue('address', address?.poiaddress);
            formInstance?.setFieldValue('latlng', address?.latlng);
          }}
        />
      }
    />
  );
};
export default ProFormTMap;
