/** @format */

import * as React from 'react';
import Select, {SelectProps} from './select';
import {useDataApiList} from '../../service/dataApi';
interface Iprops extends SelectProps {
    merchant_id?: number | '';
}
export default React.forwardRef((props: Iprops, ref) => {
    const {merchant_id = '', ...rest} = props;
    const [lisState, requestList] = useDataApiList();
    React.useEffect(() => {
        if (merchant_id !== undefined) {
            requestList({merchant_id: merchant_id, is_all: true});
        }
    }, [merchant_id]);
    return (
        <Select
            ref={ref}
            showSearch
            loading={lisState.loading}
            options={lisState.dataSource.sort((pre, next) => {
                return pre.label.localeCompare(next.label);
            })}
            allowClear
            placeholder='请选择数据API'
            {...rest}
        />
    );
});
