import { Button } from "antd";
import axios from "axios";
import React, { useState } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { useTranslation } from "react-i18next";
const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
  bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(mapStateToProps, mapDispatchToProps)(DmsCdkMakesRefetch);

export function DmsCdkMakesRefetch({ bodyshop, form, socket }) {
  const [loading, setLoading] = useState(false);
  const { t } = useTranslation();
  const handleRefetch = async () => {
    setLoading(true);
    const response = await axios.post("/cdk/getvehicles", {
      cdk_dealerid: bodyshop.cdk_dealerid,
      bodyshopid: bodyshop.id,
    });
    console.log(response);
    setLoading(false);
  };
  return (
    <Button loading={loading} onClick={handleRefetch}>
      {t("jobs.actions.dms.refetchmakesmodels")}
    </Button>
  );
}
