refactor: replace role-based access checks with canAccess utility in menu components
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
57660d7991
commit
8799799214
4 changed files with 131 additions and 111 deletions
|
|
@ -7,7 +7,7 @@ import useMyBranch from 'stores/my-branch';
|
|||
import { getUserId, getRole } from 'src/services/keycloak';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { isRoleInclude } from 'src/stores/utils';
|
||||
import { canAccess } from 'src/stores/utils';
|
||||
|
||||
type Menu = {
|
||||
label: string;
|
||||
|
|
@ -71,82 +71,41 @@ function initMenu() {
|
|||
{
|
||||
label: 'branch',
|
||||
route: '/branch-management',
|
||||
hidden: !isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
'head_of_accountant',
|
||||
]),
|
||||
hidden: !canAccess('branch'),
|
||||
},
|
||||
{
|
||||
label: 'personnel',
|
||||
route: '/personnel-management',
|
||||
hidden: !isRoleInclude([
|
||||
'owner',
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
]),
|
||||
hidden: !canAccess('personnel'),
|
||||
},
|
||||
{
|
||||
label: 'workflow',
|
||||
route: '/workflow',
|
||||
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
|
||||
hidden: !canAccess('workflow'),
|
||||
},
|
||||
{
|
||||
label: 'property',
|
||||
route: '/property',
|
||||
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
|
||||
hidden: !canAccess('workflow'),
|
||||
},
|
||||
{
|
||||
label: 'productService',
|
||||
route: '/product-service',
|
||||
hidden: !isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
'head_of_accountant',
|
||||
'head_of_sale',
|
||||
'sale',
|
||||
]),
|
||||
},
|
||||
{
|
||||
label: 'customer',
|
||||
route: '/customer-management',
|
||||
hidden: !isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
'head_of_accountant',
|
||||
'accountant',
|
||||
'head_of_sale',
|
||||
'sale',
|
||||
]),
|
||||
hidden: !canAccess('customer'),
|
||||
},
|
||||
{
|
||||
label: 'agencies',
|
||||
route: '/agencies-management',
|
||||
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'menu.sales',
|
||||
icon: 'mdi-store-settings-outline',
|
||||
hidden: !isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
'head_of_accountant',
|
||||
'accountant',
|
||||
'head_of_sale',
|
||||
'sale',
|
||||
]),
|
||||
children: [
|
||||
{ label: 'quotation', route: '/quotation' },
|
||||
{ label: 'invoice', route: '/invoice' },
|
||||
|
|
@ -169,16 +128,7 @@ function initMenu() {
|
|||
label: 'menu.account',
|
||||
icon: 'mdi-bank-outline',
|
||||
disabled: false,
|
||||
hidden: !isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'branch_manager',
|
||||
'head_of_accountant',
|
||||
'accountant',
|
||||
'head_of_sale',
|
||||
'sale',
|
||||
]),
|
||||
hidden: !canAccess('account'),
|
||||
children: [
|
||||
{ label: 'receipt', route: '/receipt' },
|
||||
{ label: 'creditNote', route: '/credit-note' },
|
||||
|
|
@ -200,10 +150,13 @@ function initMenu() {
|
|||
{
|
||||
label: 'menu.overall',
|
||||
icon: 'mdi-monitor-dashboard',
|
||||
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin', 'executive']),
|
||||
children: [
|
||||
{ label: 'report', route: '/report' },
|
||||
{ label: 'dashboard', route: '/dash-board' },
|
||||
{
|
||||
label: 'dashboard',
|
||||
route: '/dash-board',
|
||||
hidden: !canAccess('dashBoard'),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue