import Icon, { BankFilled, BarChartOutlined, CarFilled, CheckCircleOutlined, ClockCircleFilled, DashboardFilled, DollarCircleFilled, ExportOutlined, FieldTimeOutlined, FileAddFilled, FileAddOutlined, FileFilled, HomeFilled, ImportOutlined, LineChartOutlined, PaperClipOutlined, PhoneOutlined, PlusCircleOutlined, QuestionCircleFilled, ScheduleOutlined, SettingOutlined, TeamOutlined, ToolFilled, UnorderedListOutlined, UserOutlined } from "@ant-design/icons"; import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Layout, Menu, Space } from "antd"; import { useTranslation } from "react-i18next"; import { BsKanban } from "react-icons/bs"; import { FaCalendarAlt, FaCarCrash, FaCreditCard, FaFileInvoiceDollar, FaTasks } from "react-icons/fa"; import { FiLogOut } from "react-icons/fi"; import { GiPayMoney, GiPlayerTime, GiSettingsKnobs } from "react-icons/gi"; import { IoBusinessOutline } from "react-icons/io5"; import { RiSurveyLine } from "react-icons/ri"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import { selectRecentItems, selectSelectedHeader } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; import { signOutStart } from "../../redux/user/user.actions"; import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import LockWrapper from "../lock-wrapper/lock-wrapper.component"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, recentItems: selectRecentItems, selectedHeader: selectSelectedHeader, bodyshop: selectBodyshop }); const mapDispatchToProps = (dispatch) => ({ setBillEnterContext: (context) => dispatch( setModalContext({ context: context, modal: "billEnter" }) ), setTimeTicketContext: (context) => dispatch( setModalContext({ context: context, modal: "timeTicket" }) ), setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" })), setReportCenterContext: (context) => dispatch( setModalContext({ context: context, modal: "reportCenter" }) ), signOutStart: () => dispatch(signOutStart()), setCardPaymentContext: (context) => dispatch( setModalContext({ context: context, modal: "cardPayment" }) ), setTaskUpsertContext: (context) => dispatch( setModalContext({ context: context, modal: "taskUpsert" }) ) }); function Header({ handleMenuClick, currentUser, bodyshop, selectedHeader, signOutStart, setBillEnterContext, setTimeTicketContext, setPaymentContext, setReportCenterContext, recentItems, setCardPaymentContext, setTaskUpsertContext }) { const { treatments: { ImEXPay, DmsAp, Simple_Inventory } } = useSplitTreatments({ attributes: {}, names: ["ImEXPay", "DmsAp", "Simple_Inventory"], splitKey: bodyshop && bodyshop.imexshopid }); const { t } = useTranslation(); // const deleteBetaCookie = () => { // const cookieExists = document.cookie.split("; ").some((row) => row.startsWith(`betaSwitchImex=`)); // if (cookieExists) { // const domain = window.location.hostname.split(".").slice(-2).join("."); // document.cookie = `betaSwitchImex=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${domain}`; // } // }; // // deleteBetaCookie(); const accountingChildren = []; accountingChildren.push( { key: "bills", id: "header-accounting-bills", icon: , label: ( {t("menus.header.bills")} ) }, { key: "enterbills", id: "header-accounting-enterbills", icon: , label: ( {t("menus.header.enterbills")} ), onClick: () => { HasFeatureAccess({ featureName: "bills", bodyshop }) && setBillEnterContext({ actions: {}, context: {} }); } } ); if (Simple_Inventory.treatment === "on") { accountingChildren.push( { type: "divider" }, { key: "inventory", id: "header-accounting-inventory", icon: , label: {t("menus.header.inventory")} } ); } accountingChildren.push( { type: "divider" }, { key: "allpayments", id: "header-accounting-allpayments", icon: , label: ( {t("menus.header.allpayments")} ) }, { key: "enterpayments", id: "header-accounting-enterpayments", icon: , label: ( {t("menus.header.enterpayment")} ), onClick: () => { HasFeatureAccess({ featureName: "payments", bodyshop }) && setPaymentContext({ actions: {}, context: null }); } } ); if (ImEXPay.treatment === "on") { accountingChildren.push({ key: "entercardpayments", id: "header-accounting-entercardpayments", icon: , label: t("menus.header.entercardpayment"), onClick: () => { setCardPaymentContext({ actions: {}, context: {} }); } }); } accountingChildren.push( { type: "divider" }, { key: "timetickets", id: "header-accounting-timetickets", icon: , label: ( {t("menus.header.timetickets")} ) } ); if (bodyshop?.md_tasks_presets?.use_approvals) { accountingChildren.push({ key: "ttapprovals", id: "header-accounting-ttapprovals", icon: , label: {t("menus.header.ttapprovals")} }); } accountingChildren.push( { key: "entertimetickets", icon: , label: ( {t("menus.header.entertimeticket")} ), id: "header-accounting-entertimetickets", onClick: () => { HasFeatureAccess({ featureName: "timetickets", bodyshop }) && setTimeTicketContext({ actions: {}, context: { created_by: currentUser.displayName ? currentUser.email.concat(" | ", currentUser.displayName) : currentUser.email } }); } }, { type: "divider" } ); const accountingExportChildren = [ { key: "receivables", id: "header-accounting-receivables", label: ( {t("menus.header.accounting-receivables")} ) } ]; if (!((bodyshop && bodyshop.cdk_dealerid) || (bodyshop && bodyshop.pbs_serialnumber)) || DmsAp.treatment === "on") { accountingExportChildren.push({ key: "payables", id: "header-accounting-payables", label: ( {t("menus.header.accounting-payables")} ) }); } if (!((bodyshop && bodyshop.cdk_dealerid) || (bodyshop && bodyshop.pbs_serialnumber))) { accountingExportChildren.push({ key: "payments", id: "header-accounting-payments", label: ( {t("menus.header.accounting-payments")} ) }); } accountingExportChildren.push( { type: "divider" }, { key: "exportlogs", id: "header-accounting-exportlogs", label: ( {t("menus.header.export-logs")} ) } ); accountingChildren.push({ key: "accountingexport", id: "header-accounting-export", icon: , label: ( {t("menus.header.export")} ), children: accountingExportChildren }); const menuItems = [ { key: "home", icon: , id: "header-home", label: {t("menus.header.home")} }, { key: "schedule", id: "header-schedule", icon: , label: {t("menus.header.schedule")} }, { key: "jobssubmenu", id: "header-jobs", icon: , label: t("menus.header.jobs"), children: [ { key: "activejobs", id: "header-active-jobs", icon: , label: {t("menus.header.activejobs")} }, { key: "readyjobs", id: "header-ready-jobs", icon: , label: {t("menus.header.readyjobs")} }, { key: "parts-queue", id: "header-parts-queue", icon: , label: {t("menus.header.parts-queue")} }, { key: "availablejobs", id: "header-jobs-available", icon: , label: {t("menus.header.availablejobs")} }, { key: "newjob", id: "header-new-job", icon: , label: {t("menus.header.newjob")} }, { type: "divider", id: "header-jobs-divider" }, { key: "alljobs", id: "header-all-jobs", icon: , label: {t("menus.header.alljobs")} }, { type: "divider", id: "header-jobs-divider2" }, { key: "productionlist", id: "header-production-list", icon: , label: {t("menus.header.productionlist")} }, { key: "productionboard", id: "header-production-board", icon: , label: ( {t("menus.header.productionboard")} ) }, { type: "divider", id: "header-jobs-divider3" }, { key: "scoreboard", id: "header-scoreboard", icon: , label: ( {t("menus.header.scoreboard")} ) } ] }, { key: "customers", icon: , id: "header-customers", label: t("menus.header.customers"), children: [ { key: "owners", id: "header-owners", icon: , label: {t("menus.header.owners")} }, { key: "vehicles", id: "header-vehicles", icon: , label: {t("menus.header.vehicles")} } ] }, { key: "ccs", id: "header-css", icon: , label: ( {t("menus.header.courtesycars")} ), children: [ { key: "courtesycarsall", id: "header-courtesycars-all", icon: , label: ( {t("menus.header.courtesycars-all")} ) }, { key: "contracts", id: "header-contracts", icon: , label: ( {t("menus.header.courtesycars-contracts")} ) }, { key: "newcontract", id: "header-newcontract", icon: , label: ( {t("menus.header.courtesycars-newcontract")} ) } ] }, ...(accountingChildren.length > 0 ? [ { key: "accounting", id: "header-accounting", icon: , label: t("menus.header.accounting"), children: accountingChildren } ] : []), { key: "phonebook", id: "header-phonebook", icon: , label: {t("menus.header.phonebook")} }, { key: "temporarydocs", id: "header-temporarydocs", icon: , label: ( {t("menus.header.temporarydocs")} ) }, { key: "tasks", id: "tasks", icon: , label: t("menus.header.tasks"), children: [ { key: "createTask", id: "header-create-task", icon: , label: t("menus.header.create_task"), onClick: () => { setTaskUpsertContext({ actions: {}, context: {} }); } }, { key: "mytasks", id: "header-my-tasks", icon: , label: {t("menus.header.my_tasks")} }, { key: "all_tasks", id: "header-all-tasks", icon: , label: {t("menus.header.all_tasks")} } ] }, { key: "shopsubmenu", id: "header-shopsubmenu", icon: , label: t("menus.header.shop"), children: [ { key: "shop", id: "header-shop", icon: , label: {t("menus.header.shop_config")} }, { key: "dashboard", id: "header-dashboard", icon: , label: ( {t("menus.header.dashboard")} ) }, { key: "reportcenter", id: "header-reportcenter", icon: , label: t("menus.header.reportcenter"), onClick: () => { setReportCenterContext({ actions: {}, context: {} }); } }, { key: "shop-vendors", id: "header-shop-vendors", icon: , label: {t("menus.header.shop_vendors")} }, { key: "shop-csi", id: "header-shop-csi", icon: , label: ( {t("menus.header.shop_csi")} ) } ] }, { key: "user", label: currentUser.displayName || currentUser.email || t("general.labels.unknown"), children: [ { key: "signout", id: "header-signout", icon: , danger: true, label: t("user.actions.signout"), onClick: () => signOutStart() }, { key: "help", id: "header-help", icon: , label: t("menus.header.help"), onClick: () => { window.open( InstanceRenderManager({ imex: "https://help.imex.online/", rome: "https://rometech.com//" }), "_blank" ); } }, ...(InstanceRenderManager({ imex: true, rome: false }) ? [ { key: "rescue", id: "header-rescue", icon: , label: t("menus.header.rescueme"), onClick: () => { window.open("https://imexrescue.com/", "_blank"); } } ] : []), { key: "shiftclock", id: "header-shiftclock", icon: , label: ( {t("menus.header.shiftclock")} ) }, { key: "profile", id: "header-profile", icon: , label: {t("menus.currentuser.profile")} } // { // key: 'langselecter', // label: t("menus.currentuser.languageselector"), // children: [ // { // key: 'en-US', // label: t("general.languages.english"), // onClick: () => { // window.location.href = "/?lang=en-US"; // } // }, // { // key: 'fr-CA', // label: t("general.languages.french"), // onClick: () => { // window.location.href = "/?lang=fr-CA"; // } // }, // { // key: 'es-MX', // label: t("general.languages.spanish"), // onClick: () => { // window.location.href = "/?lang=es-MX"; // } // }, // ] // }, ] }, { key: "recent", icon: , id: "header-recent", children: recentItems.map((i, idx) => ({ key: idx, id: `header-recent-${idx}`, label: {i.label} })) } ]; return ( ); } export default connect(mapStateToProps, mapDispatchToProps)(Header);