import { useTranslation } from "react-i18next";
import PrintCenterJobs from "../print-center-jobs/print-center-jobs.component";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
import PrintCenterJobsParts from "../print-center-jobs/print-center-jobs-parts.component";

const mapStateToProps = createStructuredSelector({
  isPartsEntry: selectIsPartsEntry
});

export function PrintCenterModalComponent({ context, isPartsEntry }) {
  const { t } = useTranslation();
  const { type } = context;

  let ModalContent;

  switch (type) {
    case "job":
      ModalContent = isPartsEntry ? PrintCenterJobsParts : PrintCenterJobs;
      break;
    default:
      break;
  }
  return <div>{ModalContent ? <ModalContent /> : t("printcenter.errors.nocontexttype")}</div>;
}

export default connect(mapStateToProps)(PrintCenterModalComponent);
