feat: hide statistics, work time, expenses and finances from regular users
This commit is contained in:
@@ -15,10 +15,11 @@ import {
|
||||
IconSun,
|
||||
} from "@tabler/icons-react";
|
||||
import classes from "./Navbar.module.css";
|
||||
import { useAppDispatch } from "../../redux/store.ts";
|
||||
import { RootState, useAppDispatch } from "../../redux/store.ts";
|
||||
import { logout } from "../../features/authSlice.ts";
|
||||
import { useNavigate, useRouterState } from "@tanstack/react-router";
|
||||
import { setHideNavbar } from "../../features/uiSlice.ts";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
interface NavbarLinkProps {
|
||||
icon: typeof IconHome2;
|
||||
@@ -93,17 +94,21 @@ const mockdata = [
|
||||
label: "Маркетплейсы",
|
||||
href: "/marketplaces",
|
||||
},
|
||||
];
|
||||
|
||||
const adminMockdata = [
|
||||
{
|
||||
icon: IconChartDots,
|
||||
label: "Статистика",
|
||||
href: "/statistics",
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
export function Navbar() {
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
const router = useRouterState();
|
||||
const role = useSelector((state: RootState) => state.auth.role);
|
||||
const { colorScheme, toggleColorScheme } = useMantineColorScheme({
|
||||
keepTransitions: true,
|
||||
});
|
||||
@@ -114,9 +119,17 @@ export function Navbar() {
|
||||
const onNavlinkClick = (props: NavbarLinkProps) => {
|
||||
navigate({ to: props.href });
|
||||
};
|
||||
const links = mockdata.map((link, index) => (
|
||||
<NavbarLink
|
||||
|
||||
const getLinksData = () => {
|
||||
let data = mockdata;
|
||||
if (role === "admin") {
|
||||
data = data.concat(adminMockdata);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
const links = getLinksData().map((link, index) => (
|
||||
<NavbarLink
|
||||
{...link}
|
||||
index={index}
|
||||
key={link.label}
|
||||
|
||||
Reference in New Issue
Block a user