feat: admin only bar items
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
import { barItems } from "../tabs";
|
import { useBarItems } from "../tabs";
|
||||||
|
|
||||||
export interface ISidebarProps {
|
export interface ISidebarProps {
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
@ -7,6 +7,8 @@ export interface ISidebarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Sidebar: FC<ISidebarProps> = ({ activeTab, onChangeTab }) => {
|
const Sidebar: FC<ISidebarProps> = ({ activeTab, onChangeTab }) => {
|
||||||
|
const barItems = useBarItems();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="hidden sm:flex flex-col gap-2 items-stretch min-w-80 w-80 p-5 pt-18 min-h-screen select-none bg-white/65 dark:bg-black/65 shadow-lg shadow-gray-300 dark:shadow-gray-700">
|
<div className="hidden sm:flex flex-col gap-2 items-stretch min-w-80 w-80 p-5 pt-18 min-h-screen select-none bg-white/65 dark:bg-black/65 shadow-lg shadow-gray-300 dark:shadow-gray-700">
|
||||||
{barItems.map((item) => (
|
{barItems.map((item) => (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { type FC } from "react";
|
import { type FC } from "react";
|
||||||
import { barItems } from "../tabs";
|
import { useBarItems } from "../tabs";
|
||||||
|
|
||||||
export interface ITopBarProps {
|
export interface ITopBarProps {
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
@ -7,6 +7,8 @@ export interface ITopBarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TopBar: FC<ITopBarProps> = ({ activeTab, onChangeTab }) => {
|
const TopBar: FC<ITopBarProps> = ({ activeTab, onChangeTab }) => {
|
||||||
|
const barItems = useBarItems();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sm:hidden flex w-full overflow-x-auto sm:overflow-x-visible max-w-full min-w-full sm:justify-center sm:space-x-4 no-scrollbar shadow-md shadow-gray-300 dark:shadow-gray-700 dark:bg-black/70 bg-white/70 pt-14">
|
<div className="sm:hidden flex w-full overflow-x-auto sm:overflow-x-visible max-w-full min-w-full sm:justify-center sm:space-x-4 no-scrollbar shadow-md shadow-gray-300 dark:shadow-gray-700 dark:bg-black/70 bg-white/70 pt-14">
|
||||||
{barItems.map((item) => (
|
{barItems.map((item) => (
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
import { Home, Settings2, User } from "lucide-react";
|
import { useAuth } from "@/store/auth";
|
||||||
|
import { Blocks, Home, Settings2, User } from "lucide-react";
|
||||||
|
|
||||||
export const barItems = [
|
export const useBarItems = () => {
|
||||||
|
const profile = useAuth((state) => state.profile);
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
icon: <Home />,
|
icon: <Home />,
|
||||||
title: "Home",
|
title: "Home",
|
||||||
@ -16,4 +24,14 @@ export const barItems = [
|
|||||||
title: "Data & Personalization",
|
title: "Data & Personalization",
|
||||||
tab: "data-personalization",
|
tab: "data-personalization",
|
||||||
},
|
},
|
||||||
|
...(profile.isAdmin
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
icon: <Blocks />,
|
||||||
|
title: "API Services",
|
||||||
|
tab: "api-services",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user