67 lines
2.4 KiB
JavaScript
67 lines
2.4 KiB
JavaScript
import Icon, { SearchOutlined } from "@ant-design/icons";
|
|
import { Layout, Menu } from "antd";
|
|
import React, { useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { FiLogIn, FiLogOut } from "react-icons/fi";
|
|
import { MdTimer, MdTimerOff } from "react-icons/md";
|
|
import { connect } from "react-redux";
|
|
import { Link } from "react-router-dom";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
|
import { techLogout } from "../../redux/tech/tech.actions";
|
|
const { Sider } = Layout;
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
technician: selectTechnician,
|
|
});
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
techLogout: () => dispatch(techLogout()),
|
|
});
|
|
|
|
export function TechSider({ technician, techLogout }) {
|
|
const [collapsed, setCollapsed] = useState(true);
|
|
const { t } = useTranslation();
|
|
const onCollapse = (collapsed) => {
|
|
setCollapsed(collapsed);
|
|
};
|
|
|
|
return (
|
|
<Sider collapsible collapsed={collapsed} onCollapse={onCollapse}>
|
|
<Menu theme="dark" defaultSelectedKeys={["1"]} mode="inline">
|
|
<Menu.Item
|
|
key="1"
|
|
disabled={!!technician}
|
|
icon={<Icon component={FiLogIn} />}
|
|
>
|
|
<Link to={`/tech/login`}>{t("menus.tech.login")}</Link>
|
|
</Menu.Item>
|
|
<Menu.Item key="2" disabled={!!!technician} icon={<SearchOutlined />}>
|
|
<Link to={`/tech/joblookup`}>{t("menus.tech.joblookup")}</Link>
|
|
</Menu.Item>
|
|
<Menu.Item
|
|
key="3"
|
|
disabled={!!!technician}
|
|
icon={<Icon component={MdTimer} />}
|
|
>
|
|
<Link to={`/tech/jobclockin`}>{t("menus.tech.jobclockin")}</Link>
|
|
</Menu.Item>
|
|
<Menu.Item key="5" disabled={!!!technician} icon={<SearchOutlined />}>
|
|
<Link to={`/tech/list`}>{t("menus.tech.productionlist")}</Link>
|
|
</Menu.Item>
|
|
<Menu.Item key="6" disabled={!!!technician} icon={<SearchOutlined />}>
|
|
<Link to={`/tech/board`}> {t("menus.tech.productionboard")}</Link>
|
|
</Menu.Item>
|
|
<Menu.Item
|
|
key="7"
|
|
disabled={!!!technician}
|
|
onClick={() => techLogout()}
|
|
icon={<Icon component={FiLogOut} />}
|
|
>
|
|
{t("menus.tech.logout")}
|
|
</Menu.Item>
|
|
</Menu>
|
|
</Sider>
|
|
);
|
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(TechSider);
|