This commit is contained in:
@@ -159,6 +159,7 @@ export const CONTENT_PERMISSION_RESOURCES = ["blogs", "learnings", "advertisemen
|
|||||||
export const FINANCIAL_PERMISSION_RESOURCES = ["payments", "invoices", "transactions", "discounts", "bank_accounts"] as const;
|
export const FINANCIAL_PERMISSION_RESOURCES = ["payments", "invoices", "transactions", "discounts", "bank_accounts"] as const;
|
||||||
export const SUPPORT_PERMISSION_RESOURCES = ["support_plan", "tickets"] as const;
|
export const SUPPORT_PERMISSION_RESOURCES = ["support_plan", "tickets"] as const;
|
||||||
export const TASK_MANAGER_PERMISSION_RESOURCES = ["workspace", "project", "task", "task_phase"] as const;
|
export const TASK_MANAGER_PERMISSION_RESOURCES = ["workspace", "project", "task", "task_phase"] as const;
|
||||||
|
export const USERS_SIDEBAR_PERMISSION_RESOURCES = ["admins", ...TASK_MANAGER_PERMISSION_RESOURCES] as const;
|
||||||
export const PRODUCT_PERMISSION_RESOURCES = ["dmenu", "dkala", "dpage", "dmail"] as const;
|
export const PRODUCT_PERMISSION_RESOURCES = ["dmenu", "dkala", "dpage", "dmail"] as const;
|
||||||
|
|
||||||
type PermissionEntry = { name: string };
|
type PermissionEntry = { name: string };
|
||||||
|
|||||||
@@ -1,37 +1,32 @@
|
|||||||
import { FC, ReactNode } from 'react'
|
import { FC, ReactNode } from "react";
|
||||||
import { Link } from 'react-router-dom'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string;
|
||||||
icon: ReactNode,
|
icon: ReactNode;
|
||||||
color: string,
|
color: string;
|
||||||
count: number,
|
count: number;
|
||||||
description: string,
|
description: string;
|
||||||
to?: string
|
to?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
const ItemDashboard: FC<Props> = (props: Props) => {
|
const ItemDashboard: FC<Props> = (props: Props) => {
|
||||||
|
return (
|
||||||
|
<div className="p-6 min-w-[40%] xl:min-w-[15%] flex flex-col items-center xl:items-start flex-1 h-[178px] bg-white rounded-3xl">
|
||||||
|
<div className="size-10 rounded-full bg-[#EEF0F7] flex justify-center items-center">{props.icon}</div>
|
||||||
|
<div className="mt-5">{props.title}</div>
|
||||||
|
|
||||||
return (
|
<div className="mt-5 text-xs text-description flex gap-1.5 items-center">
|
||||||
<Link to={props.to ? props.to : ''} className='p-6 min-w-[40%] xl:min-w-[15%] flex flex-col items-center xl:items-start flex-1 h-[178px] bg-white rounded-3xl'>
|
<div
|
||||||
<div className='size-10 rounded-full bg-[#EEF0F7] flex justify-center items-center'>
|
style={{ background: props.color }}
|
||||||
{props.icon}
|
className="size-1.5 rounded-full"
|
||||||
</div>
|
></div>
|
||||||
<div className='mt-5'>
|
<div className="flex gap-0.5">
|
||||||
{props.title}
|
<div>{props.count}</div>
|
||||||
</div>
|
<div className="whitespace-nowrap">{props.description}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
<div className='mt-5 text-xs text-description flex gap-1.5 items-center'>
|
export default ItemDashboard;
|
||||||
<div style={{ background: props.color }} className='size-1.5 rounded-full'></div>
|
|
||||||
<div className='flex gap-0.5'>
|
|
||||||
<div>{props.count}</div>
|
|
||||||
<div className='whitespace-nowrap'>
|
|
||||||
{props.description}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ItemDashboard
|
|
||||||
|
|||||||
+10
-2
@@ -26,6 +26,8 @@ import {
|
|||||||
hasPermission,
|
hasPermission,
|
||||||
PRODUCT_PERMISSION_RESOURCES,
|
PRODUCT_PERMISSION_RESOURCES,
|
||||||
SUPPORT_PERMISSION_RESOURCES,
|
SUPPORT_PERMISSION_RESOURCES,
|
||||||
|
TASK_MANAGER_PERMISSION_RESOURCES,
|
||||||
|
USERS_SIDEBAR_PERMISSION_RESOURCES,
|
||||||
} from "../helpers/permissions";
|
} from "../helpers/permissions";
|
||||||
import { clx } from "../helpers/utils";
|
import { clx } from "../helpers/utils";
|
||||||
import { useGetProfile } from "../pages/profile/hooks/useProfileData";
|
import { useGetProfile } from "../pages/profile/hooks/useProfileData";
|
||||||
@@ -65,6 +67,12 @@ const SideBar: FC = () => {
|
|||||||
return Pages.dashboard;
|
return Pages.dashboard;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const usersDefaultLink = (() => {
|
||||||
|
if (hasPermission(permissions, "admins")) return Pages.users.list;
|
||||||
|
if (hasAnyPermission(permissions, TASK_MANAGER_PERMISSION_RESOURCES)) return Pages.taskmanager.workspaceList;
|
||||||
|
return Pages.users.list;
|
||||||
|
})();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const groupName = getSubMenuNameFromPath(location.pathname);
|
const groupName = getSubMenuNameFromPath(location.pathname);
|
||||||
|
|
||||||
@@ -197,9 +205,9 @@ const SideBar: FC = () => {
|
|||||||
}
|
}
|
||||||
title={t("sidebar.users")}
|
title={t("sidebar.users")}
|
||||||
isActive={isGroupActive("users")}
|
isActive={isGroupActive("users")}
|
||||||
link={Pages.users.list}
|
link={usersDefaultLink}
|
||||||
name="users"
|
name="users"
|
||||||
activeName="admins"
|
activeNames={USERS_SIDEBAR_PERMISSION_RESOURCES}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SideBarItem
|
<SideBarItem
|
||||||
|
|||||||
Reference in New Issue
Block a user