import Icon, { CarOutlined, ScheduleOutlined, SearchOutlined, UserAddOutlined } from "@ant-design/icons";
import { Layout, Menu } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { FaBusinessTime } from "react-icons/fa";
import { FiLogIn, FiLogOut } from "react-icons/fi";
import { MdTimer } from "react-icons/md";
import { connect } from "react-redux";
import { Link } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { techLogout } from "../../redux/tech/tech.actions";
import { selectTechnician } from "../../redux/tech/tech.selectors";
import { BsKanban } from "react-icons/bs";
import { useSplitTreatments } from "@splitsoftware/splitio-react";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
const { Sider } = Layout;
const mapStateToProps = createStructuredSelector({
technician: selectTechnician,
bodyshop: selectBodyshop
});
const mapDispatchToProps = (dispatch) => ({
techLogout: () => dispatch(techLogout()),
setTimeTicketTaskContext: (context) => dispatch(setModalContext({ context: context, modal: "timeTicketTask" }))
});
export function TechSider({ technician, techLogout, bodyshop, setTimeTicketTaskContext }) {
const [collapsed, setCollapsed] = useState(true);
const { t } = useTranslation();
const onCollapse = (collapsed) => {
setCollapsed(collapsed);
};
const {
treatments: { Enhanced_Payroll }
} = useSplitTreatments({
attributes: {},
names: ["Enhanced_Payroll"],
splitKey: bodyshop.imexshopid
});
const items = [
{
key: "1",
icon: ,
disabled: !!technician,
label: {t("menus.tech.login")}
},
{
key: "2",
icon: ,
disabled: !!!technician,
label: {t("menus.tech.joblookup")}
}
];
if (Enhanced_Payroll.treatment === "on") {
items.push(
{
key: "TechAssignedProdJobs",
disabled: !!!technician,
icon: ,
label: {t("menus.tech.assignedjobs")}
},
{
key: "3",
disabled: !!!technician,
icon: ,
onClick: () => {
setTimeTicketTaskContext({
actions: {},
context: { jobid: null }
});
},
label: t("menus.tech.claimtask")
}
);
} else {
items.push({
key: "3",
disabled: !!!technician,
icon: ,
label: {t("menus.tech.jobclockin")}
});
}
items.push(
{
key: "4",
icon: ,
disabled: !!!technician,
label: {t("menus.tech.shiftclockin")}
},
{
key: "dispatchedparts",
disabled: !!!technician,
icon: ,
label: {t("menus.tech.dispatchedparts")}
},
{
key: "5",
icon: ,
disabled: !!!technician,
label: {t("menus.tech.productionlist")}
},
{
key: "6",
icon: ,
disabled: !!!technician,
label: {t("menus.tech.productionboard")}
},
{
key: "7",
icon: ,
disabled: !!!technician,
label: t("menus.tech.logout")
}
);
return (
);
}
export default connect(mapStateToProps, mapDispatchToProps)(TechSider);