import { Input, Space, Spin } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import EmployeeSearchSelectComponent from "../employee-search-select/employee-search-select.component";
const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
  bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(ProductionBoardFilters);

export function ProductionBoardFilters({
  bodyshop,
  filter,
  setFilter,
  loading,
}) {
  const { t } = useTranslation();

  return (

        <Space wrap>
          {loading && <Spin />}
          <Input.Search
            //value={filter.search}
            placeholder={t("general.labels.search")}
            onChange={(e) => {
              setFilter({ ...filter, search: e.target.value });
            }}
          />
          <EmployeeSearchSelectComponent
            style={{ minWidth: "20rem" }}
            options={bodyshop.employees.filter((e) => e.active)}
            value={filter.employeeId}
            placeholder={t("production.labels.employeesearch")}
            onChange={(emp) => setFilter({ ...filter, employeeId: emp })}
            allowClear
          />
        </Space>

  );
}
