feat: add shift management functionality
This commit is contained in:
@@ -18,6 +18,7 @@ interface SidebarItem extends MenuItem {
|
||||
expanded?: boolean;
|
||||
items?: SidebarItem[];
|
||||
permission?: string | null;
|
||||
level?: string | null;
|
||||
}
|
||||
|
||||
const globalStore = useGlobalStore();
|
||||
@@ -31,9 +32,14 @@ function hasPermission(permission) {
|
||||
return userPermissions.value.includes(permission);
|
||||
}
|
||||
|
||||
function hasLevel(level) {
|
||||
if (!level) return true;
|
||||
return currentUser.value?.level === level;
|
||||
}
|
||||
|
||||
function filterSidebarItems(items) {
|
||||
return items
|
||||
.filter(item => hasPermission(item.permission))
|
||||
.filter(item => hasPermission(item.permission) && hasLevel(item.level))
|
||||
.map(item => {
|
||||
if (item.items) {
|
||||
const filteredChildren = filterSidebarItems(item.items);
|
||||
@@ -87,6 +93,7 @@ const items: Ref<SidebarItem[]> = ref([
|
||||
to: "/dashboard/shifts",
|
||||
key: 'shifts',
|
||||
permission: null,
|
||||
level: "پزشک",
|
||||
},
|
||||
// {
|
||||
// label: "خروج از سامانه",
|
||||
|
||||
Reference in New Issue
Block a user