import { DeleteFilled, PlusCircleFilled } from "@ant-design/icons"; import { Button, Col, Popover, Row, Select, Space, Spin } from "antd"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors"; import DataLabel from "../data-label/data-label.component"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, jobRO: selectJobReadOnly }); const mapDispatchToProps = () => ({}); const iconStyle = { marginLeft: ".3rem" }; export function JobEmployeeAssignments({ bodyshop, jobRO, body, refinish, prep, csr, handleAdd, handleRemove, loading }) { const { t } = useTranslation(); // Which assignment popover is currently open: "body" | "prep" | "refinish" | "csr" | null const [openOperation, setOpenOperation] = useState(null); // Current selection inside the popover const [selected, setSelected] = useState({ employeeid: null, name: null }); const employeeOptions = (bodyshop?.employees || []) .filter((emp) => emp.active) .map((emp) => ({ value: emp.id, label: `${emp.first_name} ${emp.last_name}` })); const getPopupContainer = () => document.querySelector("#time-ticket-modal") || document.body; const openFor = (operation) => { if (jobRO) return; setSelected({ employeeid: null, name: null }); setOpenOperation(operation); }; const close = () => { setOpenOperation(null); setSelected({ employeeid: null, name: null }); }; const renderAssigner = (operation) => { if (jobRO) { return ; } const popContent = (