import React from 'react';
import Invoice from '../../..';
import 'antd/dist/antd.css';
import InvoiceController from '../../../InvoiceController';

export default () => {

    const invoiceController = React.useMemo(() => new MyInvoiceController(), []);

    return (
        <Invoice
            controller={invoiceController}
            invoiceType='digtal'
            invoiceHeader={
                <Invoice.InvoiceHeaderDigtal
                    defaultNo='2029292029201920291029'
                    defaultInvoicingDate='2023年7月6日'
                    defaultTag="成品油"
                />}
        />
    )
};

class MyInvoiceController extends InvoiceController {

    constructor() {
        super();
        this.state.autoComplete.onItemNameSearch = async text => {
            return [
                {
                    "itemName": "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵",
                    "taxClassificationCode": "1010112070000000000",
                    "itemModelName": null,
                    "shorthand": "蔬菜",
                    "taxRate": undefined
                },
                {
                    "itemName": "稻谷",
                    "taxClassificationCode": "1010101040000000000",
                    "itemModelName": null,
                    "shorthand": "谷物",
                    "taxRate": 3
                },
                {
                    "itemName": "苹果",
                    "taxClassificationCode": "1090111090000000000",
                    "itemModelName": null,
                    "shorthand": "小型起重设备",
                    "taxRate": null
                },
                {
                    "itemName": "银丝",
                    "taxClassificationCode": "1080411120000000000",
                    "itemModelName": null,
                    "shorthand": "金属制品",
                    "taxRate": 3
                },
                {
                    "itemName": "布料",
                    "taxClassificationCode": "1100101011100000000",
                    "itemModelName": null,
                    "shorthand": "发电",
                    "taxRate": 2
                },
                {
                    "itemName": "苹果",
                    "taxClassificationCode": "1010115010100000000",
                    "itemModelName": null,
                    "shorthand": "水果",
                    "taxRate": 3
                }
            ] as any
        }

        this.state.autoComplete.onBuyerTaxIdSearch = this.state.autoComplete.onBuyerNameSearch = async test => {
            return [
                { buyerName: '测试1', buyerTaxId: 'xxxxx1', buyerPhone:'xxxx1' },
                { buyerName: '测试2', buyerTaxId: 'xxxxx2', buyerPhone:'xxxx2' },
                { buyerName: '测试4', buyerTaxId: 'xxxxx4', buyerPhone:'xxxx4' },
                { buyerName: '测试5', buyerTaxId: 'xxxxx5', buyerPhone:'xxxx5' },
                { buyerName: '测试6', buyerTaxId: 'xxxxx6', buyerPhone:'xxxx6' },
            ]
        }
    }
}