import React from 'react';
import style from './ordersSearcher.module.sass';
import {getOrdersByString, getAllOrders} from "../../../actions/actionCreator";
import {connect} from 'react-redux';

const OrdersSearcher = (props) => {

    const searchHandler = (e) => {
        props.getOrders(0, e.target.value)
    };


    return (
        <input type={'text'} onInput={searchHandler}/>
    )
};

const mapStateToProps = state => {
    const {data} = state.adminOrdersReducers;

    return {
        data
    }
};

const mapDispatchToProps = dispatch => ({
   getOrders: (offset ,searchString) => dispatch(getAllOrders(offset, searchString))
});

export default connect(mapStateToProps, mapDispatchToProps)(OrdersSearcher);